|
@@ -17,7 +17,6 @@
|
|
|
package org.springframework.security.oauth2.server.resource.introspection;
|
|
|
|
|
|
import java.net.URI;
|
|
|
-import java.net.URL;
|
|
|
import java.time.Instant;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
@@ -146,7 +145,25 @@ public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
|
|
|
(k, v) -> Instant.ofEpochSecond(((Number) v).longValue()));
|
|
|
claims.computeIfPresent(OAuth2IntrospectionClaimNames.ISSUED_AT,
|
|
|
(k, v) -> Instant.ofEpochSecond(((Number) v).longValue()));
|
|
|
- claims.computeIfPresent(OAuth2IntrospectionClaimNames.ISSUER, (k, v) -> issuer(v.toString()));
|
|
|
+ // RFC-7662 page 7 directs users to RFC-7519 for defining the values of these
|
|
|
+ // issuer fields.
|
|
|
+ // https://datatracker.ietf.org/doc/html/rfc7662#page-7
|
|
|
+ //
|
|
|
+ // RFC-7519 page 9 defines issuer fields as being 'case-sensitive' strings
|
|
|
+ // containing
|
|
|
+ // a 'StringOrURI', which is defined on page 5 as being any string, but strings
|
|
|
+ // containing ':'
|
|
|
+ // should be treated as valid URIs.
|
|
|
+ // https://datatracker.ietf.org/doc/html/rfc7519#section-2
|
|
|
+ //
|
|
|
+ // It is not defined however as to whether-or-not normalized URIs should be
|
|
|
+ // treated as the same literal
|
|
|
+ // value. It only defines validation itself, so to avoid potential ambiguity or
|
|
|
+ // unwanted side effects that
|
|
|
+ // may be awkward to debug, we do not want to manipulate this value. Previous
|
|
|
+ // versions of Spring Security
|
|
|
+ // would *only* allow valid URLs, which is not what we wish to achieve here.
|
|
|
+ claims.computeIfPresent(OAuth2IntrospectionClaimNames.ISSUER, (k, v) -> v.toString());
|
|
|
claims.computeIfPresent(OAuth2IntrospectionClaimNames.NOT_BEFORE,
|
|
|
(k, v) -> Instant.ofEpochSecond(((Number) v).longValue()));
|
|
|
Collection<GrantedAuthority> authorities = new ArrayList<>();
|
|
@@ -163,16 +180,6 @@ public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
|
|
|
return new OAuth2IntrospectionAuthenticatedPrincipal(claims, authorities);
|
|
|
}
|
|
|
|
|
|
- private URL issuer(String uri) {
|
|
|
- try {
|
|
|
- return new URL(uri);
|
|
|
- }
|
|
|
- catch (Exception ex) {
|
|
|
- throw new OAuth2IntrospectionException(
|
|
|
- "Invalid " + OAuth2IntrospectionClaimNames.ISSUER + " value: " + uri);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private OAuth2IntrospectionException onError(Throwable ex) {
|
|
|
return new OAuth2IntrospectionException(ex.getMessage(), ex);
|
|
|
}
|