Differences from Spring
spring_boot_starter_oauth2_client follows Spring Security's spring-security-oauth2-client and -oauth2-core, with Spring Boot's auto-configuration and Spring Cloud OpenFeign's OAuth2 interceptor: the same properties, types and rules. This page lists where it does not, and why.
Why
The package must run in Flutter apps and browsers as well as on servers, so it cannot bring a web server, and every network call is asynchronous. A few behaviours are safer than Spring's defaults, and Sign in with Apple and client-side DPoP are additions.
Example
# The same keys as Spring Boot:
spring.security.oauth2.client.registration.keycloak.client-id=neon-web
spring.security.oauth2.client.provider.keycloak.issuer-uri=https://login.example.com/realms/neon
# Spring Cloud's Feign key, without cloud.openfeign:
spring.feign.oauth2.enabled=true
Packaging and properties
| Spring | Here | Why |
|---|---|---|
spring-boot-starter-oauth2-client brings web security and oauth2Login() |
the client only; a server lists spring_boot_starter_security, an app spring_boot_starter_flutter_security |
It must run where there is no dart:io server. |
spring.cloud.openfeign.oauth2.* |
spring.feign.oauth2.*; the old names stop the start |
Spring Cloud means nothing in Dart. |
| Issuer discovery at startup | at the first use; a failure is retried at a use 10 seconds later or more | An app starts while the provider is unreachable. |
Plain http:// URIs accepted silently |
a warning once per registration outside loopback | Tokens over http:// can be read and changed. |
Behaviour
ClientRegistrationRepository.findByRegistrationId, the authorized client service, the manager, the token clients and the user services returnFutures.- An
authorization_coderegistration without a client secret and withoutclient-authentication-methodis a public client (none), even for a common provider that saysclient_secret_basic. - PKCE is on for every
authorization_coderegistration, confidential clients included, as in Spring Security 7.1. - The token response clients run on the
HttpTransportofspring_web_dart(Spring 7'sRestClient*TokenResponseClient). AuthorizedClientServiceOAuth2AuthorizedClientManagerneeds its provider (Spring defaults to client credentials alone), runs one authorization at a time per registration and principal, and removes the stored client afterinvalid_grantorinvalid_token.OAuth2AuthorizedClientkeeps the ID token: the refresh checks a new one against it, and a logout without a session needs it asid_token_hint.- A refreshed ID token is checked as OpenID Connect Core §12.2 says, as Spring Security 6.3's
OidcAuthorizedClientRefreshedEventListenerdoes. - The token clients, the user services and an
OidcIdTokenDecoderare beans (Spring creates them inside its configurers). TokenEndpointOidcIdTokenDecodertrusts TLS instead of checking the signature; on a server the security starter's bean checks it, as Spring does.- The issuer metadata lookup is public (
ClientRegistrations.configurationForIssuerLocation); Spring's is internal.
Additions
- Sign in with Apple:
CommonOAuth2Provider.apple,response-mode(ResponseMode),OAuth2AuthorizationResponse.fromParameters,OAuth2ClientSecretResolver,JwtClientSecretandJwtClientSecretResolver(client-secret-jwt.*),native-sign-in,JwkSetOidcIdTokenDecoder. The code token request leavesredirect_uriout when the authorization request had none. - Client-side DPoP: the
dpopproperty,DPoPKey,SoftwareDPoPKey,DPoPProofBuilder,ECDSA.transcodeSignatureToConcat, and the DPoP parts of the token clients, user services and Feign interceptor. OAuth2AccessTokenErrorDecoder: a 401 marks the Feign token expired.OAuth2AccessTokenHeaders: token headers for requests the starter does not make.
Not supported yet
oauth2Login()itself (the security starter's).private_key_jwtandclient_secret_jwt(client_assertion),tls_client_auth.- The password, device, token exchange (RFC 8693) and JWT bearer (RFC 7523) grants.
@ClientRegistrationIdon HTTP clients.- A database-backed authorized client service.
- A WebCrypto DPoP key on the web, and the retry of a Feign call answered
use_dpop_nonce.