Skip to content

Commit

Permalink
fix : UserLevelCheckInterceptor logic
Browse files Browse the repository at this point in the history
  • Loading branch information
woogym committed Jun 29, 2024
1 parent a0447fd commit 6e91465
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public boolean preHandle(@NonNull HttpServletRequest request,
@NonNull HttpServletResponse response,
@NonNull Object handler) {

HandlerMethod handlerMethod = (HandlerMethod) handler;
if (!(handler instanceof HandlerMethod handlerMethod)) {
return true;
}

UserLevelCheck userLevelCheck = handlerMethod.getMethodAnnotation(UserLevelCheck.class);

if (userLevelCheck == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.sessionManagement(c -> c.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.cors(c -> c.configurationSource(configurationSource()))
.logout(AbstractHttpConfigurer::disable)
.authorizeHttpRequests((authorizeHttpRequests) ->
authorizeHttpRequests
.requestMatchers("/api/v1/**", "swagger-ui/**", "v3/api-docs/**").permitAll()
.requestMatchers("/test").authenticated()
.requestMatchers("/api/v1/admin/**").hasRole("ADMIN") // 관리자만 해당 URL에 접근할 수 있음
.authorizeHttpRequests((authorizeHttpRequests) -> authorizeHttpRequests
.requestMatchers("/api/v1/**", "/swagger-ui/**", "v3/api-docs/**").permitAll()
.anyRequest().authenticated()
)
.exceptionHandling((exceptionHandling) -> exceptionHandling.authenticationEntryPoint(new CustomAuthenticationEntryPoint()))
Expand Down

0 comments on commit 6e91465

Please sign in to comment.