spring-security-oauth2-resource-server
로 수집된다.spring-security-oauth2-jose
에 있다.spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: https://idp.example.com/issuer
[idp.example.com/issuer
는](http://idp.example.com/issuer는) authorization server가 발급할 JWT 토큰에 대한 iss
클레임에 포함된 값이다.
issuer-url
속성을 사용하려면idp.example.com/issuer/.wellknown/openid-configuration
,idp.example.com/.wellknown/openid-configuration/issuer
또는idp.example.com/.wellknown/oauth-authorization-server/issuer
중 하나가 인증 서버에 지원되는 엔드포인트이어야 한다. 이 엔드포인트를 Provider Configuration 엔드포인트 또는 Authorization Server 메타데이터 엔드포인트라고 한다.
위 속성들과 종속성을 추가하면 리소스 서버는 자동적으로 JWT-encoded Bearer Token을 자체 설정한다.
jwks_url
속성을 통해 조회한다.jwks_url
을 통해 조회한다.jwks_url
로 조회한다.idp.example.com
에 대해 각 JWT 발급 클레임의 유효성을 검사한다.Authorization: Bearer
헤더가 포함된 모든 요청을 처리하려고 한다.GET / HTTP/1.1
Authorization: Bearer some-token-value # Resource Server will process this
jwks_url
엔드포인트에서 얻은 공개 키로 서명의 유효성을 검사하고 JWT와 일치하는지 확인한다.exp
와 nbf
타임스탬프, JWT의 iss
클레임 유효성을 검사한다.SCOPE_
prepix를 사용하여 권한을 확인한다.
Authentication#getPrincipal
은 기본적으로 스프링 시큐리티 JWT
객체이다.JwtAuthenticationProvider
는 AuthenticationProvider
의 하위 구현체이며 JWT를 인증하기 위한 JwtDecoder
와 JwtAuthenticationConverter
를 활용한다.
Filter
에서 BearerTokenAuthenticationToken
을 AuthenticationManager
를 구현한 ProvderManager
에게 전달한다.ProviderManager
는 JwtAuthenticationProvider
타입의 AuthenticationProvider
가 설정되어 있어 사용할 수 있다.JwtAuthenticationProvider
는 JwtDecoder
를 사용해 디코딩, 검증 및 유효성을 검사한다.JwtAuthenticationProvider
는 JwtAuthenticationConverter
를 사용해 Jwt
를 grant authority의 Collection
으로 변환한다.JwtAuthenticationToken
타입이며 Jwt
를 principal
로 가지고 있는 Authentication
이 JwtDecoder
에서 리턴된다. 궁극적으로 JwtAuthenticationToken
은 SecurityContextHolder
에 설정된다.