Repository navigation
Conversation
…explicit and removes the deprecation warning for the authlib.jose library.Signed
064981e to
ff4c63f
Compare
|
@kishore7snehil Can we get a review of this please? it's an irritating warning... |
|
@blochs Can you please resolve the conflicts so I can take a look? |
Preserve upstream token exchange, organization policy, security validations, and test coverage while retaining JWT algorithm configuration, joserfc access-token and DPoP verification, and matching regression coverage.
Done - there weren't any conflicts when I put this up... |
|
@blochs UTs are failing. Can you please check? |
Use Authlib 1.6 JOSE on Python 3.9, where joserfc 1.7+ is not available through Authlib. Keep the non-deprecated joserfc JWT/JWK implementation on Python 3.10+ and preserve algorithm restrictions. Fixes PR auth0#134 Build and Test import failure on Python 3.9.
It's 3.9 as the issue, which I'm pretty sure is EOL. |
|
@blochs Reviewed the changes and added few comments. PTAL! |
|
@blochs Are you working on this PR? |
| # Respect the key's declared algorithm on both JOSE backends. | ||
| # A JWKS key for RS256 must not silently verify an RS384 token. | ||
| key_alg = matching_key_dict.get("alg") | ||
| if key_alg is not None and key_alg != alg: |
There was a problem hiding this comment.
Once 3.9 is dropped this check isn't needed, because joserfc already rejects a token whose alg differs from the key's alg (with unsupported_key_alg). It only changes the outcome on the Authlib path. We can keep it if we prefer the shorter SDK message, WDYT?
There was a problem hiding this comment.
Kept this check for now since the SDK message (JWT algorithm does not match JWKS key algorithm) is clearer than joserfcs unsupported_key_alg, and removed the 3.9 comment. Happy to drop it if you prefer.
…erfc test helpers
|
@kishore7snehil Thanks for the thorough review! Addressed your comments in
Verified locally: |
| # Source of truth for dependencies: pyproject.toml + poetry.lock | ||
|
|
||
| authlib>=1.6.12 | ||
| joserfc>=1.6.8,<2.0 |
There was a problem hiding this comment.
🟠 High severity issue identified in your code:
Risk: Affected versions of joserfc are vulnerable to Uncontrolled Resource Consumption. joserfc is vulnerable to CPU exhaustion DoS: joserfc.jwe.decrypt_json() accepts a JWE General JSON Serialization with an unbounded recipients array and performs one private-key decryption (e.g. RSA-OAEP) per recipient, even when verify_all_recipients is disabled, so an unauthenticated attacker can force many expensive private-key operations with a small request.
Fix: Upgrade this library to at least version 1.7.5 at auth0-api-python/requirements.txt:4.
Reference(s): https://euvd.enisa.europa.eu/vulnerability/EUVD-2026-113392, GHSA-jpxq-7h8p-2q76, CVE-2026-119283
🚀 Fixed in commit 2af9a4e 🚀
Changes
Replaced deprecated
authlib.joseusage withjoserfcacross all supported Python versions (3.10+) and removed the unusedauthlibdependency.This eliminates the
AuthlibDeprecationWarningemitted by Authlib 1.7+ while preserving existing JWT, JWK, and DPoP verification behavior.Additional changes:
joserfc>=1.7.6,<2.0directly inpyproject.toml/requirements.txtand refreshedpoetry.lock; droppedauthlibsince nothing insrc/imports it after Python 3.9 support was removed in chore!: drop Python 3.9 support #159.jwt_algorithmstoApiClientOptions, defaulting to["RS256"](copies caller list; allows onlyRS*,PS*,ES*; rejectsnone,HS*, and unrecognized algorithms at construction).dicts and wrapped malformed JWKS keys / non-object payloads into SDK verification errors.ES256.token_utils.py(generate_tokensupportsalgorithm=withalgorithms=[algorithm];generate_dpop_proofsignsheader_overridescleanly viaJWSRegistry).jwt_algorithmsandjoserfcvalidation behavior inREADME.mdandCHANGELOG.md.Example:
References
Testing
pytest: 528 passed;ruff check .: 0 errors;poetry check: clean;python -W error -c "from auth0_api_python.api_client import ApiClient": no warnings,authlibnot imported)Checklist