diff --git a/src/main/kotlin/com/example/v1oauthauthorizationservice/infrastructure/configuration/security/SecurityConfiguration.kt b/src/main/kotlin/com/example/v1oauthauthorizationservice/infrastructure/configuration/security/SecurityConfiguration.kt index c3eb2f1..6584d32 100644 --- a/src/main/kotlin/com/example/v1oauthauthorizationservice/infrastructure/configuration/security/SecurityConfiguration.kt +++ b/src/main/kotlin/com/example/v1oauthauthorizationservice/infrastructure/configuration/security/SecurityConfiguration.kt @@ -1,5 +1,6 @@ package com.example.v1oauthauthorizationservice.infrastructure.configuration.security +import com.example.v1oauthauthorizationservice.infrastructure.configuration.AuthenticationFilter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.core.Ordered @@ -11,10 +12,13 @@ import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.security.web.SecurityFilterChain +import org.springframework.security.web.access.intercept.AuthorizationFilter @EnableWebSecurity(debug = true) @Configuration -class SecurityConfiguration { +class SecurityConfiguration( + private val authenticationFilter: AuthenticationFilter +) { @Bean fun passwordEncoder(): PasswordEncoder = BCryptPasswordEncoder() @@ -36,6 +40,7 @@ class SecurityConfiguration { .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() + httpSecurity.addFilterBefore(authenticationFilter, AuthorizationFilter::class.java) httpSecurity .authorizeHttpRequests { authorize ->