Package com.jsgalactic.axiom.security
Class Sessions.Builder
java.lang.Object
com.jsgalactic.axiom.security.Sessions.Builder
- Enclosing class:
Sessions
Builds
Sessions; used during configuration, not thread-safe.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the sessions.cookieName(String name) Sets the cookie name.Sets a cookie domain, which sends the cookie to every sub-domain; the default is host-only.Makes the cookie persistent for this long (default: a browser-session cookie).maxCookieHeader(int maxCookieHeader) Sets the longestCookieheader read (default 8,192 characters).Sets the cookie path (default/).random(SecureRandom random) Sets the source of identifiers; for tests that need determinism.sameSite(SetCookie.SameSite sameSite) SetsSameSite(Lax by default).secure(boolean secure) Sets theSecureattribute (on by default).
-
Method Details
-
cookieName
Sets the cookie name. A__Host-or__Secure-prefix is checked against the other settings when built.- Parameters:
name- cookie name, an HTTP token- Returns:
- this builder
-
secure
Sets theSecureattribute (on by default). Browsers drop Secure cookies received over plain HTTP, so turn it off only for local development.- Parameters:
secure- whether the cookie is Secure- Returns:
- this builder
-
sameSite
SetsSameSite(Lax by default).NONErequiresSecure.- Parameters:
sameSite- the attribute- Returns:
- this builder
-
path
Sets the cookie path (default/).- Parameters:
path- path starting with/- Returns:
- this builder
-
domain
Sets a cookie domain, which sends the cookie to every sub-domain; the default is host-only.- Parameters:
domain- a lower-case DNS name without a leading dot- Returns:
- this builder
-
maxAge
Makes the cookie persistent for this long (default: a browser-session cookie). The store's timeouts still decide when the session ends.- Parameters:
maxAge- 0 to 400 days- Returns:
- this builder
-
random
Sets the source of identifiers; for tests that need determinism.- Parameters:
random- a cryptographically strong generator- Returns:
- this builder
-
maxCookieHeader
Sets the longestCookieheader read (default 8,192 characters).- Parameters:
maxCookieHeader- 64 to 65,536- Returns:
- this builder
-
build
Builds the sessions.- Returns:
- the middleware
- Throws:
IllegalArgumentException- if the cookie settings are inconsistent
-