[java-idp-oidc] branch main updated: JOIDC-326 - Introspection and revocation endpoints are too strict with token_type_hint
Codeberg
noreply at shibboleth.net
Sun Nov 29 08:29:52 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-oidc/commit/7615cb7e56d172c3ddf360c3b19fa31970c959c1
The following commit(s) were added to refs/heads/main by this push:
new 7615cb7e JOIDC-326 - Introspection and revocation endpoints are too strict with token_type_hint
7615cb7e is described below
commit 7615cb7e56d172c3ddf360c3b19fa31970c959c1
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Sun Nov 29 10:29:07 2026 +0200
JOIDC-326 - Introspection and revocation endpoints are too strict with token_type_hint
https://shibboleth.atlassian.net/browse/JOIDC-326
Fixed in the shared abstract action for both introspection and revocation, covered in the flow tests
---
.../profile/impl/AbstractProcessTokenAction.java | 12 +++++-
.../op/profile/flow/IntrospectionFlowTest.java | 45 ++++++++++++++++++++++
.../oidc/op/profile/flow/RevocationFlowTest.java | 34 ++++++++++++++++
3 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/AbstractProcessTokenAction.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/AbstractProcessTokenAction.java
index 6f54d29d..a379c911 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/AbstractProcessTokenAction.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/AbstractProcessTokenAction.java
@@ -188,13 +188,19 @@ public abstract class AbstractProcessTokenAction<T> extends AbstractOIDCRequestA
return;
}
- log.debug("{} Token to introspect: {}", getLogPrefix(), token.getValue());
+ log.trace("{} Token to process: {}", getLogPrefix(), token.getValue());
JWTClaimsSet tokenClaimsSet;
if (token instanceof AccessToken) {
tokenClaimsSet = parseAccessToken(token);
+ if (tokenClaimsSet == null) {
+ tokenClaimsSet = parseRefreshToken(profileRequestContext, token);
+ }
} else if (token instanceof RefreshToken) {
tokenClaimsSet = parseRefreshToken(profileRequestContext, token);
+ if (tokenClaimsSet == null) {
+ tokenClaimsSet = parseAccessToken(token);
+ }
} else {
// No token hint, have to try both.
tokenClaimsSet = parseAccessToken(token);
@@ -204,7 +210,7 @@ public abstract class AbstractProcessTokenAction<T> extends AbstractOIDCRequestA
}
if (tokenClaimsSet == null) {
- log.warn("{} Unable to parse/decode token for introspection", getLogPrefix());
+ log.warn("{} Unable to parse/decode token for processing", getLogPrefix());
return;
}
@@ -244,6 +250,7 @@ public abstract class AbstractProcessTokenAction<T> extends AbstractOIDCRequestA
return null;
}
+ assert signedJWT != null; assert dataSealer != null;
final JWTClaimsSet jwtClaimsSet = AccessTokenClaimsSet.parse(signedJWT, dataSealer).getClaimsSet();
log.debug("{} Checking JWT signature", getLogPrefix());
final Collection<Credential> credList = new ArrayList<>();
@@ -260,6 +267,7 @@ public abstract class AbstractProcessTokenAction<T> extends AbstractOIDCRequestA
final String errorEventId = JWTSignatureValidationUtil.validateSignatureEx(credList, signedJWT,
OidcEventIds.INVALID_GRANT);
if (errorEventId != null) {
+ assert jwtClaimsSet != null;
log.warn("{} Signature on token ID '{}' invalid", getLogPrefix(), jwtClaimsSet.getJWTID());
return null;
}
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/IntrospectionFlowTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/IntrospectionFlowTest.java
index 26a20286..98f16266 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/IntrospectionFlowTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/IntrospectionFlowTest.java
@@ -219,6 +219,28 @@ public class IntrospectionFlowTest extends AbstractOidcClientAuthenticationFlowT
}
}
+ @Test
+ public void testSuccessWrongHint() throws IOException, NoSuchAlgorithmException, URISyntaxException,
+ DataSealerException, ComponentInitializationException {
+ for (final String clientId : clientIds) {
+ storeMetadata(storageService, clientId, clientSecret, scope);
+ setBasicAuth(clientId, clientSecret);
+ setHttpFormRequest("POST", Map.of(
+ "token_type_hint", "refresh_token",
+ "token",
+ buildToken(clientId, "sub", Scope.parse("openid")).toJSONObject().getAsString("access_token")));
+ final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ final TokenIntrospectionSuccessResponse resp =
+ parseSuccessResponse(result, TokenIntrospectionSuccessResponse.class);
+ Assert.assertTrue(resp.isActive());
+ assertBearerToken(resp);
+ Assert.assertEquals(resp.getClientID().getValue(), clientId);
+ Assert.assertEquals(resp.getScope(), Scope.parse("openid"));
+ Assert.assertNull(resp.getAudience());
+ Assert.assertEquals(resp.getUsername(), "jdoe");
+ }
+ }
+
@Test
public void testSuccessDPoP() throws IOException, NoSuchAlgorithmException, URISyntaxException, DataSealerException,
ComponentInitializationException {
@@ -361,6 +383,29 @@ public class IntrospectionFlowTest extends AbstractOidcClientAuthenticationFlowT
Assert.assertEquals(resp.getUsername(), "jdoe");
}
+ @Test
+ public void testSuccessWithRefreshTokenWrongHint() throws IOException, NoSuchAlgorithmException,
+ URISyntaxException, DataSealerException, ComponentInitializationException {
+ final String rootId = idGenerator.generateIdentifier();
+ final String jti = idGenerator.generateIdentifier();
+ storeMetadata(storageService, clientId, clientSecret, scope);
+ setBasicAuth(clientId, clientSecret);
+ setHttpFormRequest("POST", Map.of(
+ "token_type_hint", "access_token",
+ "token",
+ buildRefreshToken(clientId, "sub", Scope.parse("openid"), null, jti, rootId).toJSONObject()
+ .getAsString("refresh_token")));
+ final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ final TokenIntrospectionSuccessResponse resp =
+ parseSuccessResponse(result, TokenIntrospectionSuccessResponse.class);
+ Assert.assertTrue(resp.isActive());
+ assertBearerToken(resp);
+ Assert.assertEquals(resp.getClientID().getValue(), clientId);
+ Assert.assertEquals(resp.getScope(), Scope.parse("openid"));
+ Assert.assertNull(resp.getAudience());
+ Assert.assertEquals(resp.getUsername(), "jdoe");
+ }
+
@Test
public void testSuccessWithJwtRefreshToken() throws IOException, NoSuchAlgorithmException, URISyntaxException,
DataSealerException, ComponentInitializationException, JOSEException {
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/RevocationFlowTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/RevocationFlowTest.java
index 4ad7fc55..e5c6299c 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/RevocationFlowTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/RevocationFlowTest.java
@@ -142,6 +142,24 @@ public class RevocationFlowTest extends AbstractOidcClientAuthenticationFlowTest
}
}
+ @Test
+ public void testSuccessWrongHint() throws IOException, NoSuchAlgorithmException, URISyntaxException,
+ DataSealerException, ComponentInitializationException {
+ final String id = idGenerator.generateIdentifier();
+ final String rootId = idGenerator.generateIdentifier();
+ for (final String clientId : clientIds) {
+ setBasicAuth(clientId, clientSecret);
+ storeMetadata(storageService, clientId, clientSecret, scope);
+ setHttpFormRequest("POST", Collections.unmodifiableMap(Map.of("token_type_hint", "refresh_token",
+ "token", super.buildToken(clientId, "sub",
+ Scope.parse("openid"), null, id, rootId).toJSONObject().getAsString("access_token"))));
+ final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ parseSuccessResponse(result, OAuth2RevocationSuccessResponse.class);
+ Assert.assertFalse(revocationCache.isRevoked(RevocationCacheContexts.SINGLE_ACCESS_OR_REFRESH_TOKENS, id));
+ Assert.assertTrue(revocationCache.isRevoked(RevocationCacheContexts.AUTHORIZATION_CODE, rootId));
+ }
+ }
+
@Test
public void testSuccessWithPostAuthn() throws IOException, NoSuchAlgorithmException, URISyntaxException,
DataSealerException, ComponentInitializationException {
@@ -227,6 +245,22 @@ public class RevocationFlowTest extends AbstractOidcClientAuthenticationFlowTest
Assert.assertFalse(revocationCache.isRevoked(RevocationCacheContexts.AUTHORIZATION_CODE, rootId));
}
+ @Test
+ public void testSuccessSingleRefreshTokenWrongHint() throws IOException, NoSuchAlgorithmException,
+ URISyntaxException, DataSealerException, ComponentInitializationException {
+ final String id = idGenerator.generateIdentifier();
+ final String rootId = idGenerator.generateIdentifier();
+ setBasicAuth(clientIdSingle, clientSecret);
+ storeMetadata(storageService, clientIdSingle, clientSecret, scope);
+ setHttpFormRequest("POST", Collections.unmodifiableMap(Map.of("token_type_hint", "access_token", "token",
+ super.buildRefreshToken(clientIdSingle, "sub",
+ Scope.parse("openid"), null, id, rootId).toJSONObject().getAsString("refresh_token"))));
+ final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ parseSuccessResponse(result, OAuth2RevocationSuccessResponse.class);
+ Assert.assertTrue(revocationCache.isRevoked(RevocationCacheContexts.SINGLE_ACCESS_OR_REFRESH_TOKENS, id));
+ Assert.assertFalse(revocationCache.isRevoked(RevocationCacheContexts.AUTHORIZATION_CODE, rootId));
+ }
+
@Test
public void testSuccessSingleJwtRefreshToken() throws IOException, NoSuchAlgorithmException, URISyntaxException,
DataSealerException, ComponentInitializationException, JOSEException {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list