Merge pull request #663 from usbharu/fix-spring-authorization-server

fix: #654 Spring Authorization ServerのSecurityFIlterChainの設定方法が変わっている
This commit is contained in:
usbharu 2025-01-22 00:06:35 +09:00 committed by GitHub
commit a7e9ee1f37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 2 deletions

View File

@ -45,7 +45,7 @@ import org.springframework.security.oauth2.server.authorization.OAuth2Authorizat
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType
import org.springframework.security.oauth2.server.authorization.client.JdbcRegisteredClientRepository
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings
import org.springframework.security.oauth2.server.authorization.token.JwtEncodingContext
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenCustomizer
@ -65,8 +65,16 @@ class SecurityConfig {
@Bean
@Order(1)
fun oauth2Provider(http: HttpSecurity): SecurityFilterChain {
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http)
val authorizationServer = OAuth2AuthorizationServerConfigurer.authorizationServer()
http {
securityMatcher(authorizationServer.endpointsMatcher)
with(authorizationServer) {
authorizationEndpoint {
}
}
authorizeHttpRequests {
authorize(anyRequest, authenticated)
}
exceptionHandling {
authenticationEntryPoint = LoginUrlAuthenticationEntryPoint("/auth/sign_in")
}