Repository navigation
v26.6.31
Spring Security parity — Tier 2: the web authentication mechanisms. The
classic browser/login surface from Spring's HttpSecurity, built on the Tier 1
authentication spine. All additive (no behaviour change to existing code).
Adversarially reviewed before release; the review's six confirmed findings are
fixed in this release.
Added
- HTTP Basic (
httpBasic()) —HttpBasicLayerreads
Authorization: Basic …and authenticates through theAuthenticationManager
spine. An absent header passes through (so a session/bearer layer can take
over); an invalid or malformed one is rejected with401and a
WWW-Authenticate: Basic realm="…"challenge (configurable realm, pluggable
BasicAuthenticationEntryPoint) — Spring'sBasicAuthenticationFilter. - Form login (
formLogin()) —form_login_routesmountsPOST /login
(url-encodedusername+password), rotates the session id on success
(anti-fixation) before persisting the context through a
SecurityContextRepository, then redirects. Success/failure responses are
swappable (FormLoginSuccessHandler/FormLoginFailureHandler), and the
success path is saved-request-aware. - Remember-me (
rememberMe()) —TokenBasedRememberMeServicesmints a
signed, expiring cookie token whose signature is an HMAC-SHA256 keyed by a
server secret over the username, expiry, and the user's stored password hash:
a password change, an expired clock, a tampered token, or the wrong key all
reject. New trust-level methods onAuthentication—
is_remembered()/is_fully_authenticated()(+REMEMBERED_CLAIM) — so a
remembered context is authenticated but not fully authenticated (Spring's
isFullyAuthenticated()), and a sensitive route can demand a fresh login. RequestCache/SavedRequest—HttpSessionRequestCacheremembers the
page an unauthenticated user wanted; form login returns them there after
login instead of the default target (Spring's
SavedRequestAwareAuthenticationSuccessHandler). Only same-origin targets
are honoured (SavedRequest::is_safe_redirect): a protocol-relative,
backslash-tricked, absolute, or control-char target falls back to the
configured success URL, so the login flow can't be turned into an open
redirect.NullRequestCachefor stateless surfaces.SessionCreationPolicy—Always/IfRequired(default) /Never/
Stateless(Spring'ssessionManagement().sessionCreationPolicy(...)).
SessionAuthenticationLayer::session_creation_policy(...)installs the implied
SecurityContextRepository;Statelessuses the null repository (no session
context) for token-only APIs.- Multiple filter chains —
SecurityFilterChainsroutes each request to the
first chain whoseRequestMatcher(AnyRequestMatcher/
PathRequestMatcher, segment-aware, optional method) matches, so a
locked-down/api/**and a permissive web surface coexist (Spring's
FilterChainProxy); an unmatched request passes through. The dispatcher
honours tower's readiness contract for a backpressure-bearing inner service.
Known limitations (roadmap)
TokenBasedRememberMeServicesis the stateless of Spring's two
remember-me strategies: a captured cookie replays for the full validity window
(default 14 days) until the embedded expiry passes or the user's password hash
changes — there is no per-token series/rotation theft detection (Spring's
PersistentTokenBasedRememberMeServices) and no server-side revocation list.
Use a shorttoken_validity_secondsand serve the cookieHttpOnly+SecureSameSite. A persistent/series variant is a follow-up.
RequestCache::save_requestis provided for an authentication entry point to
call before redirecting to login; wiring an entry point that auto-saves the
request is left to the application (the consume side is wired into form login).