Skip to main content

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) -> dict
  • NexusRole(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.NexusIDMiddleware
  • nexusid.django.decorators.require_role(name)

Status

v1.x — stable surface. Breaking changes will follow semver.

License

MIT

Metadata

Release files for nexusid 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nexusid 1.0.0
File Size Uploaded Provenance Actions
nexusid-1.0.0.tar.gz 7.8 kB Without provenance Details for nexusid-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nexusid 1.0.0
File Interpreter ABI Platform Actions
nexusid-1.0.0-py3-none-any.whl Python 3 none any Details for nexusid-1.0.0-py3-none-any.whl

Total release size: 16.1 kB

Release files / nexusid-1.0.0.tar.gz

Download URL nexusid-1.0.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
51c70d0d294d508981f4e566ea8e3afdf2aa0f745f2c935a693d3b1743b4c974
BLAKE2b-256 checksum
How to use checksums
f0538a45135ce0323c1169941d3a8c01d9af0c3f3e3738ab111676673ce230ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.0

Release files / nexusid-1.0.0-py3-none-any.whl

Download URL nexusid-1.0.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a679b7776f47ea45ccb637becdb80176f8be43ecc046e7dc9c4f326006559c5
BLAKE2b-256 checksum
How to use checksums
79ea23c388e05f8170146c3fb1cffe9860408821ff5504ba9a746e4a31a1b66c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.0

Security for nexusid 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page