Stack Exchange
Spring security default Login page
I have set up spring security in my spring cloud gateway application. when I fire it up. It takes me to an HTML page where I have to choose preferred oauth 2.0 type.
My pom spring version 2.3.12
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-security</artifactId>
</dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>

application.yml
spring:
  profiles: default
  security:
    oauth2:
      resourceserver:
        jwt:
          issuer-uri: https://qa-abchc.cs195.force.com
      client:
        registration:
          sfdc:
            client-id: 3MVG9GnaLrwG9T5ZpEfaDCVDu7N4BibMIHajVSUG5F6epm
            scope: openid,email,phone,profile
            client-secret: fkdslfjklsdjflksjdflsj
            authorization-grant-type: authorization_code
            redirect-uri: http://localhost:7999/oauth2/callback/sfdc
          abc:
            client-id: OIDC_CLIENT
            scope: openid,email,phone,profile
            client-secret: dfjskldjflskfjls
            authorization-grant-type: authorization_code
            redirect-uri: http://localhost:7999/oauth2/callback/abc          
        provider:
          sfdc:
            authorization-uri: https://qa-abchc.cs195.force.com/abcidp/services/oauth2/authorize
            token-uri: https://qa-abchc.cs195.force.com/abcidp/services/oauth2/token 
          abc:
            authorization-uri: https://rrtrr.abc.com/fss/as/authorization.oauth2
            token-uri: https://rrtrr.abc.com/fss/as/token.oauth2

and
 
@Configuration
@EnableWebFluxSecurity
public class OAuth2WebSecurity {

    @Value("${spring.security.oauth2.client.provider.sfdc.issuer-uri}")
    String issuerUri;

    @Bean
    ReactiveJwtDecoder jwtDecoder() {
        return ReactiveJwtDecoders.fromOidcIssuerLocation(issuerUri);
    }

    @Bean
    public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http,
            ReactiveClientRegistrationRepository clientRegistrationRepository) {

                http.csrf().disable().authorizeExchange().pathMatchers("/favicon.ico", "/css/**", "/webjars/**",
                "/api/v1.0/applications/**", "/api/v1.0/users/**", "/oauth2/**", "/login/**", "/oauth2/callback/ge",
                "/*").permitAll().anyExchange().authenticated().and().oauth2Login().authorizationRequestResolver(
                        authorizationRequestResolver(clientRegistrationRepository)).and().oauth2ResourceServer(
                                oauth2 -> oauth2.authenticationManagerResolver(authenticationManagerResolver));
        return http.build();

    }

    @Bean
    public ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver(
            ReactiveClientRegistrationRepository clientRegistrationRepository) {
        return new DefaultServerOAuth2AuthorizationRequestResolver(clientRegistrationRepository,
                new PathPatternParserServerWebExchangeMatcher("/login/{registrationId}"));
    }

}

When I try to access it in the browser, it goes to http://localhost:8080/login which returns an HTML page where I get to select any one of the OAuth mentioned in the YAML file.
Now how do I disable this HTML and make it choose OAuth based on context path?
localhost:8080/login/abc --> go to abc auth server
localhost:8080/login/sfdc --> go to sfdc auth server
After authentication it should goto default rest controller or some filter class

@RestController
public class LoginController {

    @GetMapping("/oauth2/callback/ge")
    public String getLoginInfo(@AuthenticationPrincipal OidcUser principal) {
        System.out.println(principal.getAccessTokenHash());
        return "loginSuccess";
    }

    @GetMapping("/oauth2/callback/sfdc")
    public String getLoginSfdcInfo(@AuthenticationPrincipal OidcUser principal) {
        System.out.println(principal.getAccessTokenHash());
        return "loginSuccess";
    }

}


The login page is generated by Spring Security. You can disable it by specifying your own login page:
.exceptionHandling().authenticationEntryPoint(new RedirectServerAuthenticationEntryPoint("/my-custom-login-page"))

All this does is set up an authentication entry point that redirects to /my-custom-login-page. That may not be what you want, but it will disable the default login page. If you have no desired page or redirect that you want when an unauthenticated user makes a request, you don't have to perform a redirect. For example, this will return a 401 any time the user is not authenticated:
.exceptionHandling().authenticationEntryPoint(new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED))

In order to change the path of the authorization endpoint, you can change the request matching using the ServerOAuth2AuthorizationRequestResolver:
@Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http, ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver) {
    http
        // ...
        .oauth2Login().authorizationRequestResolver(authorizationRequestResolver);

    return http.build();
}

@Bean
public ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver(ReactiveClientRegistrationRepository clientRegistrationRepository) {
    return new DefaultServerOAuth2AuthorizationRequestResolver(clientRegistrationRepository,
            new PathPatternParserServerWebExchangeMatcher("/login/{registrationId}"));
}

This will allow /login/abc and /login/sfdc to go to abc and sfdc respectively based on your client registrations.
Lastly, the callback is handled by Spring Security. So your controller won't be invoked. You will want to define an authentication success handler:
.oauth2Login().authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/my-login-success-page"))

You can read more about this on the OAuth2 WebFlux section of the docs.

.oauth2Login().authorizationEndpoint(). is not longer available. its deprecated.
.oauth2Login().loginPage("/my-custom-login-page") is deprecated as well.

What version of Spring Security are you using? I am on the main branch of Spring Security and it is most certainly not deprecated.

Apologies, I now realize you are using WebFlux and the configuration is different.

@VIJ I have updated the answer for webflux.

I getting redirected to
http://localhost:7999/oauth2/callback/abc?code=4Kw2jLcdAc03yh1oWIB710fjPKq_Ioi64uYAAAAB&state=oHvCNl_nTLcuXcQ6t0Vy9UOaeJCrr0YdEPZo_95n_iM%3D
This has location url as /login.
Which eventually it again takes to default login page

All i want is after login it should goto my controller. and not to any login.html

The callback is handled by Spring Security. So your controller won't be invoked. You will want to define an authentication success handler: .oauth2Login().authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/my-login-success-page")).
