Add Spring Authorization Server project: OAuth2/OIDC provider, client and resource server
Three modules on Spring Boot 4.1.1 with Spring Authorization Server 7.1.1: the provider
itself, a relying party, and an API that trusts its tokens. Client registration, PKCE,
a custom consent page and token customisation, with profiles that make each failure
reproducible.
Every claim is backed by captured output in docs/output/as-*.txt, regenerated by
authorization-server/scripts/run-all.sh. Notable findings, verified against the jars:
- OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(HttpSecurity) was deleted
in 7.0, and both configuration classes moved into spring-security-config
- ClientSettings.requireProofKey flipped from false to true, on the authorization server
(1.5.8 -> 7.1.1) and on the OAuth2 client (6.5.1 -> 7.1.1)
- requireProofKey(false) does not make PKCE optional for a public client; the code
verifier is that client's only authentication at the token endpoint
- MediaTypeRequestMatcher(TEXT_HTML) matches Accept: */*, so the token endpoint answers
API callers with 302 -> /login unless setIgnoredMediaTypes(ALL) is called
Also renames the repository to spring-auth-demo and cross-links the new chapter set from
the existing documentation.
This commit is contained in:
15
authorization-server/tools/ClientPkceDefault.java
Normal file
15
authorization-server/tools/ClientPkceDefault.java
Normal file
@@ -0,0 +1,15 @@
|
||||
import org.springframework.security.oauth2.client.registration.ClientRegistration;
|
||||
|
||||
/**
|
||||
* Prints whether a Spring OAuth2 <i>client</i> registration requires PKCE out of the box.
|
||||
* Run against spring-security-oauth2-client 6.5.1 and 7.1.1, it shows the default flipping
|
||||
* in the same release that flipped it on the authorization server.
|
||||
*/
|
||||
public class ClientPkceDefault {
|
||||
public static void main(String[] args) {
|
||||
ClientRegistration.ClientSettings cs =
|
||||
ClientRegistration.ClientSettings.builder().build();
|
||||
System.out.println("ClientRegistration.ClientSettings.requireProofKey = "
|
||||
+ cs.isRequireProofKey());
|
||||
}
|
||||
}
|
||||
20
authorization-server/tools/SettingsDefaults.java
Normal file
20
authorization-server/tools/SettingsDefaults.java
Normal file
@@ -0,0 +1,20 @@
|
||||
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
|
||||
import org.springframework.security.oauth2.server.authorization.settings.TokenSettings;
|
||||
/**
|
||||
* Prints the out-of-the-box values of ClientSettings and TokenSettings. Run against two
|
||||
* different Spring Authorization Server jars, it is the shortest proof that a default
|
||||
* changed. scripts/settings-defaults.sh does exactly that for 1.5.8 and 7.1.1.
|
||||
*/
|
||||
public class SettingsDefaults {
|
||||
public static void main(String[] a) {
|
||||
ClientSettings cs = ClientSettings.builder().build();
|
||||
TokenSettings ts = TokenSettings.builder().build();
|
||||
System.out.println("requireProofKey = " + cs.isRequireProofKey());
|
||||
System.out.println("requireAuthorizationConsent= " + cs.isRequireAuthorizationConsent());
|
||||
System.out.println("accessTokenTimeToLive = " + ts.getAccessTokenTimeToLive());
|
||||
System.out.println("accessTokenFormat = " + ts.getAccessTokenFormat().getValue());
|
||||
System.out.println("refreshTokenTimeToLive = " + ts.getRefreshTokenTimeToLive());
|
||||
System.out.println("reuseRefreshTokens = " + ts.isReuseRefreshTokens());
|
||||
System.out.println("authorizationCodeTTL = " + ts.getAuthorizationCodeTimeToLive());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user