From 3934b0aa6ddfdda0b0c9e18f3070d4a402c19483 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Thu, 11 Jan 2024 14:29:48 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Client=20Credential=20Flow=E3=81=B8?= =?UTF-8?q?=E3=81=AE=E5=AF=BE=E5=BF=9C=E6=BC=8F=E3=82=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/usbharu/hideout/application/config/SecurityConfig.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/application/config/SecurityConfig.kt b/src/main/kotlin/dev/usbharu/hideout/application/config/SecurityConfig.kt index 966be809..870c1159 100644 --- a/src/main/kotlin/dev/usbharu/hideout/application/config/SecurityConfig.kt +++ b/src/main/kotlin/dev/usbharu/hideout/application/config/SecurityConfig.kt @@ -43,6 +43,7 @@ import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.core.Authentication import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder import org.springframework.security.crypto.password.PasswordEncoder +import org.springframework.security.oauth2.core.AuthorizationGrantType import org.springframework.security.oauth2.jwt.JwtDecoder import org.springframework.security.oauth2.server.authorization.OAuth2TokenType import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration @@ -267,7 +268,8 @@ class SecurityConfig { @Bean fun jwtTokenCustomizer(): OAuth2TokenCustomizer { return OAuth2TokenCustomizer { context: JwtEncodingContext -> - if (OAuth2TokenType.ACCESS_TOKEN == context.tokenType) { + + if (OAuth2TokenType.ACCESS_TOKEN == context.tokenType && context.authorization?.authorizationGrantType == AuthorizationGrantType.AUTHORIZATION_CODE) { val userDetailsImpl = context.getPrincipal().principal as UserDetailsImpl context.claims.claim("uid", userDetailsImpl.id.toString()) }