postkit 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. postkit-0.1.0/.gitignore +24 -0
  2. postkit-0.1.0/PKG-INFO +66 -0
  3. postkit-0.1.0/README.md +38 -0
  4. postkit-0.1.0/pyproject.toml +41 -0
  5. postkit-0.1.0/src/postkit/__init__.py +9 -0
  6. postkit-0.1.0/src/postkit/authn/__init__.py +13 -0
  7. postkit-0.1.0/src/postkit/authn/client.py +567 -0
  8. postkit-0.1.0/src/postkit/authz/__init__.py +17 -0
  9. postkit-0.1.0/src/postkit/authz/client.py +913 -0
  10. postkit-0.1.0/tests/__init__.py +0 -0
  11. postkit-0.1.0/tests/authn/__init__.py +0 -0
  12. postkit-0.1.0/tests/authn/conftest.py +124 -0
  13. postkit-0.1.0/tests/authn/helpers.py +108 -0
  14. postkit-0.1.0/tests/authn/test_audit.py +212 -0
  15. postkit-0.1.0/tests/authn/test_credentials.py +78 -0
  16. postkit-0.1.0/tests/authn/test_lockout.py +124 -0
  17. postkit-0.1.0/tests/authn/test_maintenance.py +96 -0
  18. postkit-0.1.0/tests/authn/test_mfa.py +135 -0
  19. postkit-0.1.0/tests/authn/test_rls.py +79 -0
  20. postkit-0.1.0/tests/authn/test_sessions.py +186 -0
  21. postkit-0.1.0/tests/authn/test_tokens.py +125 -0
  22. postkit-0.1.0/tests/authn/test_users.py +244 -0
  23. postkit-0.1.0/tests/authn/test_validation.py +208 -0
  24. postkit-0.1.0/tests/authz/__init__.py +0 -0
  25. postkit-0.1.0/tests/authz/conftest.py +120 -0
  26. postkit-0.1.0/tests/authz/helpers.py +67 -0
  27. postkit-0.1.0/tests/authz/test_access_patterns.py +545 -0
  28. postkit-0.1.0/tests/authz/test_audit.py +626 -0
  29. postkit-0.1.0/tests/authz/test_concurrency.py +467 -0
  30. postkit-0.1.0/tests/authz/test_consistency.py +115 -0
  31. postkit-0.1.0/tests/authz/test_e2e_demo.py +189 -0
  32. postkit-0.1.0/tests/authz/test_expiration.py +430 -0
  33. postkit-0.1.0/tests/authz/test_groups.py +197 -0
  34. postkit-0.1.0/tests/authz/test_hierarchy.py +170 -0
  35. postkit-0.1.0/tests/authz/test_listing.py +139 -0
  36. postkit-0.1.0/tests/authz/test_maintenance.py +166 -0
  37. postkit-0.1.0/tests/authz/test_namespaces.py +73 -0
  38. postkit-0.1.0/tests/authz/test_nested_teams.py +382 -0
  39. postkit-0.1.0/tests/authz/test_resource_hierarchy.py +254 -0
  40. postkit-0.1.0/tests/authz/test_rls.py +230 -0
  41. postkit-0.1.0/tests/authz/test_sdk.py +178 -0
  42. postkit-0.1.0/tests/authz/test_stress.py +208 -0
  43. postkit-0.1.0/tests/authz/test_transactions.py +87 -0
  44. postkit-0.1.0/tests/authz/test_validation.py +297 -0
  45. postkit-0.1.0/tests/conftest.py +7 -0
  46. postkit-0.1.0/uv.lock +251 -0
