Official Stackure authentication SDK for Python
Project description
Stackure Python SDK
Authentication for your app. One decorator.
Install
pip install stackure
Requires Python 3.10+.
Protect a route
from stackure import auth
@app.get("/admin")
@auth(app_id="my-app-id", roles=["admin"])
async def admin(request):
return {"user": request.user}
Works with FastAPI, Starlette, Django, Flask, aiohttp — cookies extracted automatically from the request object.
Verify manually
from stackure import verify
result = await verify(app_id="my-app-id", cookies=dict(request.cookies))
if not result.authenticated:
return {"error": result.error["message"]}, result.error["code"]
return {"user": result.user}
Send a magic link
from stackure import send_magic_link
await send_magic_link(email="user@example.com", app_id="my-app-id")
Log out
from stackure import logout
await logout(dict(request.cookies))
Configuration
Set STACKURE_BASE_URL to point at a non-production environment:
STACKURE_BASE_URL=https://stage.stackure.com python app.py
Errors
All errors are StackureError. Switch on .code:
from stackure import StackureError
try:
await send_magic_link(email=email)
except StackureError as err:
# err.code is one of: "validation" | "auth" | "forbidden" | "timeout" | "network"
...
Contributing
Open a PR. Tag a release when ready: git tag vX.Y.Z && git push --tags — the release workflow builds, signs, and publishes.
Security
Report vulnerabilities via GitHub Security Advisories. Releases publish to PyPI via OIDC trusted publishing with GitHub build-provenance attestations.
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 stackure-1.0.0.tar.gz.
File metadata
- Download URL: stackure-1.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb9743e38a6489b6c7e8c9a0fa4363313c36daf364dcb2981dd7a7509d30d052
|
|
| MD5 |
96c73ee4b69c4dec3e05f6dfc0f79234
|
|
| BLAKE2b-256 |
9f9c057c6039cc2228bd4510828f962aa1ccf6b25af02997605307358b87dd24
|
Provenance
The following attestation bundles were made for stackure-1.0.0.tar.gz:
Publisher:
release.yml on syi-stackure/sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stackure-1.0.0.tar.gz -
Subject digest:
fb9743e38a6489b6c7e8c9a0fa4363313c36daf364dcb2981dd7a7509d30d052 - Sigstore transparency entry: 1327316756
- Sigstore integration time:
-
Permalink:
syi-stackure/sdk-py@c534aa208bbe92040892ad980810b488becde2f0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/syi-stackure
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c534aa208bbe92040892ad980810b488becde2f0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file stackure-1.0.0-py3-none-any.whl.
File metadata
- Download URL: stackure-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccff7364677d1049815e2fc9b1591bd076b3c0a316ce653fee1717b65b23ecc4
|
|
| MD5 |
6cd36b3748be5cd73cb5e34f3ba3c1a9
|
|
| BLAKE2b-256 |
24eb9546608ca49fffbcfa16913ba1c2724ef4dc0f59caf36dafd84d0e8e9d14
|
Provenance
The following attestation bundles were made for stackure-1.0.0-py3-none-any.whl:
Publisher:
release.yml on syi-stackure/sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stackure-1.0.0-py3-none-any.whl -
Subject digest:
ccff7364677d1049815e2fc9b1591bd076b3c0a316ce653fee1717b65b23ecc4 - Sigstore transparency entry: 1327317220
- Sigstore integration time:
-
Permalink:
syi-stackure/sdk-py@c534aa208bbe92040892ad980810b488becde2f0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/syi-stackure
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c534aa208bbe92040892ad980810b488becde2f0 -
Trigger Event:
push
-
Statement type: