Skip to main content

Async Python SDK for validating Azure AD B2C access tokens

Project description

Azure AD B2C

Simplified Python SDK for verifying AD B2C-issued JWTs

Usage

import aad

token = "..." # JWT to verify
tenant = "..." # B2C tenant (as in `"{tenant}.b2clogin.com/{tenant}..."`)
app_id = "..." # ClientID of app registered in the B2C tenant
policy = "B2C_1_..." # policy (aka user flow) name

await aad.authorize(token, tenant, app_id, policy)
# {
#   "idp": "...",
#   "aud": "...",
#   ... # other JWT fields
#   ... # fields configured in B2C
# }

FastAPI dependency

pip install aad[fastapi]
from fastapi import FastAPI
import aad

Claims = aad.claims(tenant, app_id, policy)
app = FastAPI()

@app.get("...")
def get(claims: Claims):
    ...

Disclaimer

The JWT decoding part is heavily inspired by azure-ad-verify-token, but with an async interface

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aad-0.1.5.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

aad-0.1.5-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file aad-0.1.5.tar.gz.

File metadata

  • Download URL: aad-0.1.5.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for aad-0.1.5.tar.gz
Algorithm Hash digest
SHA256 5416780f2ac9ccd7972cce8c2c6a5e75e70df7aa0c983f30c8ea50b4bd028a83
MD5 b5b9a0f2bad3f2f69bdfccebebb9c5e4
BLAKE2b-256 25094bbe3cb1dd5d2527ab47830eb4d3eb9d307209da6ce088a534dfe0a5bf41

See more details on using hashes here.

File details

Details for the file aad-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: aad-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for aad-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7b7d831cb516f8e5c52ad9fe301737425bc1f980b8c12b08bd9bb4bcd6bd6ac6
MD5 a1c8d9e2b2cc812b71aa39d6cbf1b0f9
BLAKE2b-256 ade02495208fe6b9fbd05f178597d8aa29ed1a8fae459e8858679718ccc1b536

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page