spring_boot_starter_security 0.8.3
spring_boot_starter_security: ^0.8.3 copied to clipboard
Spring Security for the web starter: a filter chain configured with HttpSecurity, HTTP Basic, form login, sessions, CSRF, CORS, security headers, JWT resource servers.
0.8.3 #
- No changes of its own; released with the family version 0.8.3.
0.8.2 #
- No changes of its own; released with the family version 0.8.2.
0.8.1 #
- No changes of its own; released with the family version 0.8.1.
0.8.0 #
- An authentication set outside a request (by a
@Scheduledmethod, a timer, a listener of a stream opened at startup) is the one of the whole program and stays: a WARN onspring.security.context.ProgramWideAuthenticationsays so once per place in the code, with the place and without the user (ProgramWideAuthenticationMonitor; nothing is refused). Withmanagement.health.securityContext.enabled=truethe health hassecurityContext: whether there is such an authentication now and how many times one was set, alwaysUP. Off by default, so the health is Spring Boot's. spring.security.oauth2.resourceserver.jwt.authorities-claim-name(JwtGrantedAuthoritiesConverter.authoritiesClaimName) may be a path into nested objects (realm_access.roles): a claim of exactly that name wins, the path is walked only without one, and a missing or non-object part gives no authorities.spring.security.oauth2.resourceserver.jwt.required-claims.<claim>: claims every bearer token must have with exactly the given value (a number or a boolean as its text), on every auto-configured decoder; otherwise a 401invalid_token.- Every
OAuth2TokenValidator<Jwt>bean is added to the validators of the auto-configuredjwtDecoder, as in Spring Boot;JwtDecoders.fromIssuerLocationtakes avalidatorrun after its own checks. spring.security.oauth2.resourceserver.jwt.secret-key: a resource server for tokens signed with a shared secret (its UTF-8 bytes;jws-algorithmsone ofHS256, the default,HS384,HS512), with the same claim checks;issuer-uribeside it is only compared withiss. Startup fails withjwk-set-uribeside it, another or more than one algorithm, or a secret shorter than the hash. For a server only, never in a client application.JwtimplementsOAuth2Tokenofspring_security_core.spring.security.oauth2.resourceserver.jwt.require-expiry(JwtTimestampValidator(requireExpiry: true)): a bearer token without anexpclaim is refused; off by default, as in Spring Security.- A decoder of a shared secret (
secret-key,NimbusJwtDecoder.withSecretKey) no longer refuses a token whose header has akid: there is one secret and no key set to choose from, the signature decides.
0.7.4 #
- The modules are only where a server can run (
ModulePlatform.native): a browser build has none of their code.
0.7.3 #
- No changes of its own; released with the family version 0.7.3.
0.7.2 #
- README: the link goes to the package's own page on farum-azula.org, and what the README says was checked against the code and brought up to date.
- Docs: the default CSRF repository is described as it is, the
XSRF-TOKENcookie (HttpOnly, SameSite=Lax, not signed) read fromX-XSRF-TOKEN; the session repository is the alternative.maximumSessionsand the session registry are no longer listed as missing. - The package's page on pub.dev links its documentation, farum-azula.org (
documentationinpubspec.yaml).
0.7.1 #
Changes #
- Breaking: the Feign starter no longer comes through this import (the OAuth2 client stopped re-exporting it): an application with Feign clients lists
spring_boot_starter_feignand imports it. EndpointRequest.toAnyEndpoint(),.to(...),.toLinks(),.excluding(...)and.excludingLinks(): request matchers of the actuator's endpoints for aSecurityFilterChain, as Spring Boot's; they match the requests the actuator starter recorded as endpoint requests, so they follow its base path and exposure.AuthenticationRoleChecker(theauthenticationRoleCheckerbean, unless the application declares aPrincipalRoleChecker): the roles of the request'sAuthenticationfor the actuator'sshow-details=when-authorized(ROLE_ADMINis the roleADMIN).- The starter now depends on
spring_boot_actuator(the endpoints' model only: no endpoint and no auto-configuration come with it).
0.7.0 #
- No changes of its own: its generated code (
lib/spring_gen/) is regenerated with spring_core_dart_generator 0.7.0.
0.6.3 #
Changes #
- The editor metadata of
spring.security.*is made from code and the starter reads the same class:SecurityPropertiesis bound by the Binder. The hand-writtenspring_metadata_additional.jsonis gone.
0.6.2 #
- feat: 0.6.2 — the theme (typed keys and messages, states, every component, a theme from a URL), (#20)
0.6.1 #
- No changes of its own; released with the family version 0.6.1.
0.6.0 #
Changes #
- Checked against Project Wycheproof's test vectors (Apache-2.0,
test/fixtures/wycheproof/): the JWS verifier on 3 200 ECDSA (ES256, ES384, ES512), RSA PKCS#1 v1.5 (RS256, RS384, RS512), RSA-PSS (PS256, PS384, PS512) and HMAC cases, and the JWK parser and the DPoP proof'sjwkheader on the invalid-curve points of the ECDH vectors: no invalid signature or key is accepted, no valid one is refused. An RSA PKCS#1 signature whose DigestInfo lacks the NULL after the hash OID (Wycheproof'sacceptableMissingNull) verifies, as in pointycastle. - The chain logs its main steps with Spring Security's texts, so
logging.level.root=debugshows what security decides. Debug:Will secure <matcher> with filters: ...(when a chain is built),Securing GET /api/books,Secured GET /api/books,Set SecurityContextHolder to UsernamePasswordAuthenticationToken [Principal=ada, Credentials=[PROTECTED], ...](form, Basic, bearer, DPoP and OAuth 2.0 logins),Failed to process authentication request: Bad credentials,Sending AnonymousAuthenticationToken [...] to authentication entry point since access is denied,Failed to authorize GET /x with ...,Invalid CSRF token found for /login,Changed session id,Logging out [...],Authenticated token(resource server), the DPoP proof accepted or rejected with its reason, the redirect to the provider, the callback received, the ID token validated, the JWK Set fetched. Trace:Invoking <Filter> (n/m),Authorizing GET /x,Checking authorization on GET /x using ...,Set SecurityContextHolder to anonymous SecurityContext, the context stored and retrieved. Nothing at the default level. Never logged at any level: passwords, tokens, DPoP proofs, session ids, CSRF tokens, the signed cookies,code,state,nonce, the PKCE verifier, client secrets,AuthorizationandCookievalues; the credentials of an authentication always show as[PROTECTED], and paths are logged without the query. Values that come from a client go throughLogFormatUtils(line breaks and control characters replaced).test/log_secrets_test.dartruns the heavy scenarios at trace and checks the whole log for every secret they use. - The unreadable-JWK debug line names the exception type only: its message could quote the key.
0.5.0 #
Breaking #
- Access tokens must have the
typJWT(in any case) or none, as Spring Security 7'sJwtTypeValidator.jwt(), in every default decoder and validator (JwtValidators.createDefault,createDefaultWithIssuer, thespring.security.oauth2.resourceserver.jwt.*decoder):at+jwt,logout+jwt,secevent+jwtanddpop+jwttokens signed with the same keys are refused. For a provider that types its access tokens as RFC 9068 says, start the validator withJwtTypeValidator(['at+jwt', 'JWT'], allowEmpty: true). Theoauth2Login()ID token decoder checks the same. - A token bound to a client certificate (
cnf.x5t#S256, RFC 8705) is refused with either scheme: the web starter does not hand client certificates to the security filters, so the binding cannot be checked (Spring refuses it without the certificate too). DefaultBearerTokenResolverwithallowUriQueryParameterreadsaccess_tokeninGETrequests only, as in Spring.- The CORS filter uses only the bean named
corsConfigurationSource, as Spring Security does (another name is ignored; a bean of another type under that name stops the start), andCorsFilter.configurationForreturns aFutureOr. It applies that bean's rules alone where the bean has some:@CrossOriginand theWebMvcConfigurermappings no longer widen them. Elsewhere it applies the rules of the handler the router would call, chosen with itsconsumes,producesandheaderstoo, as Spring'sHandlerMappingIntrospectorchooses it; a WebSocket handshake gets the bean's rules or none, no longer theWebMvcConfigurermappings. - The CORS filter answers a pre-flight that has no configuration with a 200 without CORS headers (was a 403), as Spring's
CorsFilter, and checks an actual request's own method: aHEADorDELETEthe rules do not list is a 403 before the security checks. - Only a login makes a session. Before it, the CSRF token is the
XSRF-TOKENcookie (CookieCsrfTokenRepository,HttpOnly,SameSite=Lax), the page to come back to is the signedREDIRECT_URIcookie (CookieRequestCache, Spring's) and the OAuth 2.0 authorization request ofoauth2Login()the signedOAUTH2_AUTHORIZATION_REQUESTcookie (CookieOAuth2AuthorizationRequestRepository), so clients that are not logged in cannot fill the session store. Spring Security keeps the three in the session;HttpSessionCsrfTokenRepository,HttpSessionRequestCacheandHttpSessionOAuth2AuthorizationRequestRepositorycan still be set. The cookies are signed byCookieSignerwithspring.security.cookie.secret(32 characters or more, the same on every instance), else with a random key of the process. Aresponse_mode=form_postlogin needs HTTPS (its cookie isSameSite=None; Secure). The CSRF token's header is nowX-XSRF-TOKEN(the cookie repository's, as in Spring; it wasX-CSRF-TOKEN); pages that take the name from the token (CsrfToken.headerName) need no change. RequestCache.removeRequesttakes the response too, as in Spring.- A login refused because too many password checks run and wait (
PasswordChecksBusyException,spring.security.password-checks.*) is answered503withRetry-After: 1, never as a failed login (no event, no challenge); a warning is logged at most once a minute. The chain's own provider uses thePasswordCheckLimiterbean. - Each user holds at most 10 sessions by default: a new login ends the user's least recently used one, so one account cannot fill the session store by logging in again and again.
sessionManagement((s) => s.maximumSessions(n))orspring.security.session.maximum-sessionschanges it (-1: no limit, Spring's default),.maxSessionsPreventsLogin(true)orspring.security.session.max-sessions-prevents-login=truerefuses the new login instead (SessionAuthenticationException); the properties are not in Spring Boot, apply only to chains with sessions (form login,oauth2Login()), and a chain's own setting wins. Spring'sSessionRegistry,SessionRegistryImpl(over the session repository: it holds ids only and asks the repository which live),SessionInformation,ConcurrentSessionControlAuthenticationStrategyandRegisterSessionAuthenticationStrategy. Users are told apart by name and by where the login came from. - DPoP: a proof's
jtiis kept untiliat+ clock skew + 5 seconds, so aDPoPProofJtiCachegets anexpiresAt5 seconds later, and must refuse a recorded id until it drops it, whatever its expiry says.
Changes #
- With
oauth2ResourceServer(), a request that carries a token in a header (Authorization: Bearer, orDPoPwith a proof) is exempt from CSRF, as Spring'sregisterDefaultCsrfOverride(which exemptsBeareronly): POST, PUT and DELETE API calls got a 403. A token in theaccess_tokenquery never exempts a request, and the chain's logout and login URLs keep their CSRF check (Spring exempts them). - DPoP: the proof's key is compared with the token's
cnf.jktbefore itsjtiis recorded, so proofs of made-up keys cannot fill the replay cache; a token withoutcnf.jktis refused before the proof is read. - DPoP: a proof can no longer be replayed at exactly
iat+ clock skew. - A DPoP-bound token sent as
Bearerpublishes one failure event, never a success first (UnboundBearerTokenAuthenticationProvider). - A failed fetch of the JWK Set or of the issuer's metadata is made again 30 seconds later at the earliest, never once per token.
- The key cache's lifetime, the refetch pause and the DPoP replay cache's purges are measured on a monotonic clock, so a wall clock set back stretches none of them.
JwtTypeValidator, Spring's validator of thetypheader.StrictHttpFirewallrefuses.and..segments with path parameters (..;x) also withallowSemicolon.oauth2Login(): a callback with another method thanGETor a formPOST(HEAD,PUT, ...) fails withinvalid_requestand leaves the login in progress alone.
0.4.3 #
JwtDecoders.fromIssuerLocationfinds the issuer's metadata with the OAuth2 client's discovery (ClientRegistrations.configurationForIssuerLocation): the same locations and issuer check. A location the fetcher cannot read (a 404 oftransportJwkFetcherincluded) now moves to the next, so the RFC 8414 metadata is found behind a missing OpenID Connect document.oauth2Login()is in the differential test against Spring Security 7.1.oauth2Login(): single sign-on with OAuth 2.0 and OpenID Connect providers (Spring Security'sOAuth2LoginConfigurer,OAuth2AuthorizationRequestRedirectFilter,OAuth2LoginAuthenticationFilter,OidcAuthorizationCodeAuthenticationProvider,HttpSessionOAuth2AuthorizationRequestRepository, the authorized client repositories,OidcClientInitiatedLogoutSuccessHandler); ID token signatures checked with the provider's JWK Set (OidcIdTokenDecoderFactory, also theoidcIdTokenDecoderbean); the default chain logs browsers in through thespring.security.oauth2.client.*registrations. The starter depends on and re-exportsspring_boot_starter_oauth2_client, whoseOAuth2Error,OAuth2AuthenticationException,OAuth2TokenValidator,OAuth2TokenValidatorResultandDelegatingOAuth2TokenValidatorreplace the starter's own (same signatures).defaultSuccessUrl, failure and logout URLs may be absolute (http://localhost:5050/).transportJwkFetcher.
0.4.2 #
- Docs (#9)
0.4.1 #
- feat: guides replace the examples; optional parameters from Dart nullability; coloured logs
- feat: guides replace the examples; optional parameters from Dart nullability; coloured logs
0.4.0 #
- Initial version: Spring Security for
spring_boot_starter_web, secure by default like Spring Boot (every request needs a login; form login for browsers, HTTP Basic for other clients; one user fromspring.security.user.*or a generated password; CSRF, security headers, logout).SecurityFilterChainbeans built withHttpSecurity(authorizeHttpRequestson the router's path patterns, a request no rule matches is denied;httpBasic,formLogin,oauth2ResourceServer,csrf,cors,headers,sessionManagement,exceptionHandling,logout,securityMatcher),FilterChainProxywith aStrictHttpFirewall, sessions with a new id at login, JWT resource servers (RS, PS, ES and HS algorithms on Bouncy Castle's Dart port, JWK sets with key rotation, issuer discovery,spring.security.oauth2.resourceserver.jwt.*), errors asProblemDetailwith Spring's challenges,@AuthenticationPrincipaland@CurrentSecurityContextarguments. Tests:user(),jwt(),csrf(),httpBasic(),anonymous()forMockMvc. Compared with Spring Security 7.1 request by request; the differences are listed in the README.