Metadata-Version: 2.4
Name: postkit
Version: 0.1.0
Summary: PostgreSQL-native authentication and authorization SDK
Project-URL: Homepage, https://github.com/varunchopra/postkit
Project-URL: Repository, https://github.com/varunchopra/postkit
Author: Varun Chopra
License-Expression: Apache-2.0
Keywords: authentication,authorization,postgresql,rebac,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Security
Requires-Python: >=3.10
Requires-Dist: psycopg>=3.1.0
Provides-Extra: binary
Requires-Dist: psycopg[binary]>=3.1.0; extra == 'binary'
Provides-Extra: dev
Requires-Dist: psycopg[binary]>=3.1.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# postkit

PostgreSQL-native authentication and authorization SDK.

## Installation

```bash
pip install postkit
```

## Usage

```python
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](https://github.com/varunchopra/postkit) for SQL installation instructions.
