add public swagger ui
This commit is contained in:
@@ -77,6 +77,11 @@ public class SecurityConfig {
|
||||
.authenticationEntryPoint(bearerAuthenticationEntryPoint))
|
||||
.authorizeHttpRequests(authorize -> authorize
|
||||
.requestMatchers(HttpMethod.GET, "/health/**").permitAll()
|
||||
.requestMatchers(
|
||||
"/swagger-ui.html",
|
||||
"/swagger-ui/**",
|
||||
"/v3/api-docs/**"
|
||||
).permitAll()
|
||||
.requestMatchers(HttpMethod.POST, "/api/v1/users").permitAll()
|
||||
.anyRequest().authenticated())
|
||||
.addFilterBefore(apiAuthenticationFilter, AnonymousAuthenticationFilter.class);
|
||||
|
||||
@@ -120,6 +120,10 @@ public class ApiAuthenticationFilter extends OncePerRequestFilter {
|
||||
private boolean isPublicRequest(HttpServletRequest request) {
|
||||
String path = request.getRequestURI();
|
||||
return path.startsWith("/health/")
|
||||
|| path.equals("/swagger-ui.html")
|
||||
|| path.startsWith("/swagger-ui/")
|
||||
|| path.equals("/v3/api-docs")
|
||||
|| path.startsWith("/v3/api-docs/")
|
||||
|| (HttpMethod.POST.matches(request.getMethod())
|
||||
&& "/api/v1/users".equals(path));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user