Skip to main content

gait-sdk

PyPI Python License: MIT

The official Python SDK for Gait, an identity and security platform. Drop it into a Django REST Framework or FastAPI service to verify who is calling you, using identities Gait issues. It never issues tokens, stores passwords, or makes authorization decisions.

Gait                authenticates   — who are you? (login, 2FA, sessions, signed tokens)
gait-sdk            verifies        — is this token genuine, and whose is it?
your application    authorizes      — what may this person do here?

How gait-sdk works: the browser logs in to Gait, sends a Bearer token to your app, gait-sdk verifies it locally with Gait's cached public keys, your code authorizes, and sensitive actions get a live session check

That boundary is the core design rule. The SDK hands your code a verified identity (subject, email, session, token id, issuer). Roles, organizations and permissions belong to your application. See Architecture.

What is Gait?

Gait is an identity and security service. It handles everything about who someone is:

  • sign-up and login;
  • two-factor authentication;
  • sessions, logout and "log out everywhere";
  • short-lived signed access tokens, and publishing the public keys that let other services check them.

Alongside that, it watches its own security posture (a security observatory with automated investigation).

Apps don't build login themselves. They send people to Gait, and gait-sdk lets their backend trust the result.

Availability: Gait currently serves its own first-party applications (starting with Lumen, a vascular-ultrasound reporting platform). Self-service onboarding for outside applications isn't open yet. You can still try gait-sdk end to end today with the local stand-in issuer in examples/.

New here? Start here

  1. Concepts: tokens, signatures, JWKS, revocation, 401 vs 403, in plain language.
  2. Examples: a FastAPI and a Django app you can run in five minutes, no account needed.
  3. Integration guide: wiring it into your own app.
  4. Something wrong? Troubleshooting lists the exact error messages.

Install

pip install "gait-sdk[django]"     # Django REST Framework services
pip install "gait-sdk[fastapi]"    # FastAPI services
pip install gait-sdk               # core only (verification, sessions, app identity)

Requires Python 3.10+. Pin exact versions in production (gait-sdk==0.5.0). See Supply chain.


Quick start: Django REST Framework

# settings.py
INSTALLED_APPS = [..., "gait_sdk"]          # validates configuration at startup

REST_FRAMEWORK = {
    "DEFAULT_AUTHENTICATION_CLASSES": ["gait_sdk.authentication.ExternalJWTAuthentication"],
}

GAIT_TOKEN_VERIFIER = "jwks"                 # verify locally (recommended)
GAIT_JWKS_URL = "https://auth.example.com/.well-known/jwks.json"
GAIT_ISSUER = "https://auth.example.com"
GAIT_AUDIENCE = "urn:gait:your-app"
GAIT_AUTH_URL = "https://auth.example.com/api"   # used for live session checks
# views.py
from gait_sdk.django.authentication import require_live_session

class FinalizeReport(APIView):
    def post(self, request, pk):
        identity = request.verified_identity    # subject, email, session_id, token_id, issuer
        ...                                     # YOUR authorization check first
        require_live_session(request)           # sensitive action: confirm the session live
        ...                                     # then mutate

Quick start: FastAPI

from fastapi import Depends, FastAPI
from gait_sdk.fastapi.dependencies import require_live_session, validate_configuration, verify_token

app = FastAPI()
validate_configuration()   # fail at startup, not on the first request

@app.get("/me")
async def me(claims: dict = Depends(verify_token)):
    return {"subject": claims["id"], "email": claims["email"]}   # "id" works in both verifier modes

@app.post("/danger")
async def danger(claims: dict = Depends(require_live_session)):
    ...

Configuration

Setting Default Purpose
GAIT_TOKEN_VERIFIER introspection jwks = verify tokens locally against Gait's published keys (recommended). introspection = ask Gait /whoami/ on every request (legacy). Chosen explicitly, with no automatic fallback.
GAIT_JWKS_URL — Required for jwks. Must be https (plain http only for localhost).
GAIT_ISSUER — Required for jwks. Must equal Gait's JWT_ISSUER exactly.
GAIT_AUDIENCE — Required for jwks. Must equal Gait's JWT_AUDIENCE.
GAIT_AUTH_URL — Gait's API base (…/api), used by live session checks, introspection, application identity and signals. https required (http only for localhost).
GAIT_TIMEOUT 5 Seconds for calls to Gait.
GAIT_APPLICATION_CREDENTIAL — Only for application identity / security signals. A secret: keep it in the environment.
GAIT_ALLOW_COOKIE_AUTH False Deprecated legacy cookie mode (introspection only). Leave off. See Security.

