#203: Add kid option for private key authentication - #231
Open
dorner wants to merge 1 commit into
Open
Conversation
Author
|
cc: @rmad17 @kishore7snehil (I'm assuming you guys are the maintainers?) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Adds support for the
kid(key ID) JWT header when authenticating with a private key(client assertion), so that a tenant with two registered credentials can be rotated
deterministically instead of relying on Auth0 picking the right key.
Public API
client_assertion_signing_key_idon the:auth0strategy. When set, it isemitted as the
kidheader of the client assertion JWT. When absent or blank, nokidheader is sent, just like now.
Classes and methods changed
OmniAuth::Auth0::JWTToken#initialize— new optional keyword argumentclient_assertion_signing_key_id:. Added as a keyword to avoid having too many positional arguments.OmniAuth::Auth0::JWTToken#jwt_headers— new private method returning the extra JWT headerparameters. Passed as the fourth argument to
JWT.encode.OmniAuth::Auth0::JWTToken— newclient_assertion_signing_key_idreader.OmniAuth::Strategies::Auth0#jwt_token— forwardsoptions.client_assertion_signing_key_id.No endpoints added, deleted, deprecated, or changed, no UI involved.
Usage
The value should be the key ID Auth0 assigned to the uploaded public key.
README.mdhas beenupdated in both the
config/auth0.ymland initializer examples.References
kidheader parameterTesting
The change is three lines of production code. All we care about is that the
kidactuallyreaches the wire.
Unit —
spec/omniauth/auth0/jwt_token_spec.rb: asserts the decoded header contains theconfigured
kidalongsidealg, and that the header has nokidkey at all when the option isomitted or set to
''.Integration —
spec/omniauth/strategies/auth0_spec.rb: two new contexts drive a fullcallback. One asserts the option is threaded through to
JWTToken; the other skips theJWTTokenstub entirely, decodes the realclient_assertionsent toPOST /oauth/token, andasserts its
kidheader. I confirmed bothkidassertions fail when the header logic isdisabled, so they are not vacuous.
To verify locally:
bundle exec rake spec138 examples, 0 failures (133 before this change).
Not tested: whether a live tenant accepts a given
kidvalue. I'll try to install locally and test this way.— tested on Ruby 3.2.2, the highest version in this project's CI matrix
(
.github/workflows/matrix.jsoncovers 3.0, 3.1, 3.2)Checklist
Note that rubocop shows 233 failures on my local using
bundle exec rubocop. Not sure why and I didn't want to touch any existing code.Code written by Claude but fully code reviewed and edited where necessary by myself. Same for the PR description.