@@ -0,0 +1,24 @@
1
+ # Build artifacts
2
+ dist/
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.pyc
7
+ *.egg-info/
8
+ .venv/
9
+ venv/
10
+ .pytest_cache/
11
+
12
+ # Node
13
+ node_modules/
14
+
15
+ # IDE
16
+ .idea/
17
+ .vscode/
18
+ *.swp
19
+
20
+ # OS
21
+ .DS_Store
22
+
23
+ # Test artifacts
24
+ *.log
postkit-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: postkit
3
+ Version: 0.1.0
4
+ Summary: PostgreSQL-native authentication and authorization SDK
5
+ Project-URL: Homepage, https://github.com/varunchopra/postkit
6
+ Project-URL: Repository, https://github.com/varunchopra/postkit
7
+ Author: Varun Chopra
8
+ License-Expression: Apache-2.0
9
+ Keywords: authentication,authorization,postgresql,rebac,sdk
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Database
19
+ Classifier: Topic :: Security
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: psycopg>=3.1.0
22
+ Provides-Extra: binary
23
+ Requires-Dist: psycopg[binary]>=3.1.0; extra == 'binary'
24
+ Provides-Extra: dev
25
+ Requires-Dist: psycopg[binary]>=3.1.0; extra == 'dev'
26
+ Requires-Dist: pytest>=7.0; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # postkit
30
+
31
+ PostgreSQL-native authentication and authorization SDK.
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install postkit
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```python
42
+ import psycopg
43
+ from postkit.authz import AuthzClient
44
+ from postkit.authn import AuthnClient
45
+
46
+ conn = psycopg.connect("postgresql://...")
47
+ cursor = conn.cursor()
48
+
49
+ # Authorization
50
+ authz = AuthzClient(cursor, namespace="my-app")
51
+ authz.grant("admin", resource=("repo", "api"), subject=("user", "alice"))
52
+ if authz.check("alice", "read", ("repo", "api")):
53
+ print("Access granted")
54
+
55
+ # Authentication
56
+ authn = AuthnClient(cursor, namespace="my-app")
57
+ user_id = authn.create_user("alice@example.com", password_hash="argon2...")
58
+ session_id = authn.create_session(user_id, token_hash="sha256...")
59
+ ```
60
+
61
+ ## Requirements
62
+
63
+ - PostgreSQL 14+
64
+ - The postkit SQL schema installed in your database
65
+
66
+ See the [main repository](https://github.com/varunchopra/postkit) for SQL installation instructions.
@@ -0,0 +1,38 @@
1
+ # postkit
2
+
3
+ PostgreSQL-native authentication and authorization SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install postkit
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ import psycopg
15
+ from postkit.authz import AuthzClient
16
+ from postkit.authn import AuthnClient
17
+
18
+ conn = psycopg.connect("postgresql://...")
19
+ cursor = conn.cursor()
20
+
21
+ # Authorization
22
+ authz = AuthzClient(cursor, namespace="my-app")
23
+ authz.grant("admin", resource=("repo", "api"), subject=("user", "alice"))
24
+ if authz.check("alice", "read", ("repo", "api")):
25
+ print("Access granted")
26
+
27
+ # Authentication
28
+ authn = AuthnClient(cursor, namespace="my-app")
29
+ user_id = authn.create_user("alice@example.com", password_hash="argon2...")
30
+ session_id = authn.create_session(user_id, token_hash="sha256...")
31
+ ```
32
+
33
+ ## Requirements
34
+
35
+ - PostgreSQL 14+
36
+ - The postkit SQL schema installed in your database
37
+
38
+ See the [main repository](https://github.com/varunchopra/postkit) for SQL installation instructions.
@@ -0,0 +1,41 @@
1
+ [project]
2
+ name = "postkit"
3
+ version = "0.1.0"
4
+ description = "PostgreSQL-native authentication and authorization SDK"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ requires-python = ">=3.10"
8
+ authors = [{ name = "Varun Chopra" }]
9
+ keywords = ["postgresql", "authentication", "authorization", "rebac", "sdk"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "License :: OSI Approved :: Apache Software License",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Topic :: Database",
20
+ "Topic :: Security",
21
+ ]
22
+ dependencies = ["psycopg>=3.1.0"]
23
+
24
+ [project.optional-dependencies]
25
+ binary = ["psycopg[binary]>=3.1.0"]
26
+ dev = ["pytest>=7.0", "psycopg[binary]>=3.1.0"]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/varunchopra/postkit"
30
+ Repository = "https://github.com/varunchopra/postkit"
31
+
32
+ [build-system]
33
+ requires = ["hatchling"]
34
+ build-backend = "hatchling.build"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/postkit"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+ python_files = ["test_*.py"]
@@ -0,0 +1,9 @@
1
+ """
2
+ postkit - PostgreSQL-native authentication and authorization SDK.
3
+
4
+ Usage:
5
+ from postkit.authz import AuthzClient
6
+ from postkit.authn import AuthnClient
7
+ """
8
+
9
+ __version__ = "0.1.0"
@@ -0,0 +1,13 @@
1
+ """postkit.authn - Authentication client for PostgreSQL-native auth."""
2
+
3
+ from postkit.authn.client import (
4
+ AuthnClient,
5
+ AuthnError,
6
+ AuthnValidationError,
7
+ )
8
+
9
+ __all__ = [
10
+ "AuthnClient",
11
+ "AuthnError",
12
+ "AuthnValidationError",
13
+ ]