Let me shortly describe what problem i am facing right now.
I have configured spring security for webflux application, and i am getting login form prompted, when i try to access the route that doesn't require authentication. The route is /swagger-ui/ and it should get opened without any login forms or whatever.
Below is the code i have within the SecurityWebFilterChain
@Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
//@formatter:off
return http
.formLogin().disable()
.httpBasic().disable()
.authenticationManager(authenticationManager)
.securityContextRepository(securityContextRepository)
.authorizeExchange()
.pathMatchers(HttpMethod.OPTIONS).permitAll()
.pathMatchers("/v2/api-docs", "/v3/api-docs", "/configuration/ui", "/swagger-resources",
"/configuration/security", "/swagger-ui/", "/swagger-ui",
"/webjars/**", "/swagger-resources/configuration/ui",
"/swagger-resources/configuration/security").permitAll() // Allowed routes for swagger
.pathMatchers("/api/auth", "/api/auth/**").permitAll() // Allowed routes for auth
.and()
.authorizeExchange()
.anyExchange()
.authenticated() // All other routes require authentication
.and()
.csrf().disable()
.headers()
.hsts()
.includeSubdomains(true)
.maxAge(Duration.ofSeconds(31536000))
.and()
.frameOptions().mode(XFrameOptionsServerHttpHeadersWriter.Mode.SAMEORIGIN)
.and()
.build();
//@formatter:on
}
}
If anyone has any suggestions, please let me know, i will appreciate it. Here is the picture what i got in the browser.