fix: honor kid and other credential fields on private_key_jwt/mTLS credential creation - #1489
Draft
harshithRai wants to merge 3 commits into
Draft
fix: honor kid and other credential fields on private_key_jwt/mTLS credential creation#1489harshithRai wants to merge 3 commits into
harshithRai wants to merge 3 commits into
Conversation
…t/mTLS credential creation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1489 +/- ##
=======================================
Coverage 80.54% 80.54%
=======================================
Files 166 166
Lines 7920 7922 +2
Branches 1771 1771
=======================================
+ Hits 6379 6381 +2
Misses 829 829
Partials 712 712 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…t/mTLS credential creation
…t/mTLS credential creation
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
When deploying a Private Key JWT client credential from a tenant config, the
clientAuthCredentialshandler only forwardedname,pem, andcredential_typeto thePOST /clients/{id}/credentialsAPI. Any other field the user set in the config, most notablykid, was silently dropped, so Auth0 auto-generated akidinstead of using the one specified. This resolves #1466.The handler now forwards the full set of API-accepted optional fields on
public_keycredential creation:kid,alg,expires_at, andparse_expiry_from_cert. Fields left unset are omitted from the payload (filtered on!= null, which dropsnullandundefinedbut preserves an explicitfalsesuch asparse_expiry_from_cert: false) to avoid sending nulls the API rejects. The forwarded set matches thepublic_key(PublicKeyCredential) create model in the SDK.Scope is deliberately narrow: only the create path changed. Credential matching remains keyed on
name, export shape is unchanged (Auth0 returns onlynameandcredential_typeon read, sokid/pemare never exported), and the "nopemmeans skip" safeguard that makes export then deploy non-destructive is untouched.Shape
The credentials block accepts additional optional fields on creation. No existing field is renamed or removed.
YAML, before:
YAML, after:
Directory mode (client JSON), before:
{ "name": "My API Client", "client_authentication_methods": { "private_key_jwt": { "credentials": [ { "name": "my-key-v2", "credential_type": "public_key", "pem": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----\n" } ] } } }Directory mode (client JSON), after:
{ "name": "My API Client", "client_authentication_methods": { "private_key_jwt": { "credentials": [ { "name": "my-key-v2", "credential_type": "public_key", "kid": "my-custom-kid", "alg": "RS256", "pem": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----\n" } ] } } }📚 References
🔬 Testing
Unit: added a handler test asserting
kidandalgare forwarded, that an explicitparse_expiry_from_cert: falseis sent, and that null/undefined optional fields are omitted from the create payload. Full suite passes (1481 passing, 0 failing).Manual, against a live dev tenant, in both YAML and directory formats:
private_key_jwtcredential with a customkidand a public-keypemto a client config.CREATEis previewed with no handler crash.GET /clients/{id}/credentialsand confirm the credential'skidequals the configured value (previously it was a random auto-generated value).pemin an export means skip).📝 Checklist