Skip to content

Commit

Permalink
fix : 권한 설정 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
dltjdgh0428 committed Mar 28, 2024
1 parent 06f31f1 commit 351537e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/main/java/com/book_everywhere/auth/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ public SecurityFilterChain filterChain(HttpSecurity http, HandlerMappingIntrospe
.formLogin(AbstractHttpConfigurer::disable)
.httpBasic(AbstractHttpConfigurer::disable)
.authorizeHttpRequests((authorizeRequests) -> authorizeRequests
.requestMatchers(new MvcRequestMatcher(introspector, "/")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/health")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/env")).permitAll()
// .requestMatchers(new MvcRequestMatcher(introspector, "/api/**")).hasAuthority("ROLE_MEMBER")
.requestMatchers(new MvcRequestMatcher(introspector, "/**")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/api/**")).permitAll()
.anyRequest().authenticated()
.requestMatchers(new MvcRequestMatcher(introspector, "/")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/health")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/env")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/test/**")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/swagger-ui/**")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/api/review")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/api/map")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/api/tags")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/api/data/**")).permitAll()
.requestMatchers(new MvcRequestMatcher(introspector, "/api/**")).hasRole("ROLE_MEMBER")
.anyRequest().authenticated()
)
.oauth2Login(oauth2Login ->
oauth2Login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic
Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);

return new CustomOAuth2User(attributes,Role.ROLE_MEMBER);
return new CustomOAuth2User(attributes,user.getRole());
}

/**
Expand Down

0 comments on commit 351537e

Please sign in to comment.