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:
@@ -11,20 +11,27 @@ import org.springframework.security.config.annotation.web.configurers.SessionMan
|
|||||||
import org.springframework.security.config.http.SessionCreationPolicy
|
import org.springframework.security.config.http.SessionCreationPolicy
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority
|
import org.springframework.security.core.authority.SimpleGrantedAuthority
|
||||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter
|
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter
|
||||||
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter
|
|
||||||
import org.springframework.security.web.SecurityFilterChain
|
import org.springframework.security.web.SecurityFilterChain
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
@EnableMethodSecurity
|
@EnableMethodSecurity(
|
||||||
|
prePostEnabled = true, // ← явно включаем
|
||||||
|
securedEnabled = true // ← опционально
|
||||||
|
)
|
||||||
class WebSecurityConfig () {
|
class WebSecurityConfig () {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun filterChain(http: HttpSecurity): SecurityFilterChain? {
|
fun filterChain(http: HttpSecurity): SecurityFilterChain? {
|
||||||
http.authorizeHttpRequests(Customizer { auth ->
|
http.authorizeHttpRequests(Customizer { auth ->
|
||||||
auth.anyRequest().authenticated() })
|
|
||||||
|
auth.requestMatchers("/public/**", "/health", "/info").permitAll()
|
||||||
|
auth.anyRequest().permitAll()
|
||||||
|
//auth.anyRequest().authenticated()
|
||||||
|
|
||||||
|
})
|
||||||
.oauth2ResourceServer(Customizer { oauth2 ->
|
.oauth2ResourceServer(Customizer { oauth2 ->
|
||||||
// oauth2!!.jwt(Customizer.withDefaults())
|
// oauth2!!.jwt(Customizer.withDefaults())
|
||||||
// добавляем конвертер для извлечения ролей
|
// добавляем конвертер для извлечения ролей
|
||||||
|
|||||||
Reference in New Issue
Block a user