Use single security chain with auth permitAll
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
This commit is contained in:
@@ -2,7 +2,6 @@ package com.android.trisolarisserver.security
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Bean
|
import org.springframework.context.annotation.Bean
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
import org.springframework.core.annotation.Order
|
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity
|
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy
|
import org.springframework.security.config.http.SessionCreationPolicy
|
||||||
@@ -15,24 +14,12 @@ class SecurityConfig(
|
|||||||
private val firebaseAuthFilter: FirebaseAuthFilter
|
private val firebaseAuthFilter: FirebaseAuthFilter
|
||||||
) {
|
) {
|
||||||
@Bean
|
@Bean
|
||||||
@Order(0)
|
fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
fun authChain(http: HttpSecurity): SecurityFilterChain {
|
|
||||||
http
|
|
||||||
.securityMatcher("/auth/**", "/", "/health")
|
|
||||||
.csrf { it.disable() }
|
|
||||||
.authorizeHttpRequests { it.anyRequest().permitAll() }
|
|
||||||
.httpBasic { it.disable() }
|
|
||||||
.formLogin { it.disable() }
|
|
||||||
return http.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Order(1)
|
|
||||||
fun apiChain(http: HttpSecurity): SecurityFilterChain {
|
|
||||||
http
|
http
|
||||||
.csrf { it.disable() }
|
.csrf { it.disable() }
|
||||||
.sessionManagement { it.sessionCreationPolicy(SessionCreationPolicy.STATELESS) }
|
.sessionManagement { it.sessionCreationPolicy(SessionCreationPolicy.STATELESS) }
|
||||||
.authorizeHttpRequests {
|
.authorizeHttpRequests {
|
||||||
|
it.requestMatchers("/", "/health", "/auth/**").permitAll()
|
||||||
it.anyRequest().authenticated()
|
it.anyRequest().authenticated()
|
||||||
}
|
}
|
||||||
.httpBasic { it.disable() }
|
.httpBasic { it.disable() }
|
||||||
|
|||||||
Reference in New Issue
Block a user