Class: VertxWeb::CSRFHandler
- Inherits:
-
Object
- Object
- VertxWeb::CSRFHandler
- Defined in:
- /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/csrf_handler.rb
Overview
This handler adds a CSRF token to requests which mutate state. In order change the state a (XSRF-TOKEN) cookie is set
with a unique token, that is expected to be sent back in a (X-XSRF-TOKEN) header.
The behavior is to check the request body header and cookie for validity.
This Handler requires session support, thus should be added somewhere below Session and Body handlers.
Class Method Summary (collapse)
-
+ (::VertxWeb::CSRFHandler) create(secret = nil)
Instantiate a new CSRFHandlerImpl with a secret CSRFHandler.create("s3cr37").
Instance Method Summary (collapse)
- - (void) handle(arg0 = nil)
-
- (self) set_cookie_name(name = nil)
Set the cookie name.
-
- (self) set_header_name(name = nil)
Set the header name.
-
- (self) set_nag_https(nag = nil)
Should the handler give warning messages if this handler is used in other than https protocols?.
-
- (self) set_timeout(timeout = nil)
Set the timeout for tokens generated by the handler, by default it uses the default from the session handler.
Class Method Details
+ (::VertxWeb::CSRFHandler) create(secret = nil)
Instantiate a new CSRFHandlerImpl with a secret
CSRFHandler.create("s3cr37")
37 38 39 40 41 42 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/csrf_handler.rb', line 37 def self.create(secret=nil) if secret.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::CSRFHandler.java_method(:create, [Java::java.lang.String.java_class]).call(secret),::VertxWeb::CSRFHandler) end raise ArgumentError, "Invalid arguments when calling create(secret)" end |
Instance Method Details
- (void) handle(arg0 = nil)
This method returns an undefined value.
24 25 26 27 28 29 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/csrf_handler.rb', line 24 def handle(arg0=nil) if arg0.class.method_defined?(:j_del) && !block_given? return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(arg0.j_del) end raise ArgumentError, "Invalid arguments when calling handle(arg0)" end |
- (self) set_cookie_name(name = nil)
Set the cookie name. By default XSRF-TOKEN is used as it is the expected name by AngularJS however other frameworks
might use other names.
47 48 49 50 51 52 53 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/csrf_handler.rb', line 47 def (name=nil) if name.class == String && !block_given? @j_del.java_method(:setCookieName, [Java::java.lang.String.java_class]).call(name) return self end raise ArgumentError, "Invalid arguments when calling set_cookie_name(name)" end |
- (self) set_header_name(name = nil)
Set the header name. By default X-XSRF-TOKEN is used as it is the expected name by AngularJS however other
frameworks might use other names.
58 59 60 61 62 63 64 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/csrf_handler.rb', line 58 def set_header_name(name=nil) if name.class == String && !block_given? @j_del.java_method(:setHeaderName, [Java::java.lang.String.java_class]).call(name) return self end raise ArgumentError, "Invalid arguments when calling set_header_name(name)" end |
- (self) set_nag_https(nag = nil)
Should the handler give warning messages if this handler is used in other than https protocols?
68 69 70 71 72 73 74 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/csrf_handler.rb', line 68 def set_nag_https(nag=nil) if (nag.class == TrueClass || nag.class == FalseClass) && !block_given? @j_del.java_method(:setNagHttps, [Java::boolean.java_class]).call(nag) return self end raise ArgumentError, "Invalid arguments when calling set_nag_https(nag)" end |
- (self) set_timeout(timeout = nil)
Set the timeout for tokens generated by the handler, by default it uses the default from the session handler.
78 79 80 81 82 83 84 |
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/csrf_handler.rb', line 78 def set_timeout(timeout=nil) if timeout.class == Fixnum && !block_given? @j_del.java_method(:setTimeout, [Java::long.java_class]).call(timeout) return self end raise ArgumentError, "Invalid arguments when calling set_timeout(timeout)" end |