Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure access_token is available after introspect #660

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public Future<User> authenticate(Credentials credentials) {

// attempt to create a user from the json object
final User newUser = createUser(
json,
json.put("access_token", tokenCredentials.getToken()),
user.attributes().containsKey("missing-kid"));

// final step, verify if the user is not expired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,11 @@ public void introspectAccessToken(TestContext should) {
should.assertNotNull(token2);
JsonObject principal = token2.principal().copy();

// clean time specific value
principal.remove("expires_at");
principal.remove("access_token");
principal.remove("opaque");

final JsonObject assertion = fixtureIntrospect.copy();
// principal should be identified as opaque
assertion.put("opaque", true);
// access token should be present in the principal
assertion.put("access_token", token);

should.assertEquals(assertion.getMap(), principal.getMap());

Expand Down Expand Up @@ -180,11 +179,13 @@ public void introspectAccessTokenGoogleWay(TestContext should) {
should.assertNotNull(token);
// make a copy because later we need to original data
JsonObject principal = token.principal().copy();
// clean time specific value
principal.remove("opaque");

// clean up control
final JsonObject assertion = fixtureGoogle.copy();
// principal should be identified as opaque
assertion.put("opaque", true);
// access token should be present in the principal
assertion.put("access_token", OAuth2IntrospectTest.token);

should.assertEquals(assertion.getMap(), principal.getMap());

Expand Down Expand Up @@ -230,7 +231,17 @@ public void introspectAccessTokenKeyCloakWay(TestContext should) {
} else {
User token = res.result();
should.assertNotNull(token);
should.assertNotNull(token.principal());
// make a copy because later we need to original data
JsonObject principal = token.principal().copy();

// clean up control
final JsonObject assertion = fixtureKeycloak.copy();
// principal should be identified as opaque
assertion.put("opaque", true);
// access token should be present in the principal
assertion.put("access_token", OAuth2IntrospectTest.token);

should.assertEquals(assertion.getMap(), principal.getMap());
test.complete();
}
});
Expand Down