OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - JwtDecoder 에 의한 검증(MAC)
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) {
return NimbusJwtDecoder.withSecretKey(octetSequenceKey.toSecretKey())
.macAlgorithm(MacAlgorithm.from(properties.getJwt().getJwsAlgorithms().get(0)))
.build();
}
}
SecretKey기반 JwtDecoder 생성대칭키 방식으로 생성된 토큰을 검증하기 위해
JWK를 상속한OctetSequenceKey로 SecretKey 기반JwtDecoder를 생성한다.
application.yml
spring:
security:
oauth2:
resourceserver:
jwt:
jws-algorithms: HS256SecurityConfig
기존에 필터를 제거하고
JwtDecoder에 의한 검증이 되도록 API 설정
이전 ↩️ - OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - JwtAuthorizationMacFilter(MAC)
다음 ↪️ - OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - JwtAuthorizationRsaFilter(RSA)
PreviousOAuth 2.0 Resource Server MAC & RSA 토큰 검증 - JwtAuthorizationRsaFilter(RSA)NextOAuth 2.0 Resource Server MAC & RSA 토큰 검증 - PublicKey.txt 에 의한 검증(RSA)
Last updated