NexusID Python SDK — OIDC token validation, app_roles authorization, and Flask + Django integrations for the NexusID identity broker
Project description
NexusID Python SDK
Python client for applications protected by a NexusID identity broker. Validates OIDC ID tokens, exposes app_roles claims as idiomatic role checks, and ships drop-in middleware/decorators for Flask and Django.
Install
pip install nexusid # core: client + roles
pip install "nexusid[flask]" # + Flask decorators
pip install "nexusid[django]" # + Django middleware + decorators
pip install "nexusid[jwt]" # + RS256 JWT verification (PyJWT, cryptography)
pip install "nexusid[all]" # everything
Quick start — plain Python
from nexusid import NexusIDClient, NexusRole
client = NexusIDClient(
issuer="https://idp.example.com",
client_id="my-app",
client_secret="...", # omit for PKCE public clients
)
claims = client.verify_token(id_token)
role = NexusRole(claims.get("app_roles", []))
if role.has("Admin"):
...
Flask
from flask import Flask
from nexusid.flask.decorators import require_role
app = Flask(__name__)
@app.route("/admin")
@require_role("Admin")
def admin():
return "ok"
Django
# settings.py
MIDDLEWARE = [
...,
"nexusid.django.middleware.NexusIDMiddleware",
]
NEXUSID = {
"ISSUER": "https://idp.example.com",
"CLIENT_ID": "my-django-app",
}
# views.py
from nexusid.django.decorators import require_role
@require_role("Admin")
def admin_view(request):
...
API surface
NexusIDClient(issuer, client_id, client_secret=None)client.verify_token(id_token) -> dictNexusRole(roles: list[str])role.has(name),role.has_any([names]),role.has_all([names]),role.list()nexusid.flask.decorators.require_role(name)nexusid.django.middleware.NexusIDMiddlewarenexusid.django.decorators.require_role(name)
Status
v1.x — stable surface. Breaking changes will follow semver.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nexusid-1.0.0.tar.gz.
File metadata
- Download URL: nexusid-1.0.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51c70d0d294d508981f4e566ea8e3afdf2aa0f745f2c935a693d3b1743b4c974
|
|
| MD5 |
0199d70084f41bdb11a229db0be53e8e
|
|
| BLAKE2b-256 |
f0538a45135ce0323c1169941d3a8c01d9af0c3f3e3738ab111676673ce230ef
|
File details
Details for the file nexusid-1.0.0-py3-none-any.whl.
File metadata
- Download URL: nexusid-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a679b7776f47ea45ccb637becdb80176f8be43ecc046e7dc9c4f326006559c5
|
|
| MD5 |
3d33b6a01d440def32111c8648ed34e3
|
|
| BLAKE2b-256 |
79ea23c388e05f8170146c3fb1cffe9860408821ff5504ba9a746e4a31a1b66c
|