1
0
Files
spring-auth-demo/authorization-server/scripts/pkce-applier.sh
Ankur Mhatre e9381dc5be 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.
2026-08-24 08:20:38 +05:30

33 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Why a confidential Spring OAuth2 client does not send PKCE, straight from the bytecode
# of DefaultOAuth2AuthorizationRequestResolver rather than from documentation.
set -u
cd "$(dirname "$0")/.."
OUT=../docs/output/as-pkce-applier.txt
mkdir -p ../docs/output
mvn -B -q -pl oidc-client dependency:build-classpath \
-Dmdep.outputFile=/tmp/cl-cp.txt -DincludeScope=compile >/dev/null 2>&1
JAR=$(tr ':' '\n' < /tmp/cl-cp.txt | grep 'spring-security-oauth2-client-' | head -1)
WORK=$(mktemp -d); trap 'rm -rf "$WORK"' EXIT
(cd "$WORK" && unzip -o -q "$JAR" 'org/springframework/security/oauth2/client/web/DefaultOAuth2AuthorizationRequestResolver*')
{
echo "# From $(basename "$JAR")"
echo "#"
echo "# The resolver applies its default PKCE customizer only when the registration's"
echo "# client authentication method is NONE - that is, only for public clients."
echo "# A registration that has a client secret gets no code_challenge."
echo
javap -p -c -cp "$WORK" \
org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizationRequestResolver \
2>/dev/null \
| grep -E 'ClientAuthenticationMethod.NONE|DEFAULT_PKCE_APPLIER|withPkce' \
| sed 's/^ *//' | head -8
echo
echo "# The fields and the opt-in setter:"
javap -p -cp "$WORK" \
org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizationRequestResolver \
2>/dev/null \
| grep -E 'DEFAULT_PKCE_APPLIER|setAuthorizationRequestCustomizer' | sed 's/^ *//'
} > "$OUT" 2>&1
cat "$OUT"