-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: (BRD-74) 스프링 시큐리티 필터체인 기본 설정
- Loading branch information
Showing
3 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ternal-security/src/main/kotlin/com/ttasjwi/board/system/core/config/FilterChainConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.ttasjwi.board.system.core.config | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.core.annotation.Order | ||
import org.springframework.http.HttpMethod | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity | ||
import org.springframework.security.web.SecurityFilterChain | ||
import org.springframework.security.config.annotation.web.invoke | ||
import org.springframework.security.config.http.SessionCreationPolicy | ||
import org.springframework.security.web.savedrequest.NullRequestCache | ||
|
||
@Configuration | ||
class FilterChainConfig { | ||
|
||
@Bean | ||
@Order(0) | ||
fun apiSecurityFilterChain(http: HttpSecurity): SecurityFilterChain { | ||
http { | ||
securityMatcher("/api/**") | ||
authorizeHttpRequests { | ||
authorize(HttpMethod.GET, "/api/v1/deploy/health-check", permitAll) | ||
|
||
authorize(HttpMethod.GET, "/api/v1/members/email-available", permitAll) | ||
authorize(HttpMethod.GET, "/api/v1/members/username-available", permitAll) | ||
authorize(HttpMethod.GET, "/api/v1/members/nickname-available", permitAll) | ||
|
||
authorize(HttpMethod.POST, "/api/v1/members/email-verification/start", permitAll) | ||
authorize(HttpMethod.POST, "/api/v1/members/email-verification", permitAll) | ||
authorize(HttpMethod.POST, "/api/v1/members", permitAll) | ||
|
||
authorize(HttpMethod.POST, "/api/v1/auth/login", permitAll) | ||
|
||
authorize(anyRequest, authenticated) | ||
} | ||
|
||
csrf { disable() } | ||
|
||
sessionManagement { | ||
sessionCreationPolicy = SessionCreationPolicy.STATELESS | ||
} | ||
|
||
requestCache { | ||
requestCache = NullRequestCache() | ||
} | ||
} | ||
return http.build() | ||
} | ||
|
||
@Bean | ||
@Order(1) | ||
fun staticResourceSecurityFilterChain(http: HttpSecurity): SecurityFilterChain { | ||
http { | ||
authorizeHttpRequests { | ||
authorize(anyRequest, permitAll) | ||
} | ||
} | ||
return http.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters