I am looking to customize my oauth2 login page. I am using Spring cloud Gateway so this is Spring Security Webflux. This should be fairly straightforward but I cannot figure out a way to do it with Webflux security. Stuff I have tried :
- I have tried using loginPage() as suggested in How Can I Customize Login Page for Oauth2 in Spring Webflux? but as the O.P. posted there, this does not compile in the webflux world.
- I have tried putting in a controller at /login and have it direct to my custom page but the controller is not hit. My SecurityConfig :
@Bean
public SecurityWebFilterChain configure(ServerHttpSecurity http) throws Exception {
return http
.csrf().disable().authorizeExchange()
.pathMatchers(HttpMethod.GET,"/oauth2login",
"*/*.js", "/*.json", "/*.ico", "/login").permitAll()
.pathMatchers("/api/","/api/**").authenticated()
.and().oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::jwt)
.authorizeExchange().anyExchange().authenticated()
.and().securityContextRepository(new WebSessionServerSecurityContextRepository())
.oauth2Login()
.and().build();
}
What am I doing wrong here?