Skip to content

Commit

Permalink
change permitted routes to non auth routes
Browse files Browse the repository at this point in the history
  • Loading branch information
yesyash committed Jul 26, 2024
1 parent fd78cc2 commit 53173b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class SecurityConfig {
private final AuthEntryPoint authEntryPoint;
private final CustomAccessDeniedHandler accessDeniedHandler;

public static final List<String> PERMITTED_PATHS = List.of("/v1/health", "/v1/auth");
public static final List<String> NON_AUTH_ROUTES = List.of("/v1/health", "/v1/auth");

public SecurityConfig(
AuthEntryPoint authEntryPoint, CustomAccessDeniedHandler accessDeniedHandler) {
Expand All @@ -44,7 +44,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
httpSecurityCorsConfigurer.configurationSource(corsConfigurationSource()))
.authorizeHttpRequests(
auth -> {
PERMITTED_PATHS.forEach(path -> auth.requestMatchers(path + "/**").permitAll());
NON_AUTH_ROUTES.forEach(path -> auth.requestMatchers(path + "/**").permitAll());
auth.requestMatchers(HttpMethod.GET, "/v1/**")
.hasAnyAuthority(UserRoleEnum.getAllRoles()) // give read-only access to all
.requestMatchers("/v1/**")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void doFilterInternal(
@Override
protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
String path = request.getRequestURI();
return SecurityConfig.PERMITTED_PATHS.stream().anyMatch(path::startsWith);
return SecurityConfig.NON_AUTH_ROUTES.stream().anyMatch(path::startsWith);
}

public String getJWTFromRequest(HttpServletRequest request) {
Expand Down

0 comments on commit 53173b7

Please sign in to comment.