Package io.quarkus.vertx.http.security
Interface CSRF.Builder
- Enclosing interface:
CSRF
public static interface CSRF.Builder
The Quarkus CSRF prevention configuration builder.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Create a new CSRF configuration.cookieDomain(String cookieDomain) The CSRF cookie domain.Set the 'secure' parameter on the CSRF cookie to 'true' when the HTTP protocol is used.cookieHttpOnly(boolean cookieHttpOnly) Set the HttpOnly attribute to prevent access to the cookie via JavaScript.cookieMaxAge(Duration cookieMaxAge) The CSRF cookie max age.cookieName(String cookieName) The CSRF cookie name.cookiePath(String cookiePath) The CSRF cookie path.createTokenPath(String createTokenPath) This method is a shortcut forcreateTokenPath(Set.of(createTokenPath)).createTokenPath(Set<String> createTokenPath) Create CSRF token only if the HTTP GET relative request path matches one of configured paths.formFieldName(String formFieldName) Form field name which keeps a CSRF token.requireFormUrlEncoded(boolean requireFormUrlEncoded) Require that only 'application/x-www-form-urlencoded' or 'multipart/form-data' body is accepted for the token verification to proceed.tokenHeaderName(String tokenHeaderName) The token header name which can provide a CSRF token.tokenSignatureKey(String tokenSignatureKey) The CSRF token signature key.tokenSize(int tokenSize) Random CSRF token size in bytes.
-
Method Details
-
formFieldName
Form field name which keeps a CSRF token. The default field name is "csrf-token".- Parameters:
formFieldName- form field name- Returns:
- this builder
-
tokenHeaderName
The token header name which can provide a CSRF token. The default name is "X-CSRF-TOKEN".- Parameters:
tokenHeaderName- the CSRF token header name- Returns:
- this builder
-
cookieName
The CSRF cookie name. The default name is "csrf-token".- Parameters:
cookieName- the CSRF cookie name- Returns:
- this builder
-
cookieMaxAge
The CSRF cookie max age. The default max age are 2 hours.- Parameters:
cookieMaxAge- the CSRF cookie max age- Returns:
- this builder
-
cookiePath
The CSRF cookie path. The default path is "/".- Parameters:
cookiePath- the CSRF cookie path- Returns:
- this builder
-
cookieDomain
The CSRF cookie domain.- Parameters:
cookieDomain- the CSRF cookie domain- Returns:
- this builder
-
cookieForceSecure
CSRF.Builder cookieForceSecure()Set the 'secure' parameter on the CSRF cookie to 'true' when the HTTP protocol is used. The cookie will always be secure if the HTTPS protocol is used, even if this method is not called.- Returns:
- this builder
-
cookieHttpOnly
Set the HttpOnly attribute to prevent access to the cookie via JavaScript. The HttpOnly attribute is set by default.- Parameters:
cookieHttpOnly- if the HttpOnly attribute should be set- Returns:
- this builder
-
createTokenPath
This method is a shortcut forcreateTokenPath(Set.of(createTokenPath)).- Returns:
- this builder
- See Also:
-
createTokenPath
Create CSRF token only if the HTTP GET relative request path matches one of configured paths.- Parameters:
createTokenPath- list of the HTTP GET requests paths for which Quarkus should create a token- Returns:
- this builder
-
tokenSize
Random CSRF token size in bytes. The default size in bytes is 16.- Parameters:
tokenSize- the token size in bytes- Returns:
- this builder
-
tokenSignatureKey
The CSRF token signature key.- Parameters:
tokenSignatureKey- the CSRF token signature key- Returns:
- this builder
-
requireFormUrlEncoded
Require that only 'application/x-www-form-urlencoded' or 'multipart/form-data' body is accepted for the token verification to proceed. Required by default.- Parameters:
requireFormUrlEncoded- if only 'application/x-www-form-urlencoded' or 'multipart/form-data' body is allowed- Returns:
- this builder
-
build
CSRF build()Create a new CSRF configuration.- Returns:
- CSRF instance, which should be passed to the
HttpSecurityevent
-