Skip to main content

Decube Auth SDK for signup, login, and token refresh

Project description

Decube Auth SDK (Python)

The Decube Auth SDK is a lightweight Python client for interacting with the Decube authentication system through the Decube Gateway.

It provides a simple, ergonomic interface for:

  • User signup
  • User login
  • Refresh token rotation

The SDK is intentionally thin and stateless.


Installation

From PyPI:

pip install decube-auth

For local development:

pip install -e .

Quick Start

from decube_auth import AuthClient

auth = AuthClient(api_key="dc_live_xxx")

# Signup
tokens = auth.signup("user@example.com", "password123")

# Login
tokens = auth.login("user@example.com", "password123")

# Refresh access token
tokens = auth.refresh(tokens["refresh_token"])

Authentication Model

  • API key is used to authenticate the project
  • User credentials authenticate the user
  • Project context is enforced by the Gateway
  • Tokens returned are scoped to a single project
  • The SDK communicates only with the Gateway, never directly with backend services.

Public API

AuthClient

Initialization

AuthClient(api_key: str, base_url: str = DEFAULT_BASE_URL)

api_key (required): Project API key base_url (optional): Gateway base URL

signup(email, password)

Creates a new user scoped to the project.

tokens = auth.signup("user@example.com", "password123")

Returns:

{
  "access_token": "...",
  "refresh_token": "..."
}

login(email, password)

Authenticates an existing user.

tokens = auth.login("user@example.com", "password123")

Returns:

{
  "access_token": "...",
  "refresh_token": "..."
}

refresh(refresh_token)

Rotates the refresh token and returns a new token pair.

tokens = auth.refresh(refresh_token)

Returns:

{
  "access_token": "...",
  "refresh_token": "..."
}

Refresh tokens are:

  • Single-use
  • Rotated on every refresh
  • Invalid after use or expiry

Exceptions

  • The SDK raises clean, Python-level exceptions instead of exposing HTTP details.
  • Exception Meaning
  • AuthenticationError Invalid credentials or token
  • ConflictError Resource already exists (e.g. duplicate signup)
  • BadRequestError Invalid request payload
  • ServerError Unexpected server error

Example:

from decube_auth.exceptions import AuthenticationError

try:
    auth.login("a@b.com", "wrong-password")
except AuthenticationError:
    print("Invalid credentials")

Configuration

Base URL By default, the SDK connects to:

http://localhost:7000

Override using environment variable:

DECUBE_BASE_URL=http://your-gateway-host

Or directly in code:

auth = AuthClient(
    api_key="dc_live_xxx",
    base_url="https://api.decube.io"
)

What the SDK Does NOT Do

  • Store tokens
  • Auto-refresh tokens
  • Validate JWTs
  • Implement business logic
  • Manage sessions

These responsibilities belong to the client application.

Design Principles

  • Stateless
  • Explicit
  • Minimal surface area
  • No hidden behavior
  • Gateway-centric communication

Status

  • 🔒 Frozen at Checkpoint-2
  • Public API is locked
  • Behavior is stable
  • Backward compatibility guaranteed within version range

Summary

The Decube Auth SDK is a convenience layer, not a framework. It exists to make authentication with Decube:

  • Easy to integrate
  • Predictable
  • Explicit

If you understand HTTP, you understand this SDK.

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

decube_auth-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

decube_auth-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file decube_auth-0.1.0.tar.gz.

File metadata

  • Download URL: decube_auth-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for decube_auth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a93cc7b90e58203c69cec5be9ad6b8f22d0eb04ad43dfd1412f53e75100719aa
MD5 e8c9a31e4ebb70c21adb4046084a5f14
BLAKE2b-256 b316b3c6449ff75c1ee1ba7f48f6cc146173486ed2039e6170de412fa20bd776

See more details on using hashes here.

File details

Details for the file decube_auth-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: decube_auth-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for decube_auth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9789740e184a367c1da387e1d77e60d5fb089a906eb4dfc31962e3760882aa9
MD5 1710abda60df76f4996a0649076e71d3
BLAKE2b-256 9a3b4a35a858420eef98723d1c8de19ac49560ff37e1fe8e161bf8b4fc4d1a47

See more details on using hashes here.

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