SSO/Oauth login on same application, Login based on UrL

Viewed 140

I have spring MVC application and I am trying to register different SSO login on same application. For example if url is (admin.abc.com), It should login from microsoft SSO and if the url is abc.com it should redirect to google login. Here is my code but when I run the code both sso open with giving me the option to choose. Is there any way I can set sso login based on domain instead of select option.

  @Autowired
    ClientRegistrationRepository regRepository;

@Bean
    public ClientRegistrationRepository clientRegistrationRepository() {
        return new InMemoryClientRegistrationRepository(Arrays.asList(msClientRegistration(), googleSSOClientRegistration()));
    }

and the configuration for antmatcher is like this

@Override
    protected void configure(final HttpSecurity http)
        throws Exception {
        http.antMatcher("/**")
            .authorizeRequests()
            .antMatchers("/login.htm").authenticated()
            .antMatchers("/**")
            .permitAll().anyRequest()
            .authenticated().and().logout()
            .logoutSuccessHandler(oauthLogoutSuccessHandler())
            .invalidateHttpSession(true)
            .logoutUrl("/logout")
            .and().oauth2Login()
            .failureHandler(new CustomAuthenticationFailureHandler())
            .authorizationEndpoint()
            .authorizationRequestResolver(
                new CustomAuthorizationRequestResolver(regRepository, "/oauth2/authorization"))
            .and().tokenEndpoint()
            .accessTokenResponseClient(authorizationCodeTokenResponseClient())
            .and().and().headers()
            .frameOptions()
            .sameOrigin().and().csrf()
            .disable();
    }

How to add antMatcher configuration based on domain url? google sso for abc.com and admin.abc.com for microsoft login with OAuth2. Instead of having this I want to redirect base on url's

Instead of having this I want to redirect base on url's.. either Google login or Microsoft.

0 Answers
Related