Skip to content
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

[SDK-3714] Async token verifier #445

Merged
merged 4 commits into from
Oct 17, 2022
Merged

[SDK-3714] Async token verifier #445

merged 4 commits into from
Oct 17, 2022

Conversation

adamjmcgrath
Copy link
Contributor

@adamjmcgrath adamjmcgrath commented Oct 13, 2022

Changes

Asyncify the last blocking http calls (JWKS fetching)

from auth0.v3.authentication.async_token_verifier import import (
    AsyncAsymmetricSignatureVerifier,
    AsyncJwksFetcher,
    AsyncTokenVerifier,
)
domain = 'myaccount.auth0.com'
client_id = 'exampleid'

# After authenticating
id_token = auth_result['id_token']

jwks_url = 'https://{}/.well-known/jwks.json'.format(domain)
issuer = 'https://{}/'.format(domain)

sv = AsyncAsymmetricSignatureVerifier(jwks_url)  # Reusable instance
tv = AsyncTokenVerifier(signature_verifier=sv, issuer=issuer, audience=client_id)
tv.set_session(some_client_session) # to share an http session
await tv.verify(id_token)

# low level
fetcher = AsyncJwksFetcher(jwks_url)
fetcher.set_session(some_client_session) # to share an http session
public_key = await fetcher.get_key("id1")

References

resolves #432

Testing

  • This change adds unit test coverage
  • This change adds integration test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

@adamjmcgrath adamjmcgrath added the review:medium Medium review label Oct 13, 2022
@adamjmcgrath adamjmcgrath requested a review from a team as a code owner October 13, 2022 10:55
@adamjmcgrath adamjmcgrath merged commit 29e3358 into master Oct 17, 2022
@adamjmcgrath adamjmcgrath deleted the async-token-verifier branch October 17, 2022 13:32
@adamjmcgrath adamjmcgrath mentioned this pull request Oct 17, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
review:medium Medium review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AsyncIO - Add asyncio support to JwksFetcher
2 participants