forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply the required claims restriction to OIDC introspections
- Loading branch information
1 parent
8d60463
commit 3d7db50
Showing
4 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ public class OidcResource { | |
private volatile boolean rotate; | ||
private volatile int jwkEndpointCallCount; | ||
private volatile int introspectionEndpointCallCount; | ||
private volatile int opaqueToken2UsageCount; | ||
private volatile int revokeEndpointCallCount; | ||
private volatile int userInfoEndpointCallCount; | ||
private volatile boolean enableDiscovery = true; | ||
|
@@ -112,6 +113,13 @@ public int resetIntrospectionEndpointCallCount() { | |
return introspectionEndpointCallCount; | ||
} | ||
|
||
@POST | ||
@Path("opaque-token-call-count") | ||
public int resetOpaqueTokenCallCount() { | ||
opaqueToken2UsageCount = 0; | ||
return opaqueToken2UsageCount; | ||
} | ||
|
||
@POST | ||
@Produces("application/json") | ||
@Path("introspect") | ||
|
@@ -120,7 +128,15 @@ public String introspect(@FormParam("client_id") String clientId, @FormParam("cl | |
introspectionEndpointCallCount++; | ||
|
||
boolean activeStatus = introspection && !token.endsWith("-invalid"); | ||
|
||
boolean requiredClaim = true; | ||
if (token.endsWith("_2")) { | ||
opaqueToken2UsageCount++; | ||
if (opaqueToken2UsageCount == 2) { | ||
// This is to confirm that the same opaque token_2 works well when its introspection response | ||
// includes `required_claim` with value "1" but fails when the required claim is not included | ||
requiredClaim = false; | ||
} | ||
} | ||
String introspectionClientId = "none"; | ||
String introspectionClientSecret = "none"; | ||
if (clientSecret != null) { | ||
|
@@ -146,6 +162,7 @@ public String introspect(@FormParam("client_id") String clientId, @FormParam("cl | |
" \"scope\": \"user\"," + | ||
" \"email\": \"[email protected]\"," + | ||
" \"username\": \"alice\"," + | ||
(requiredClaim ? "\"required_claim\": \"1\"," : "") + | ||
" \"introspection_client_id\": \"" + introspectionClientId + "\"," + | ||
" \"introspection_client_secret\": \"" + introspectionClientSecret + "\"," + | ||
" \"client_id\": \"" + clientId + "\"" + | ||
|
@@ -251,13 +268,23 @@ public String testAccessTokenWithEmptyScope(@QueryParam("kid") String kid, @Quer | |
@POST | ||
@Path("opaque-token") | ||
@Produces("application/json") | ||
public String testOpaqueToken(@QueryParam("kid") String kid) { | ||
public String testOpaqueToken() { | ||
return "{\"access_token\": \"987654321\"," + | ||
" \"token_type\": \"Bearer\"," + | ||
" \"refresh_token\": \"123456789\"," + | ||
" \"expires_in\": 300 }"; | ||
} | ||
|
||
@POST | ||
@Path("opaque-token2") | ||
@Produces("application/json") | ||
public String testOpaqueToken2() { | ||
return "{\"access_token\": \"987654321_2\"," + | ||
" \"token_type\": \"Bearer\"," + | ||
" \"refresh_token\": \"123456789\"," + | ||
" \"expires_in\": 300 }"; | ||
} | ||
|
||
@POST | ||
@Path("enable-introspection") | ||
public boolean setIntrospection() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters