-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add Custom Token Exchange support (RFC 8693) #51
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
Conversation
6c41684 to
2df8d4c
Compare
d2b6bfb to
5c58db4
Compare
f8c84d2 to
898fd85
Compare
Implements token exchange via Exchange Profiles for Auth0 API client. Features: - get_token_by_exchange_profile() method with HTTP Basic auth - Reserved parameter protection (case-insensitive) - DoS protection (array size limits) - Strict token validation (whitespace, Bearer prefix) - Type safety for extra params (str, sequences; rejects dict/set/bytes) - Comprehensive error handling (GetTokenByExchangeProfileError, ApiError) - Lenient expires_in parsing (coerces numeric strings) - Negative expires_in validation Testing: - 129 tests, 86% coverage - Shared test utilities in conftest.py - Table-driven validation tests - Cross-validated against auth0-auth-js Docs: - README with usage examples and Early Access warning - Related SDKs section - Error handling patterns Note: verify_request() now uses split(None, 1) for header parsing. Malformed headers with multiple spaces now raise VerifyAccessTokenError during JWT parsing instead of InvalidAuthSchemeError. Standard inputs unaffected.
898fd85 to
49e003e
Compare
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
1 similar comment
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Thanks. It's interesting because I did code reviews with both ChatGPT and Gemini and many of these were not flagged. Some of them are overly paranoid I think, but there are a few good ones in there as well. Will address. |
…ency - Add timeout configuration to get_access_token_for_connection for consistency - Improve Content-Type parsing with explicit comments for lenient JSON detection - Enhance unsupported type error messages to explain allowed types - Clarify case-insensitive Bearer prefix check in error message and docs - Fix docstring example to use async function context (avoid 'await outside async' warning) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
@kishore7snehil Updated per feedback. See PR description for details. |
kishore7snehil
left a comment
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.
I have tested the CTE flow with Auth0 Setup and the changes LGTM!
Custom Token Exchange Support (RFC 8693)
Adds Custom Token Exchange support (RFC 8693) for exchanging subject tokens via Auth0 Token Exchange Profiles for parity with auth0/auth0-auth-js#75.
Note
Early Access feature for Enterprise customers. Contact Auth0 support to enable.
API
Features
Testing
conftest.pyBehavioral Changes in
verify_request()Important
RFC 7230 Compliance Improvements
This PR improves
verify_request()HTTP header parsing to be fully RFC 7230 compliant:✅ What Improved (Zero Breaking Risk)
Header Case-Insensitivity: HTTP headers are now normalized to lowercase per RFC 7230
Authorization,authorization,AUTHORIZATIONall work correctlyDPoP,dpop,DPOPall work correctlyWhitespace Handling: Now uses
split(None, 1)per RFC 7230 Section 3.2Scenario: Malformed
Authorizationheader with spaces inside the token (e.g.,"Bearer token with spaces")InvalidAuthSchemeErrorat parsing stageVerifyAccessTokenErrorduring JWT validationBaseAuthError(parent class)Examples
Recent Improvements
Code Review Feedback (Latest Commit)
Based on automated PR review feedback, the following improvements were made:
✅ Timeout Consistency
get_access_token_for_connectionfor consistency withget_token_by_exchange_profileApiClientOptions.timeout(default: 10.0s)✅ Content-Type Parsing
application/jsonandtext/jsonContent-Type headers gracefully✅ Enhanced Error Messages
✅ Documentation Clarity
Related
Release Notes
Version Recommendation
Tip
Recommended: Minor version bump (e.g.,
1.1.0) for new public APIAlternative: If planning 1.0 GA, could ship as
1.0.0CHANGELOG Entries
Added
get_token_by_exchange_profile()method for exchanging subject tokens via Auth0 Token Exchange Profilestimeoutoption inApiClientOptions(default: 10.0s) for HTTP requestsGetTokenByExchangeProfileErrorfor token exchange validation errorsChanged
verify_request()improvements:split(None, 1)to correctly handle tabs and multiple spaces between scheme and tokenVerifyAccessTokenError(during JWT parsing) instead ofInvalidAuthSchemeError(at header parsing stage)BaseAuthErrorInvalidAuthSchemeErrorspecifically for this edge case, update to catchVerifyAccessTokenErrororBaseAuthErrorSecurity
Warning
Security improvements in this release:
extraparameters limited to 20 array values per keyDependency Changes
Note
python-versions = "^3.9"freezegun(dev dependency for deterministic time testing)CI/CD Notes
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com