Skip to main content

Official Stackure authentication SDK for Python

Project description

Stackure Python SDK

Check build PyPI version Python versions PyPI - Downloads Trusted publisher License: MIT

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


Download files

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

Source Distribution

stackure-1.20260417.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stackure-1.20260417.3-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file stackure-1.20260417.3.tar.gz.

File metadata

  • Download URL: stackure-1.20260417.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stackure-1.20260417.3.tar.gz
Algorithm Hash digest
SHA256 1e2b2c759df6c62342ca4252f32a3cde767eb0f795dee2a27341e6331cbe6f4c
MD5 e0165741d8a8d699f9b7e5ece191586d
BLAKE2b-256 e104ee7ae0eaf1459021c76ec0ae272824f11a403dce37e4020b942a7f5e0297

See more details on using hashes here.

Provenance

The following attestation bundles were made for stackure-1.20260417.3.tar.gz:

Publisher: release.yml on syi-stackure/sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stackure-1.20260417.3-py3-none-any.whl.

File metadata

  • Download URL: stackure-1.20260417.3-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stackure-1.20260417.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b89fad0d3216a9fd69051ff6618bbb20d1d8216f470e24a652e615f235230ec2
MD5 08d118d6006a534672ff71fb960c22e8
BLAKE2b-256 b1f1c00d0963d303050edb1d037c6ecdedf8f50b0e59dae5ebbbe1766fef0a51

See more details on using hashes here.

Provenance

The following attestation bundles were made for stackure-1.20260417.3-py3-none-any.whl:

Publisher: release.yml on syi-stackure/sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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