OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - JwtDecoder 에 의한 검증(RSA)
JwtDecoderConfig
@Configuration
public class JwtDecoderConfig {
@Bean
@ConditionalOnProperty(prefix = "spring.security.oauth2.resourceserver.jwt", name = "jws-algorithms", havingValue = "HS256", matchIfMissing = false)
public JwtDecoder jwtDecoderBySecretKeyValue(OctetSequenceKey octetSequenceKey, OAuth2ResourceServerProperties properties) {
...
}
//추가
@Bean
@ConditionalOnProperty(prefix = "spring.security.oauth2.resourceserver.jwt", name = "jws-algorithms", havingValue = "RS512", matchIfMissing = false)
public JwtDecoder jwtDecoderByPublicKeyValue(RSAKey rsaKey, OAuth2ResourceServerProperties properties) throws JOSEException {
return NimbusJwtDecoder.withPublicKey(rsaKey.toRSAPublicKey())
.signatureAlgorithm(SignatureAlgorithm.from(properties.getJwt().getJwsAlgorithms().get(0)))
.build();
}
}
PublicKey기반JwtDecoder생성비대칭 키 방식으로 생성된 토큰을 검증하기 위해
JWK를 상속한RSAKey로 PublicKey 기반JwtDecoder를 생성한다.
application.yml
SignatureConfig
SecurityConfig
이전 ↩️ - OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - JwtAuthorizationRsaFilter(RSA)
다음 ↪️ - OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - PublicKey.txt에 의한 검증(RSA)
PreviousOAuth 2.0 Resource Server MAC & RSA 토큰 검증 - PublicKey.txt 에 의한 검증(RSA)NextOAuth 2.0 Resource Server MAC & RSA 토큰 검증 - 기본 환경 및 공통 클래스 구성
Last updated