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

feat: Allow extra fields in introspect response #520

Closed
wants to merge 4 commits into from

Conversation

mitar
Copy link
Contributor

@mitar mitar commented Oct 28, 2020

Related issue

Fixes #441.

Proposed changes

Sessions can now implement GetExtraClaims to control extra claims in token's introspect output.

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got green light (please contact
    [email protected]) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation within the code base (if appropriate).

Further comments

I am not completely satisfied with tests here. For example, there is no test which would check which all fields are really output from introspect for regular access token and for JWT access token. Any suggestion where to add it is welcome.

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I've added a few comments with ideas how to improve the patch :)

introspection_response_writer.go Outdated Show resolved Hide resolved
introspection_response_writer.go Show resolved Hide resolved
introspection_response_writer_test.go Show resolved Hide resolved
@mitar mitar requested a review from aeneasr November 4, 2020 20:33
@mitar
Copy link
Contributor Author

mitar commented Nov 4, 2020

@aeneasr I think I addressed all your comments.

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long wait time, but it is finally possible to run oidc conformity tests in fosite which I wanted to address before continuing review here.

I added a few more comments which I think need to be addressed before merge!

handler/oauth2/strategy_jwt_session.go Show resolved Hide resolved
@@ -55,7 +55,6 @@ var jwtValidCase = func(tokenType fosite.TokenType) *fosite.Request {
JWTClaims: &jwt.JWTClaims{
Issuer: "fosite",
Subject: "peter",
Audience: []string{"group0"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this still work though? If so can we add a test to cover this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it cannot work because we are filtering out aud from GetExtraClaims. Before the test was in fact buggy, I would claim, and didn't really check if audience is set in the generated (and tested) token. So setting this value does nothing.

for name, value := range extraClaims {
switch name {
// We do not allow these to be set through extra claims.
case "exp", "client_id", "scope", "iat", "sub", "aud", "username":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must include iss, jti, nbf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really possible to limit. Because currently regular claims from JWT tokens are passed through to introspection endpoint using GetExtraClaims. I tried to not do it like that, but I get import cycle. See: 04cd625

introspection_response_writer.go Show resolved Hide resolved
@aeneasr aeneasr added the stale Feedback from one or more authors is required to proceed. label Jan 11, 2021
@github-actions github-actions bot closed this Feb 13, 2021
@mitar
Copy link
Contributor Author

mitar commented Apr 9, 2021

I made a followup PR: #579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Feedback from one or more authors is required to proceed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for adding additional fields to introspection result
2 participants