Skip to content

chore: Resolves Issue #92, updates to use transitive dependency explicit - #134

Open
blochs wants to merge 16 commits into
auth0:mainfrom
blochs:deprecated-lib-warning
Open

blochs wants to merge 16 commits into
auth0:mainfrom
blochs:deprecated-lib-warning

Conversation

@blochs

@blochs blochs commented Sep 29, 2026 •

Copy link
Copy Markdown

Changes

Replaced deprecated authlib.jose usage with joserfc across all supported Python versions (3.10+) and removed the unused authlib dependency.

This eliminates the AuthlibDeprecationWarning emitted by Authlib 1.7+ while preserving existing JWT, JWK, and DPoP verification behavior.

Additional changes:

  • Declared joserfc>=1.7.6,<2.0 directly in pyproject.toml / requirements.txt and refreshed poetry.lock; dropped authlib since nothing in src/ imports it after Python 3.9 support was removed in chore!: drop Python 3.9 support #159.
  • Added configurable jwt_algorithms to ApiClientOptions, defaulting to ["RS256"] (copies caller list; allows only RS*, PS*, ES*; rejects none, HS*, and unrecognized algorithms at construction).
  • Normalized decoded access-token and DPoP claims to plain dicts and wrapped malformed JWKS keys / non-object payloads into SDK verification errors.
  • DPoP verification remains restricted to ES256.
  • Updated token_utils.py (generate_token supports algorithm= with algorithms=[algorithm]; generate_dpop_proof signs header_overrides cleanly via JWSRegistry).
  • Documented jwt_algorithms and joserfc validation behavior in README.md and CHANGELOG.md.

Example:

ApiClientOptions(
    domain="example.us.auth0.com",
    audience="my-api",
    jwt_algorithms=["RS256", "RS384"],
)

References

Testing

  • This change adds unit test coverage
  • This change adds integration test coverage
  • Tested on Python 3.13.7 (pytest: 528 passed; ruff check .: 0 errors; poetry check: clean; python -W error -c "from auth0_api_python.api_client import ApiClient": no warnings, authlib not imported)

Checklist

@blochs
blochs requested a review from a team as a code owner September 29, 2026 12:46
…explicit

and removes the deprecation warning for the authlib.jose library.Signed
@blochs
blochs force-pushed the deprecated-lib-warning branch from 064981e to ff4c63f Compare September 29, 2026 12:52
@blochs

blochs commented Oct 29, 2026

Copy link
Copy Markdown
Author

@kishore7snehil Can we get a review of this please? it's an irritating warning...

@kishore7snehil

Copy link
Copy Markdown
Contributor

@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.
@blochs

blochs commented Oct 29, 2026

Copy link
Copy Markdown
Author

@blochs Can you please resolve the conflicts so I can take a look?

Done - there weren't any conflicts when I put this up...

@kishore7snehil

Copy link
Copy Markdown
Contributor

@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.
@blochs

blochs commented Oct 29, 2026

Copy link
Copy Markdown
Author

@blochs UTs are failing. Can you please check?

It's 3.9 as the issue, which I'm pretty sure is EOL.

Comment thread src/auth0_api_python/api_client.py Resolved
Comment thread src/auth0_api_python/api_client.py Resolved
Comment thread src/auth0_api_python/api_client.py Resolved
Comment thread src/auth0_api_python/api_client.py Resolved
Comment thread tests/test_api_client.py Resolved
Comment thread src/auth0_api_python/token_utils.py Resolved
Comment thread src/auth0_api_python/token_utils.py Resolved
Comment thread src/auth0_api_python/config.py Resolved
Comment thread src/auth0_api_python/api_client.py Resolved
Comment thread tests/test_api_client.py Resolved
@kishore7snehil

kishore7snehil commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

@blochs Reviewed the changes and added few comments. PTAL!

@kishore7snehil

Copy link
Copy Markdown
Contributor

@blochs Are you working on this PR?

Comment thread src/auth0_api_python/token_utils.py Resolved
Comment thread src/auth0_api_python/api_client.py Resolved
Comment thread src/auth0_api_python/api_client.py Resolved
# 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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pyproject.toml Resolved
Comment thread README.md Resolved
Comment thread CHANGELOG.md Resolved
Comment thread src/auth0_api_python/token_utils.py Resolved
Comment thread src/auth0_api_python/api_client.py Resolved
@blochs

blochs commented Nov 21, 2026

Copy link
Copy Markdown
Author

@kishore7snehil Thanks for the thorough review! Addressed your comments in bf1acef:

  • Merged auth0/main (post-chore!: drop Python 3.9 support #159) and removed _internal/jose_compat.py plus all Python 3.9 / USE_LEGACY_JOSE branches across api_client.py, token_utils.py, tests/test_api_client.py, README.md, and CHANGELOG.md.
  • Dropped the unused authlib dependency from pyproject.toml and requirements.txt, declared joserfc>=1.6.8,<2.0 unconditionally, and regenerated poetry.lock.
  • Fixed generate_token to pass algorithms=[algorithm] to jwt.encode so RS384 (and other configured algorithms) work with joserfc.
  • Updated generate_dpop_proof to sign header_overrides into the proof via JWSRegistry (only when header_overrides is provided) rather than mutating the header post-signing, and added a regression test verifying the signature stays valid.
  • Kept the explicit key_alg != alg check in api_client.py for the shorter SDK error message (left that thread open in case you'd prefer dropping it).

Verified locally: pytest (528 passed), ruff check . (clean), poetry check (clean), and python -W error import check confirms zero warnings and no authlib import. PTAL!

Comment thread requirements.txt Outdated
# Source of truth for dependencies: pyproject.toml + poetry.lock

authlib>=1.6.12
joserfc>=1.6.8,<2.0

@semgrepcode-auth0 semgrepcode-auth0 Bot Nov 21, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 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 🚀

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecated library warning (AuthlibDeprecationWarning: authlib.jose module is deprecated)

2 participants