Skip to content

Commit 85246d2

Browse files
authored
Parse 'sub' to identify resource owner
As per https://tools.ietf.org/html/rfc7662#section-2.2 the `sub` key should identify the resource owner in oauth2 introspection responses. This change adds support for the `sub` key and will allow the introspection response of RFC-compliant servers to be parsed. Will still try `user_id` first as to not break backward compatibility.
1 parent ce9bf35 commit 85246d2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

openid-connect-client/src/main/java/org/mitre/oauth2/introspectingfilter/IntrospectingTokenService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ private OAuth2Request createStoredRequest(final JsonObject token) {
244244
private Authentication createUserAuthentication(JsonObject token) {
245245
JsonElement userId = token.get("user_id");
246246
if(userId == null) {
247-
return null;
247+
userId = token.get("sub");
248+
if (userId == null) {
249+
return null;
250+
}
248251
}
249252

250253
return new PreAuthenticatedAuthenticationToken(userId.getAsString(), token, introspectionAuthorityGranter.getAuthorities(token));

0 commit comments

Comments
 (0)