fix security configuration
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -21,22 +21,14 @@ class WebSecurityConfig () {
|
|||||||
@Bean
|
@Bean
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun filterChain(http: HttpSecurity): SecurityFilterChain? {
|
fun filterChain(http: HttpSecurity): SecurityFilterChain? {
|
||||||
http
|
http.authorizeHttpRequests(Customizer { auth ->
|
||||||
.authorizeHttpRequests(Customizer { auth ->
|
auth.anyRequest().authenticated() })
|
||||||
auth
|
|
||||||
.anyRequest().authenticated()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.oauth2ResourceServer(Customizer { oauth2 ->
|
.oauth2ResourceServer(Customizer { oauth2 ->
|
||||||
oauth2!!
|
oauth2!!.jwt(Customizer.withDefaults())
|
||||||
.jwt(Customizer.withDefaults())
|
}) // ← проверяем JWT токен
|
||||||
} // ← проверяем JWT токен
|
|
||||||
)
|
|
||||||
.sessionManagement(Customizer { session: SessionManagementConfigurer<HttpSecurity?>? ->
|
.sessionManagement(Customizer { session: SessionManagementConfigurer<HttpSecurity?>? ->
|
||||||
session!!
|
session!!.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
}) // без сессий
|
||||||
} // без сессий
|
|
||||||
)
|
|
||||||
.csrf(Customizer { csrf: CsrfConfigurer<HttpSecurity?>? -> csrf!!.disable() }) // отключаем CSRF для API
|
.csrf(Customizer { csrf: CsrfConfigurer<HttpSecurity?>? -> csrf!!.disable() }) // отключаем CSRF для API
|
||||||
|
|
||||||
return http.build()
|
return http.build()
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ spring:
|
|||||||
# Keycloak Security
|
# Keycloak Security
|
||||||
security:
|
security:
|
||||||
oauth2:
|
oauth2:
|
||||||
|
resourceserver:
|
||||||
|
jwt:
|
||||||
|
issuer-uri: https://keycloak.dmitriy-churmeev.tech/realms/test_realm
|
||||||
client:
|
client:
|
||||||
registration:
|
registration:
|
||||||
keycloak:
|
keycloak:
|
||||||
|
|||||||
Reference in New Issue
Block a user