Closed
Description
Describe the bug
Both the SpringOpaqueTokenIntrospector
and NimbusOpaqueTokenIntrospector
use the clientId
and clientSecret
to authenticate the calls to the authorization server.
This is done via basic authentication added using a BasicAuthenticationInterceptor
. This does not perform any URL encoding.
This issue was addressed in #9610 for the token granting client, but persists for the introspection client.
The workaround at the moment is to manually encode the secret when instantiating the introspector.
To Reproduce
- Set up a Spring Authorization Server with a client with a secret such as
badSecret%
- Configure a
SpringOpaqueTokenIntrospector
orNimbusOpaqueTokenIntrospector
to use that client - Attempt to use the introspector with the Spring Authorization Server.
- See the server respond with a 400
invalid_request
error and see the following cause in the logs:
Caused by: java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern
at java.base/java.net.URLDecoder.decode(URLDecoder.java:230) ~[?:?]
at java.base/java.net.URLDecoder.decode(URLDecoder.java:147) ~[?:?]
at org.springframework.security.oauth2.server.authorization.web.authentication.ClientSecretBasicAuthenticationConverter.convert(ClientSecretBasicAuthenticationConverter.java:85) ~[spring-security-oauth2-authorization-server-1.3.2.jar!/:1.3.2]
... 103 more
Expected behavior
The token introspector should URL encode the secret.