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:
@@ -26,6 +26,8 @@ class WebSecurityConfig () {
|
||||
@Bean
|
||||
@Throws(Exception::class)
|
||||
fun filterChain(http: HttpSecurity): SecurityFilterChain? {
|
||||
logger.info("=== INITIALIZING SECURITY FILTER CHAIN ===")
|
||||
|
||||
http
|
||||
// .authorizeHttpRequests { auth ->
|
||||
//
|
||||
@@ -34,16 +36,21 @@ class WebSecurityConfig () {
|
||||
// //auth.anyRequest().authenticated()
|
||||
// }
|
||||
|
||||
.oauth2ResourceServer { oauth2 ->
|
||||
.oauth2ResourceServer { oauth2 -> {
|
||||
logger.info("=== oauth2ResourceServer ===")
|
||||
// oauth2!!.jwt(Customizer.withDefaults())
|
||||
// добавляем конвертер для извлечения ролей
|
||||
oauth2.jwt { jwt ->
|
||||
jwt.jwtAuthenticationConverter(jwtAuthenticationConverter())
|
||||
{
|
||||
logger.info("=== jwtAuthenticationConverter() ==="+jwtAuthenticationConverter())
|
||||
jwt.jwtAuthenticationConverter(jwtAuthenticationConverter())
|
||||
}
|
||||
}
|
||||
} // проверка JWT токен
|
||||
.sessionManagement { session: SessionManagementConfigurer<HttpSecurity?>? ->
|
||||
}} // проверка JWT токен
|
||||
.sessionManagement {{ session: SessionManagementConfigurer<HttpSecurity?>? ->
|
||||
logger.info("=== sessionManagement ===")
|
||||
session!!.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||
} // без сессий
|
||||
}} // без сессий
|
||||
.csrf { csrf: CsrfConfigurer<HttpSecurity?>? -> csrf!!.disable() } // отключаем CSRF для API
|
||||
|
||||
return http.build()
|
||||
@@ -57,7 +64,7 @@ class WebSecurityConfig () {
|
||||
|
||||
// Извлекаем роли из resource_access.test_client.roles
|
||||
val resourceAccess = jwt.claims["resource_access"] as? Map<*, *>
|
||||
logger.info("Roles! "+resourceAccess)
|
||||
logger.info("Roles1! "+resourceAccess)
|
||||
val clientAccess = resourceAccess?.get("test_client") as? Map<*, *>
|
||||
val clientRoles = clientAccess?.get("roles") as? List<*>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user