CXF RFC 7662 엔드 포인트 구현을 가리키는 tokenInfoUri와 함께 스프링 보안 OAuth2를 사용하고 있습니다. tokenInfoUri를 호출 할 때스프링 OAuth2 : tokenInfoUri은 RFC 7662 엔드 포인트로 ClassCastException을 생성합니다.
는은, 봄은 java.lang.ClassCastException가 생성됩니다 java.lang.String의이 java.util.Collection으로
캐스트 할 수없는 RFC 7662의 응답은 다음과 같습니다
{
"active":true,
"client_id":"83EQEL8D1OiCIw",
"username":"alice",
"token_type":"Bearer",
"scope":"openid hello.say",
"iat":1470083268,
"exp":1470086868
}
그래서 scope는 Collection이 아닌 String으로 역 직렬화됩니다. 스프링이이 RFC (https://tools.ietf.org/html/rfc7662#section-2.2)를 처리하지 않는 것 같습니다.
DefaultAccessTokenConverter의 최신 버전은 String 유형을 처리하지만 RFC7662 규격을 준수하도록 Set (문자열 분리 기호)을 분할해야합니다.
문제를 만들어야합니까?
감사합니다, 아드리안
여기에 자세한 내용은; 스프링 보안 OAuth 2.0.9. 스택 트레이스 :
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection
at org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter.extractAuthentication(DefaultAccessTokenConverter.java:124) ~[spring-security-oauth2-2.0.9.RELEASE.jar:na]
at org.springframework.security.oauth2.provider.token.RemoteTokenServices.loadAuthentication(RemoteTokenServices.java:115) ~[spring-security-oauth2-2.0.9.RELEASE.jar:na]
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager.authenticate(OAuth2AuthenticationManager.java:83) ~[spring-security-oauth2-2.0.9.RELEASE.jar:na]
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:150) ~[spring-security-oauth2-2.0.9.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) ~[spring-security-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
구성 :
security:
user:
password: user
oauth2:
client:
clientId: blabli
clientSecret: blabla
resource:
serviceId: ${PREFIX:}resource
tokenInfoUri: http://localhost:9081/oidc/oauth2/introspect
요청 :
POST /oidc/oauth2/introspect HTTP/1.1
Accept: application/json, application/*+json
Authorization: Basic ODNFUUVMOEQxT2lDSXc6dy1OZHpERnlJaTJadThQUkRmeE9Xdw==
Content-Type: application/x-www-form-urlencoded
User-Agent: Java/1.8.0_91
Host: localhost:9080
Connection: keep-alive
Content-Length: 38
token=faa395452928f5126fc8cf61b66bf0f4
응답 :이 봄의 OAuth 2.0.10에서 해결
{
"active":true,
"client_id":"83EQEL8D1OiCIw",
"username":"alice",
"token_type":"Bearer",
"scope":"openid hello.say",
"iat":1470083268,
"exp":1470086868
}