-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add Private Key JWT support for client credentials in Management API #528
base: main
Are you sure you want to change the base?
Add Private Key JWT support for client credentials in Management API #528
Conversation
Hi @ErwinSteffens, I'll review the PR. Currently, we're exploring alternative ways to support this since the OAuth2 library doesn't provide this feature yet. However, if they add support in the future, we may reconsider our approach. I'll keep you updated on the next steps. Thanks for your contribution! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #528 +/- ##
==========================================
- Coverage 95.85% 95.82% -0.04%
==========================================
Files 59 60 +1
Lines 11540 11639 +99
==========================================
+ Hits 11062 11153 +91
- Misses 359 366 +7
- Partials 119 120 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hi @ErwinSteffens, I’ve pushed some test cases and a few changes — feel free to review and let me know if anything needs to be reverted or adjusted. I intended to open a PR, but it looks like the changes were pushed directly by mistake. Apologies for the mix-up! |
8584b44
to
636d182
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
internal/client/jwt_token_source.go:111
- [nitpick] Consider enhancing the error message to include a list of supported algorithms for clearer guidance, e.g., by appending the supported options to the message.
return "", fmt.Errorf("unsupported client assertion algorithm %q", alg)
🔧 Changes
This PR adds support for Client Credentials authentication using Private Key JWT for the Management API.
The
[golang.org/x/oauth2](https://pkg.go.dev/golang.org/x/oauth2)
package allows for customizingEndpointParams
in the client credentials flow, which enables the use of Private Key JWT without direct support from the library. By usingAuthStyleInParams
and omittingClientID
andClientSecret
, these parameters are excluded from the request, which aligns with how Private Key JWT should work.There is an open issue in
x/oauth2
for first-class support of this feature, but it hasn’t seen recent progress. This implementation provides a practical workaround while staying idiomatic to the existing Auth0 SDK design.If the approach looks good, I’ll follow up with test coverage.
✅ Usage Examples
🔐 Client credentials using Private Key JWT:
🔐 Private Key JWT with custom audience:
📚 References
🔬 Testing
To test manually:
Generate a key pair:
openssl genrsa -out private.pem 2048 openssl rsa -in private.pem -pubout > public.pub
Create an Auth0 Application using the "Machine to Machine" flow.
Configure Private Key JWT:
public.pub
as the client’s public key.Run the following test code (ensure
private.pem
is in the working directory):📝 Checklist