Class CSRFDoubleSubmitCookieInterceptor.Builder
- Enclosing class:
CSRFDoubleSubmitCookieInterceptor<A extends ExchangeContext,B extends Exchange<A>>
A CSRF double submit cookie interceptor builder.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe cookie name.protected StringThe CSRF token cookie domain parameter.protected StringThe header name.protected BooleanThe CSRF token cookie httpOnly parameter.protected IntegerThe CSRF token cookie max age parameter.protected StringThe parameter name.protected StringThe CSRF token cookie path parameter.protected BooleanThe CSRF token cookie secure parameter. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilder()Creates a CSRF double submit cookie interceptor builder. -
Method Summary
Modifier and TypeMethodDescription<A extends ExchangeContext,B extends Exchange<A>>
CSRFDoubleSubmitCookieInterceptor<A, B> build()Builds a CSRF double submit cookie interceptor.cookieName(String cookieName) Specifies the name of the CSRF token cookie.Specifies the domain of the CSRF token cookie.headerName(String headerName) Specifies the name of the CSRF token header.httpOnly(boolean httpOnly) Specifies thehttpOnlyflag of the CSRF token cookie.maxAge(int maxAge) Specifies the max age of the CSRF token cookie.parameterName(String parameterName) Specifies the name of the CSRF token parameter.Specifies the path of the CSRF token cookie.secure(boolean secure) Specifies thesecureflag of the CSRF token cookie.
-
Field Details
-
cookieName
The cookie name. -
headerName
The header name. -
parameterName
The parameter name. -
maxAge
The CSRF token cookie max age parameter. -
domain
The CSRF token cookie domain parameter. -
path
The CSRF token cookie path parameter. -
secure
The CSRF token cookie secure parameter. -
httpOnly
The CSRF token cookie httpOnly parameter.
-
-
Constructor Details
-
Builder
protected Builder()Creates a CSRF double submit cookie interceptor builder.
-
-
Method Details
-
cookieName
Specifies the name of the CSRF token cookie.
- Parameters:
cookieName- a cookie name- Returns:
- this builder
-
headerName
Specifies the name of the CSRF token header.
- Parameters:
headerName- a header name- Returns:
- this builder
-
parameterName
Specifies the name of the CSRF token parameter.
- Parameters:
parameterName- a parameter name- Returns:
- this builder
-
maxAge
Specifies the max age of the CSRF token cookie.
- Parameters:
maxAge- a max age in seconds- Returns:
- this builder
-
domain
Specifies the domain of the CSRF token cookie.
- Parameters:
domain- a domain- Returns:
- this builder
-
path
Specifies the path of the CSRF token cookie.
- Parameters:
path- a path- Returns:
- this builder
-
secure
Specifies the
secureflag of the CSRF token cookie.If not specified, this is enabled by default which is the recommended behaviour.
- Parameters:
secure- true to create a secured cookie, false otherwise- Returns:
- this builder
-
httpOnly
Specifies the
httpOnlyflag of the CSRF token cookie.If not specified, this is enabled by default which is the recommended behaviour.
You might need to set this to false when using JavaScript frameworks such as Angular, which requires to access the CSRF cookie token value in order to be able to send it in fetch calls in an HTTP header or a query parameter.
- Parameters:
httpOnly- true to create an HTTP only cookie, false otherwise- Returns:
- this builder
-
build
public <A extends ExchangeContext,B extends Exchange<A>> CSRFDoubleSubmitCookieInterceptor<A,B> build()Builds a CSRF double submit cookie interceptor.
- Type Parameters:
A- the context typeB- the exchange type- Returns:
- a CSRF double submit cookie interceptor
-