Settings come from Django settings first, then environment variables / .env. An invalid or incomplete configuration stops the service at startup.


What you get

Module For
gait_sdk.verification Token verification (JwksVerifier, IntrospectionVerifier) → VerifiedIdentity
gait_sdk.session check_session_live(): live revocation check for sensitive actions
gait_sdk.authentication / gait_sdk.django DRF authentication class, require_live_session(request)
gait_sdk.fastapi.dependencies verify_token, require_live_session, validate_configuration
gait_sdk.application Verify your service's own Gait credential (machine identity)
gait_sdk.context SecurityContext: human identity + application identity together
gait_sdk.security Send tenant security signals to Gait

Security, in one screen

  • RS256 only. alg=none, HS256 key-confusion and unknown algorithms are rejected. iss, aud, exp, iat, sub, sid, jti and token_use="access" are all required.
  • The SDK holds no secrets for verification. It only ever has Gait's public keys, so it cannot mint tokens even if compromised.
  • Fails closed: an invalid token → 401; Gait unreachable → 503. It never falls back to a weaker check.
  • Real 401s (not DRF's silent 403), so clients' refresh-on-401 logic works.
  • Revocation: local verification sees a revoked session only when its token expires (≤15 min). Protect sensitive actions with require_live_session.
  • No token, cookie or credential value is ever logged.

Full threat model, guarantees, limits and audit history: docs/SECURITY.md. To report a vulnerability, see the same file.


Upgrading from auth_integration

The package was renamed in 0.5.0. The old import name still works as a deprecated alias until 0.6.0, returning the same modules, so nothing breaks while you migrate:

  1. pip install gait-sdk (replacing the old git URL pin).
  2. Replace auth_integration with gait_sdk in imports, INSTALLED_APPS, and DRF settings strings.

Details: Integration guide.

Documentation

Concepts Tokens, signatures, JWKS, revocation, 401/403/503, explained for newcomers
Examples Runnable FastAPI + Django apps with a local stand-in issuer
Architecture The boundary, components, verification & caching, trust model
Integration guide Wiring into Django/FastAPI, JWKS cut-over runbook, sensitive actions, testing
Security Threat model, guarantees, known limits, hardening checklist, audit log, reporting
Troubleshooting Exact error messages, what they mean, and how to fix them
Publishing How releases reach PyPI (a step-by-step tutorial), and consuming safely
Changelog Version history
Module references gait_sdk/docs/

License

MIT, © Anthony Narine.

Release files for gait-sdk 0.5.1

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

Source distribution (sdist)

Source distribution for gait-sdk 0.5.1
File Size Uploaded
gait_sdk-0.5.1.tar.gz 74.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gait-sdk 0.5.1
File Interpreter ABI Platform
gait_sdk-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 124.6 kB

Release files / gait_sdk-0.5.1.tar.gz

Download URL gait_sdk-0.5.1.tar.gz
Size 74.4 kB
Tags Source
SHA-256 checksum
How to use checksums
34a2078cb2d11185d7c2a502bb5827c3de13f3a4a455e09e25fbdb3b92a8c8f9
BLAKE2b-256 checksum
How to use checksums
11040446fc4bcde9c2f441fce734b9d287f79e8d977db02f2919554974e8b6f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / gait_sdk-0.5.1-py3-none-any.whl

Download URL gait_sdk-0.5.1-py3-none-any.whl
Size 50.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f440d3e9eed039ab6fec447298aa0c48511f5d3e54733d338e43ce88452f1bc
BLAKE2b-256 checksum
How to use checksums
ec3311417bf21b805548ce58d38f5d278ff04d75284a5a7f02a1ca53b9d27a53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

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