-
Notifications
You must be signed in to change notification settings - Fork 6k
Spring Security OAuth2 - Unable to start Spring Boot App if configured with multiple external Auth Servers and failed to connect to one of them #11397
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
@mohamadassaad thanks for reaching out, and sorry for the delay on responding to this. I was out on break and then very busy when I returned. The class used by Spring Boot to perform this discovery is
Most of the time, using the discovery mechanism is a convenience, so I strongly recommend you try the above workaround as it will most likely work for you. Sadly, we may not have a better solution for quite some time until 5.8 and 6.0 are released. I'm going to close this as a duplicate of #8882. |
Hello @sjohnr , I am having the same issue with the latest version of spring security and keycloak (I don't think that it's relevant). I tried to add the The final problem that I am dealing with now is that the logout doesn't work. Normally the Any ideas? |
@ThanKarab, thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. We prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it). |
Thanks for the quick reply @sjohnr , any progress or walkthrough on how to use |
@ThanKarab, please see this comment. |
I managed to find a workaround because since it's for development purposes I know when the identity provider server will not exist. I am using the authentication enabled property with a conditional bean that creates a dummy
|
Summary
Fail to start a Spring Boot Application configured with oauth2Login() and with multiple external Authorization Servers if the connection to one them failed at startup
Actual Behavior
[ (self-tuning)'] o.s.boot.SpringApplication : Application run failed
...........
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of
...........
Caused by: java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of ""
at org.springframework.security.oauth2.client.registration.ClientRegistrations.getBuilder(ClientRegistrations.java:220) ~[spring-security-oauth2-client-5.6.1.jar:5.6.1]
at org.springframework.security.oauth2.client.registration.ClientRegistrations.fromIssuerLocation(ClientRegistrations.java:144) ~[spring-security-oauth2-client-5.6.1.jar:5.6.1]
at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.getBuilderFromIssuerIfPossible(OAuth2ClientPropertiesRegistrationAdapter.java:83) ~[spring-boot-autoconfigure-2.4.5.jar:2.6.3]
...........
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "< azure ad issuer >/.well-known/openid-configuration": sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785) ~[spring-web-5.3.6.jar:5.3.6]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:670) ~[spring-web-5.3.6.jar:5.3.6]
at org.springframework.security.oauth2.client.registration.ClientRegistrations.lambda$oidc$0(ClientRegistrations.java:155) ~[spring-security-oauth2-client-5.6.1.jar:5.6.1]
Expected Behavior
Successfully start the Spring Boot Application even if the connection to one of the External Authorization Server is not working.
Configuration
application.properties
`#First Authorization Server
spring.security.oauth2.client.registration.my_okta_account.client-id=
spring.security.oauth2.client.registration.my_okta_account.client-secret=
spring.security.oauth2.client.provider.my_okta_account.issuer-uri=
#Second Authorization Server
spring.security.oauth2.client.registration.my_azure_ad.client-id=
spring.security.oauth2.client.registration.my_azure_ad.client-secret=
spring.security.oauth2.client.provider.my_azure_ad.issuer-uri=`
Version
5.6
The text was updated successfully, but these errors were encountered: