jwt icon indicating copy to clipboard operation
jwt copied to clipboard

SecurityConfig.java will not build with 3.5.5

Open DT3uscher opened this issue 4 months ago • 1 comments

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()
			)

DT3uscher avatar Aug 26 '25 18:08 DT3uscher

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.

DT3uscher avatar Aug 26 '25 18:08 DT3uscher