Class SignedCookieSessionStore
java.lang.Object
org.apache.juneau.rest.server.auth.oidc.rp.SignedCookieSessionStore
- All Implemented Interfaces:
SessionStore
Stateless
SessionStore that serializes the session into an HMAC-signed compact JWT carried
entirely in the session cookie. This is the documented default.
Because the session lives client-side, this store scales horizontally and survives server restarts with no shared store. The trade-offs:
- No server-side revocation —
supportsServerSideRevocation()isfalse ; a stateless cookie cannot be force-revoked, so this store does NOT support back-channel logout. UseInMemorySessionStoreor a caller-supplied distributed store if back-channel logout is required. - Size cap — cookies are capped (~4 KB); only minimal claims are stored, never the raw access / refresh / ID tokens. An over-cap payload throws rather than silently truncating.
- Key rotation — rotating the signing key invalidates all live sessions (users are bounced to re-login).
The payload is signed with HS256 using the configured signing key (which must be at least 256
bits / 32 bytes). Signature failures, expiry, and parse errors all resolve to
Optional.empty() on lookup(String) (fail-closed).
- Since:
- 10.0.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum serialized cookie size in bytes. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptioncreate()Static creator.createSessionCookieValue(OidcSession session) Persists the supplied session and returns the opaque value to set as the session cookie.voidinvalidate(String cookieValue) Invalidates the session identified by the supplied cookie value.Resolves a session from a cookie value.booleanReturns whether this store can revoke sessions server-side (a prerequisite for back-channel logout).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.juneau.rest.server.auth.oidc.rp.SessionStore
invalidateBySessionId, invalidateBySubject
-
Field Details
-
DEFAULT_MAX_COOKIE_BYTES
Default maximum serialized cookie size in bytes.- See Also:
-
-
Constructor Details
-
SignedCookieSessionStore
Constructor.- Parameters:
b- The builder.
-
-
Method Details
-
create
Static creator.- Returns:
- A new builder.
-
createSessionCookieValue
Description copied from interface:SessionStorePersists the supplied session and returns the opaque value to set as the session cookie.For a server-side store this is typically a random session id used as a lookup key; for a stateless cookie store it is the entire signed session payload.
- Specified by:
createSessionCookieValuein interfaceSessionStore- Parameters:
session- The session to persist. Must not benull .- Returns:
- The cookie value the client should send back on subsequent requests. Never
null .
-
lookup
Description copied from interface:SessionStoreResolves a session from a cookie value.- Specified by:
lookupin interfaceSessionStore- Parameters:
cookieValue- The cookie value previously returned bySessionStore.createSessionCookieValue(org.apache.juneau.rest.server.auth.oidc.rp.OidcSession). Must not benull .- Returns:
- The resolved session, or
Optional.empty()if absent, expired, invalid, or tampered.
-
invalidate
Description copied from interface:SessionStoreInvalidates the session identified by the supplied cookie value. No-op if absent.- Specified by:
invalidatein interfaceSessionStore- Parameters:
cookieValue- The cookie value. Must not benull .
-
supportsServerSideRevocation
Description copied from interface:SessionStoreReturns whether this store can revoke sessions server-side (a prerequisite for back-channel logout).Defaults to
false — stateless cookie stores cannot revoke a session the server never retained.- Specified by:
supportsServerSideRevocationin interfaceSessionStore- Returns:
true ifSessionStore.invalidateBySubject(String)/SessionStore.invalidateBySessionId(String)are supported.
-