Package io.vertx.mutiny.ext.web.handler
Class CSRFHandler
- java.lang.Object
-
- io.vertx.mutiny.ext.web.handler.CSRFHandler
-
- All Implemented Interfaces:
io.vertx.core.Handler<RoutingContext>,Consumer<RoutingContext>
public class CSRFHandler extends Object implements io.vertx.core.Handler<RoutingContext>, Consumer<RoutingContext>
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. NOTE: This class has been automatically generated from theoriginalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<CSRFHandler>__TYPE_ARGstatic StringDEFAULT_COOKIE_NAMEstatic StringDEFAULT_COOKIE_PATHstatic StringDEFAULT_HEADER_NAME
-
Constructor Summary
Constructors Constructor Description CSRFHandler(io.vertx.ext.web.handler.CSRFHandler delegate)CSRFHandler(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(RoutingContext item)static CSRFHandlercreate(Vertx vertx, String secret)booleanequals(Object o)io.vertx.ext.web.handler.CSRFHandlergetDelegate()voidhandle(RoutingContext arg0)inthashCode()static CSRFHandlernewInstance(io.vertx.ext.web.handler.CSRFHandler arg)CSRFHandlersetCookieHttpOnly(boolean httpOnly)CSRFHandlersetCookieName(String name)CSRFHandlersetCookiePath(String path)CSRFHandlersetHeaderName(String name)CSRFHandlersetNagHttps(boolean nag)CSRFHandlersetOrigin(String origin)CSRFHandlersetTimeout(long timeout)StringtoString()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<CSRFHandler> __TYPE_ARG
-
DEFAULT_COOKIE_NAME
public static final String DEFAULT_COOKIE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_COOKIE_PATH
public static final String DEFAULT_COOKIE_PATH
- See Also:
- Constant Field Values
-
DEFAULT_HEADER_NAME
public static final String DEFAULT_HEADER_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CSRFHandler
public CSRFHandler(io.vertx.ext.web.handler.CSRFHandler delegate)
-
CSRFHandler
public CSRFHandler(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.ext.web.handler.CSRFHandler getDelegate()
-
handle
public void handle(RoutingContext arg0)
- Specified by:
handlein interfaceio.vertx.core.Handler<RoutingContext>
-
create
public static CSRFHandler create(Vertx vertx, String secret)
- Parameters:
vertx-secret- server secret to sign the token.- Returns:
-
setOrigin
public CSRFHandler setOrigin(String origin)
- Parameters:
origin- the origin for this server e.g.:https://www.foo.com.- Returns:
- fluent
-
setCookieName
public CSRFHandler setCookieName(String name)
- Parameters:
name- a new name for the cookie.- Returns:
- fluent
-
setCookiePath
public CSRFHandler setCookiePath(String path)
- Parameters:
path- a new path for the cookie.- Returns:
- fluent
-
setCookieHttpOnly
public CSRFHandler setCookieHttpOnly(boolean httpOnly)
- Parameters:
httpOnly- a new name for the header.- Returns:
- fluent
-
setHeaderName
public CSRFHandler setHeaderName(String name)
- Parameters:
name- a new name for the header.- Returns:
- fluent
-
setNagHttps
public CSRFHandler setNagHttps(boolean nag)
- Parameters:
nag- true to nag- Returns:
- fluent
-
setTimeout
public CSRFHandler setTimeout(long timeout)
- Parameters:
timeout- token timeout- Returns:
- fluent
-
accept
public void accept(RoutingContext item)
- Specified by:
acceptin interfaceConsumer<RoutingContext>
-
newInstance
public static CSRFHandler newInstance(io.vertx.ext.web.handler.CSRFHandler arg)
-
-