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>
,InputTrustHandler
,Consumer<RoutingContext>
public class CSRFHandler extends Object implements InputTrustHandler, 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 theoriginal
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<CSRFHandler>
__TYPE_ARG
static String
DEFAULT_COOKIE_NAME
static String
DEFAULT_COOKIE_PATH
static String
DEFAULT_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 void
accept(RoutingContext item)
static CSRFHandler
create(Vertx vertx, String secret)
boolean
equals(Object o)
io.vertx.ext.web.handler.CSRFHandler
getDelegate()
void
handle(RoutingContext arg0)
int
hashCode()
static CSRFHandler
newInstance(io.vertx.ext.web.handler.CSRFHandler arg)
CSRFHandler
setCookieHttpOnly(boolean httpOnly)
CSRFHandler
setCookieName(String name)
CSRFHandler
setCookiePath(String path)
CSRFHandler
setCookieSecure(boolean secure)
CSRFHandler
setHeaderName(String name)
CSRFHandler
setNagHttps(boolean nag)
CSRFHandler
setOrigin(String origin)
CSRFHandler
setTimeout(long timeout)
String
toString()
-
-
-
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()
- Specified by:
getDelegate
in interfaceInputTrustHandler
-
handle
public void handle(RoutingContext arg0)
- Specified by:
handle
in interfaceio.vertx.core.Handler<RoutingContext>
- Specified by:
handle
in interfaceInputTrustHandler
-
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
-
setCookieSecure
public CSRFHandler setCookieSecure(boolean secure)
- Parameters:
secure
- true to set the secure flag on the cookie- Returns:
- a reference to this, so the API can be used fluently
-
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:
accept
in interfaceConsumer<RoutingContext>
- Specified by:
accept
in interfaceInputTrustHandler
-
newInstance
public static CSRFHandler newInstance(io.vertx.ext.web.handler.CSRFHandler arg)
-
-