Skip to content

Commit

Permalink
Merge pull request #239 from kakao-tech-campus-2nd-step3/docs/#185-re…
Browse files Browse the repository at this point in the history
…adme

[chore] 최종 검사용 admin permitAll()
  • Loading branch information
BaeJunH0 authored Nov 15, 2024
2 parents cd22e37 + a4b7362 commit a9d4707
Showing 1 changed file with 42 additions and 41 deletions.
83 changes: 42 additions & 41 deletions src/main/java/team7/inplace/security/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,53 +35,54 @@ public class SecurityConfig {

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http)
throws Exception {
throws Exception {

//http 설정
http.csrf(AbstractHttpConfigurer::disable)
.formLogin(AbstractHttpConfigurer::disable)
.httpBasic(AbstractHttpConfigurer::disable)
.formLogin(AbstractHttpConfigurer::disable)
.httpBasic(AbstractHttpConfigurer::disable)

//authentication Service, Handler 설정
.oauth2Login((oauth2) -> oauth2
.userInfoEndpoint((userInfoEndPointConfig) -> userInfoEndPointConfig
.userService(customOauth2UserService)).successHandler(customSuccessHandler)
.failureHandler(customFailureHandler))
//authentication Service, Handler 설정
.oauth2Login((oauth2) -> oauth2
.userInfoEndpoint((userInfoEndPointConfig) -> userInfoEndPointConfig
.userService(customOauth2UserService)).successHandler(customSuccessHandler)
.failureHandler(customFailureHandler))

//authentication Filter 설정
.addFilterBefore(authorizationFilter,
UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(exceptionHandlingFilter, AuthorizationFilter.class)
//authentication Filter 설정
.addFilterBefore(authorizationFilter,
UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(exceptionHandlingFilter, AuthorizationFilter.class)

.exceptionHandling((auth) -> auth
.authenticationEntryPoint(loginAuthenticationEntryPoint)
.accessDeniedHandler(customAccessDeniedHandler))
//authentication 경로 설정
.authorizeHttpRequests((auth) -> auth
.requestMatchers("/admin/**", "/api/error-logs/**", "/cicd", "crawling/**")
.hasRole("ADMIN")
.requestMatchers("/users/**").authenticated()
.requestMatchers("/influencers/likes").authenticated()
.requestMatchers("/influencers/multiple/likes").authenticated()
.requestMatchers(HttpMethod.POST, "/influencers/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.PUT, "/influencers/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.DELETE, "/influencers/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.GET, "/influencers/**").permitAll()
.requestMatchers(HttpMethod.POST, "/places/**").authenticated()
.requestMatchers(HttpMethod.GET, "/places/**").permitAll()
.requestMatchers("/place-message/**").authenticated()
.requestMatchers("/reviews/**").authenticated()
.requestMatchers("/refresh-token").authenticated()
.requestMatchers("/videos", "videos/my").authenticated()
.requestMatchers("/videos/**").permitAll()
.requestMatchers(HttpMethod.DELETE, "/videos/{videoId}").authenticated()
.anyRequest().permitAll()
)
//cors 설정
.addFilter(corsFilter)
//session 설정
.sessionManagement((session) -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
.exceptionHandling((auth) -> auth
.authenticationEntryPoint(loginAuthenticationEntryPoint)
.accessDeniedHandler(customAccessDeniedHandler))
//authentication 경로 설정
.authorizeHttpRequests((auth) -> auth
.requestMatchers("/api/error-logs/**", "/cicd", "crawling/**")
.hasRole("ADMIN")
.requestMatchers("/admin/**").permitAll()
.requestMatchers("/users/**").authenticated()
.requestMatchers("/influencers/likes").authenticated()
.requestMatchers("/influencers/multiple/likes").authenticated()
.requestMatchers(HttpMethod.POST, "/influencers/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.PUT, "/influencers/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.DELETE, "/influencers/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.GET, "/influencers/**").permitAll()
.requestMatchers(HttpMethod.POST, "/places/**").authenticated()
.requestMatchers(HttpMethod.GET, "/places/**").permitAll()
.requestMatchers("/place-message/**").authenticated()
.requestMatchers("/reviews/**").authenticated()
.requestMatchers("/refresh-token").authenticated()
.requestMatchers("/videos", "videos/my").authenticated()
.requestMatchers("/videos/**").permitAll()
.requestMatchers(HttpMethod.DELETE, "/videos/{videoId}").authenticated()
.anyRequest().permitAll()
)
//cors 설정
.addFilter(corsFilter)
//session 설정
.sessionManagement((session) -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS));

return http.build();
}
Expand Down

0 comments on commit a9d4707

Please sign in to comment.