You do not need such a complicated configuration. Add @EnableOAuth2Sso to your MainConfiguration and set the appropriate application properties.
Here is what I did to use Facebook as an authorization server.
a) Remove clientId and authServer from UserServiceImpl . Otherwise, you will have to configure an authorization server, which is not needed.
b) Remove AuthorizationServerConfiguration .
c) Add @EnableWebSecurity and @EnableOAuth2Sso to MainConfiguration .
d) Change MainConfiguration::configure to
http .logout().logoutSuccessUrl("/").permitAll().and() .authorizeRequests().antMatchers("/", "/login", "/home.html").permitAll() .anyRequest().authenticated() .and().csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
e) Remove everything else except the nested AuthenticationSecurity class from MainConfiguration .
f) Change ResourceServerConfiguration::configure(HttpSecurity) to
http.antMatcher("/api/**").authorizeRequests().anyRequest().authenticated();
f) Remove the tokenStore attribute and the ResourceServerConfiguration::configure(ResourceServerSecurityConfigurer) method from the ResourceServerConfiguration .
g) Remove the security and facebook configuration block from application.yml . Add this one instead
security: oauth2: client: client-id: <CLIENT_ID> token-name: oauth_token authentication-scheme: query client-authentication-scheme: form access-token-uri: https://graph.facebook.com/oauth/access_token user-authorization-uri: https://www.facebook.com/dialog/oauth resource: user-info-uri: https://graph.facebook.com/me client-id: <CLIENT_ID> client-secret: <CLIENT_SECRET> token-type: code
h) In index.html change <a href="#/login">login</a> to <a href="/login">login</a> . i) Replace the contents of hello.js with one .
But I would like to have a traditional username and password login (log in directly, rather than showing the login page).
I would never use a site that requires my credentials without redirecting me to the source! I donβt know you, and you are considered a phishing site under suspicion. You must really reconsider your decision.
Btw, I created a migration request with these changes.