jwt
jwt copied to clipboard
SecurityConfig.java will not build with 3.5.5
SecurityFilterChain tokenSecurityFilterChain(HttpSecurity http) throws Exception { return http .requestMatcher(new AntPathRequestMatcher("/token")) <-- This isn't valid (The method requestMatcher(AntPathRequestMatcher) is undefined for the type HttpSecurity)
I replaced that line with the following and added the swagger endpoints as well. I also added a SwaggerConfig file to configure the Basic auth in swagger. Then you get the "Authorize" button in the Swagger UI
return http
.securityMatcher("/token/**", "/swagger-ui/**", "/v3/api-docs*/**")
.authorizeHttpRequests(auth -> auth
.requestMatchers("/token/**").permitAll()
.requestMatchers("/swagger-ui/**").permitAll()
.requestMatchers("/v3/api-docs*/**" ).permitAll()
)
The securityMatcher line is important. Otherwise, you get a build error because there are 2 SecurityFilterChains in play. It took me a while to figure that part out.