-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c0879a
commit 58ad7c2
Showing
3 changed files
with
52 additions
and
14 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
13 changes: 0 additions & 13 deletions
13
Api-Module/src/main/kotlin/com/bamyanggang/apimodule/HealthCheckController.kt
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
...c/main/kotlin/com/bamyanggang/apimodule/domain/auth/presentation/config/SecurityConfig.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,48 @@ | ||
package com.bamyanggang.apimodule.domain.auth.presentation.config | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity | ||
import org.springframework.security.config.annotation.web.builders.WebSecurity | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer | ||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer | ||
import org.springframework.security.config.http.SessionCreationPolicy | ||
import org.springframework.security.web.SecurityFilterChain | ||
|
||
|
||
@EnableWebSecurity | ||
@Configuration | ||
class SecurityConfig { | ||
// TODO: api 추가될 때 white list url 확인해서 추가하기. | ||
private val whiteList: Array<String> = arrayOf( | ||
"/api/**", | ||
"/api-docs/**", | ||
"/", | ||
"/error" | ||
) | ||
|
||
@Bean | ||
fun webSecurityCustomizer(): WebSecurityCustomizer { | ||
return WebSecurityCustomizer { web: WebSecurity -> web.ignoring().requestMatchers(*whiteList) } | ||
} | ||
|
||
@Bean | ||
@Throws(Exception::class) | ||
fun filterChain(http: HttpSecurity): SecurityFilterChain { | ||
return http | ||
.csrf { obj: AbstractHttpConfigurer<*, *> -> obj.disable() } | ||
.formLogin { obj: AbstractHttpConfigurer<*, *> -> obj.disable() } | ||
.httpBasic { obj: AbstractHttpConfigurer<*, *> -> obj.disable() } | ||
.sessionManagement { sessionManagementConfigurer -> | ||
sessionManagementConfigurer | ||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS) | ||
} | ||
.authorizeHttpRequests { authorizationManagerRequestMatcherRegistry -> | ||
authorizationManagerRequestMatcherRegistry | ||
.anyRequest() | ||
.authenticated() | ||
} | ||
.build() | ||
} | ||
} |