Skip to main content

PostgreSQL-native authentication and authorization SDK

Project description

postkit

PostgreSQL-native authentication and authorization SDK.

Installation

pip install postkit

Usage

import psycopg
from postkit.authz import AuthzClient
from postkit.authn import AuthnClient

conn = psycopg.connect("postgresql://...")
cursor = conn.cursor()

# Authorization
authz = AuthzClient(cursor, namespace="my-app")
authz.grant("admin", resource=("repo", "api"), subject=("user", "alice"))
if authz.check("alice", "read", ("repo", "api")):
    print("Access granted")

# Authentication
authn = AuthnClient(cursor, namespace="my-app")
user_id = authn.create_user("alice@example.com", password_hash="argon2...")
session_id = authn.create_session(user_id, token_hash="sha256...")

Requirements

  • PostgreSQL 14+
  • The postkit SQL schema installed in your database

See the main repository for SQL installation instructions.

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

postkit-0.1.0.tar.gz (64.6 kB view details)

Uploaded Source

Built Distribution

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

postkit-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: postkit-0.1.0.tar.gz
  • Upload date:
  • Size: 64.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.16

File hashes

Hashes for postkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3950be462e7af597788da8bfb5699667bd50f82b1a3e65c8a6b99d42bab4ae3b
MD5 8a2e524c2b135593e23b527d4beeba39
BLAKE2b-256 9d20edab41fe838e79aa7a7ab3e3d565be5cc5f5a0a1958b62d513d4b4bb94dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: postkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.16

File hashes

Hashes for postkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f37d6906081b5d6c7e5d280c5d1220357cf7ddd8cb81bb4512165f0c885d2bd3
MD5 00fc9842d73538cbcf45f9835092cc54
BLAKE2b-256 332cbfcf3f9da9370655553cc7b1588538d11df911a0ec13516d530fd3912e26

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