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: include client_assertion in token hook payload #3949

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

phooijenga
Copy link
Contributor

We want to use JWTs for client authentication in combination with a token hook.

Related issue(s)

When a client authenticates via the private_key_jwt auth method the payload includes

client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer

and

client_assertion=<signed-jwt>

This works, and the token hook is called, but it does not include the assertion.

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • 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 the approval (please contact
    security@ory.sh) 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 or changed the documentation.

Further Comments

I didn't see any tests for the private_key_jwt auth method, so I copied and modified some of the existing tests for JWT as Authorization Grant.

@phooijenga phooijenga requested review from aeneasr and a team as code owners February 20, 2025 09:18
@aeneasr
Copy link
Member

aeneasr commented Feb 20, 2025

That‘s on purpose - like we don’t include the client_secret, auth code, or other tokens.

@phooijenga
Copy link
Contributor Author

phooijenga commented Feb 20, 2025 via email

@aeneasr
Copy link
Member

aeneasr commented Feb 20, 2025

Would it not be possible to replay the auth grant with the assertion?

@phooijenga
Copy link
Contributor Author

A replay attempt would be rejected because the jti was already used; which is required for this flow.

@aeneasr
Copy link
Member

aeneasr commented Feb 25, 2025

I see, it will probably more difficult to implement, but what do you think of instead including the client assertion claims and not the token itself, so that the webhook target does not need to verify the JWT?

@aeneasr aeneasr closed this Feb 25, 2025
@aeneasr aeneasr reopened this Feb 25, 2025
@phooijenga
Copy link
Contributor Author

Yeah, that would work; I'll see if I can figure out how to do that.

@phooijenga phooijenga force-pushed the token-hook-include-client-assertion branch from c1d0eb1 to 81c5802 Compare February 25, 2025 21:27
@phooijenga
Copy link
Contributor Author

Getting the claims also requires some changes in Fosite, for which I have created ory/fosite#844. I based it on v0.49.0 to avoid adding unnecessary changes in this MR, which now has a replace in the go.mod to demonstrate the tests passing.

I'm not sure the approach I took to make the claims available is the right one, and it should probably have a test.

@mitar
Copy link
Contributor

mitar commented Mar 6, 2025

I am curious, why do you need access to the assertion itself/claims in the hook?

@phooijenga
Copy link
Contributor Author

We want to validate/verify some of the claims in the assertion, and copy them to the access token.

@mitar
Copy link
Contributor

mitar commented Mar 8, 2025

But isn't everything in the assertion self-asserted? Client can put anything they want in there?

@phooijenga
Copy link
Contributor Author

Yes, we are aware :)

@aeneasr
Copy link
Member

aeneasr commented Mar 11, 2025

That's quite dangerous, I would say! Access tokens should only have trusted content

@mitar
Copy link
Contributor

mitar commented Mar 11, 2025

Maybe they have some out-of-band way of verifying content, like additional signatures and stuff. Or maybe it is non-critical stuff like first and last name they allow one just to pick arbitrary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants