Skip to content

Commit

Permalink
[#42] Feat: /admin/** 으로 들어오는 요청은 ADMIN 만 접근 가능하도록 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
SY2on committed Jan 18, 2024
1 parent 9d719de commit 36b0702
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class SecurityConfig {
"/inquiries/list"
};

private static final String[] ADMIN_PAGE_LIST = {
"/admin/**"
};

private final JwtTokenProvider jwtTokenProvider;
private final JwtAccessDeniedHandler jwtAccessDeniedHandler;
private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
Expand All @@ -44,6 +48,7 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.authorizeHttpRequests(authorize -> authorize
.shouldFilterAllDispatcherTypes(false)
.requestMatchers(AUTH_WHITELIST).permitAll()
.requestMatchers(ADMIN_PAGE_LIST).hasRole("ADMIN")
.anyRequest().authenticated()
.and().addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider),
UsernamePasswordAuthenticationFilter.class))
Expand Down

0 comments on commit 36b0702

Please sign in to comment.