Our app is currently set up with OAuth OpenID connect authentication with an external (third-party) server. The requirement is to use user details service that loads the user from LDAP (along with the authorities/roles) to complete the authentication. So authentication.getPrincipal()
should be returning the custom UserDetails object we use that gets generated by querying LDAP using the username obtained from the Open ID authentication.
I have tried the following:
- Followed Similar Issue but it seems like in the answer it's setting up the server-side and it doesn't work either
- Tried adding custom UserDetailsService in WebSecurityConfig
where myCustomUserDetailsService() handles the call to LDAP and fetches the user details info, including the authorities.@Configuration public class OAuth2Config extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.oauth2Login().and().userDetailsService(myCustomUserDetailsService()); } }
I'm not too familiar with the spring oauth2 framework, correct me if I'm wrong: I'm guessing I need to implement my own user info endpoint to make a call to LDAP, and not the user info endpoint provided to me by the OpenID service?