I'm migrating to the latest spring security. My current project uses the deprecated EnableOAuth2Sso configuration with the following config. Whenever I go to the /login page of my app, it will automatically redirect to the URLs specified below (the SSO site).
security.oauth2.client.accessTokenUri=http://localhost:8081/oauth/token
security.oauth2.client.userAuthorizationUri=http://localhost:8081/oauth/authorize
security.oauth2.resource.userInfoUri=http://localhost:8081/user
With the latest spring security 6, using the oauth2Login
, it seems like now spring wants me to define a list of client registrations. I have something like this
spring.security.oauth2.client.registration.myclient.client-id=...
spring.security.oauth2.client.registration.myclient.client-secret=...
spring.security.oauth2.client.registration.myclient.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.myclient.redirect-uri={baseUrl}/login/oauth2/code/myclient
spring.security.oauth2.client.provider.myclient.authorization-uri=http://localhost:8081/oauth/authorize
spring.security.oauth2.client.provider.myclient.token-uri=http://localhost:8081/oauth/token
spring.security.oauth2.client.provider.myclient.user-info-uri=http://localhost:8081/user
spring.security.oauth2.client.provider.myclient.userNameAttribute=name
It seems like I can set multiple oauth clients in my app. However, the annoying thing is that if I go to the /login URL, I'm seeing a login page provided by spring with my defined oauth client as the single option. My question is that how can I get this to the previous behavior, to not show this page and just redirect me to the SSO site for login?
Easy one: you have the frontend redirect the user to the URL pointed by the link standing for the login option you are interested in (probably tools
in your case) instead of the login screen (something like http://localhost:8080/oauth2/authorization/tools
).