-
Notifications
You must be signed in to change notification settings - Fork 6.1k
JwtDecoders from issuer uri produces ClassCastException #9651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was testing latest Spring Boot snapshot version (2.5.0-SNAPSHOT) and I got the same above issue. Folllowing is the stacktrace:
|
Thanks for the report @tiborkoch. I was able to reproduce the same issue with the provided sample. The fix you suggested is correct. Would you be interested in submitting a PR for this fix? |
@tiborkoch I didnt have enough time to fix this issue, but if you can do it I share with you the old issue. |
Fixed in #9658 |
Is there a workaround until the fix is released? |
Hi, @RobertHeim, yes, you can create the @Bean
JwtDecoder jwtDecoder() {
String issuerUri = ...;
String jwkSetUri = ...;
OAuth2TokenValidator<Jwt> validator = JwtValidators.createDefaultWithIssuer(issuerUri);
NimbusJwtDecoder jwtDecoder = NimbusJwtDecoder.withJwtSetUri(jwkSetUri).build();
jwtDecoder.setJwtValidator(validator);
return jwtDecoder;
} |
Or, if you are a Spring Boot application, then you can instead do: spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: https://auth.example.org/issuer
jwk-set-uri: https://auth.example.org/jwks |
Thanks for the fast feedback. That works! |
Describe the bug
Using the latest Spring Boot snapshot version (2.5.0-SNAPSHOT) that has Spring Security 5.5.0-RC1 as dependency, a
ClassCastException
is thrown when creating aJwtDecoder
from an issuer uri.It can be fixed by using
instead of casting.
To Reproduce
Start the app in the provided repository.
Expected behavior
No errors on startup.
Sample
https://github.com/tiborkoch/spring-security-oauth2resourceserver
The text was updated successfully, but these errors were encountered: