phzyx-auth 0.1.0__py3-none-any.whl
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.
- phzyx/auth/__init__.py +141 -0
- phzyx/auth/adapters/__init__.py +19 -0
- phzyx/auth/adapters/fastapi.py +638 -0
- phzyx/auth/adapters/litestar.py +280 -0
- phzyx/auth/admin_bridge.py +83 -0
- phzyx/auth/api_keys.py +94 -0
- phzyx/auth/audit.py +36 -0
- phzyx/auth/cli.py +43 -0
- phzyx/auth/config.py +92 -0
- phzyx/auth/crypto.py +19 -0
- phzyx/auth/csrf.py +45 -0
- phzyx/auth/decorators.py +116 -0
- phzyx/auth/errors.py +64 -0
- phzyx/auth/guards.py +67 -0
- phzyx/auth/models.py +238 -0
- phzyx/auth/oauth.py +249 -0
- phzyx/auth/orm_stores.py +436 -0
- phzyx/auth/passkeys.py +351 -0
- phzyx/auth/password.py +56 -0
- phzyx/auth/principal.py +73 -0
- phzyx/auth/rate_limit.py +76 -0
- phzyx/auth/rbac.py +75 -0
- phzyx/auth/service.py +956 -0
- phzyx/auth/service_async.py +77 -0
- phzyx/auth/sessions.py +117 -0
- phzyx/auth/tokens.py +158 -0
- phzyx/auth/totp.py +105 -0
- phzyx_auth-0.1.0.dist-info/METADATA +116 -0
- phzyx_auth-0.1.0.dist-info/RECORD +31 -0
- phzyx_auth-0.1.0.dist-info/WHEEL +4 -0
- phzyx_auth-0.1.0.dist-info/entry_points.txt +2 -0
phzyx/auth/__init__.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""Phzyx Auth — identity, sessions, JWT, API keys, guards (batteries optional)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from phzyx.auth.admin_bridge import PhzyxAuthz, PhzyxFieldAuthz
|
|
8
|
+
from phzyx.auth.api_keys import IssuedAPIKey, MemoryAPIKeyStore
|
|
9
|
+
from phzyx.auth.audit import AuditLog
|
|
10
|
+
from phzyx.auth.config import AuthConfig
|
|
11
|
+
from phzyx.auth.decorators import (
|
|
12
|
+
require_auth,
|
|
13
|
+
require_permissions,
|
|
14
|
+
require_scopes,
|
|
15
|
+
require_staff,
|
|
16
|
+
require_superuser,
|
|
17
|
+
)
|
|
18
|
+
from phzyx.auth.errors import (
|
|
19
|
+
AuthError,
|
|
20
|
+
ForbiddenError,
|
|
21
|
+
InvalidCredentialsError,
|
|
22
|
+
LockedError,
|
|
23
|
+
MfaRequiredError,
|
|
24
|
+
UnauthorizedError,
|
|
25
|
+
ValidationAuthError,
|
|
26
|
+
)
|
|
27
|
+
from phzyx.auth.models import (
|
|
28
|
+
AUTH_MODELS,
|
|
29
|
+
AbstractUser,
|
|
30
|
+
Group,
|
|
31
|
+
MFAFactor,
|
|
32
|
+
OAuthAccount,
|
|
33
|
+
Permission,
|
|
34
|
+
User,
|
|
35
|
+
)
|
|
36
|
+
from phzyx.auth.oauth import (
|
|
37
|
+
AuthlibOAuthProvider,
|
|
38
|
+
OAuthNotConfiguredError,
|
|
39
|
+
OAuthProviderConfig,
|
|
40
|
+
StaticOAuthProvider,
|
|
41
|
+
build_provider,
|
|
42
|
+
preset_config,
|
|
43
|
+
)
|
|
44
|
+
from phzyx.auth.orm_stores import (
|
|
45
|
+
HybridUserMap,
|
|
46
|
+
OrmAPIKeyStore,
|
|
47
|
+
OrmPasswordResetStore,
|
|
48
|
+
OrmSessionStore,
|
|
49
|
+
OrmUserRepository,
|
|
50
|
+
)
|
|
51
|
+
from phzyx.auth.passkeys import HmacPasskeyBackend, default_passkey_backend, sign_hmac_assertion
|
|
52
|
+
from phzyx.auth.password import PasswordHasher, generate_token, hash_password, verify_password
|
|
53
|
+
from phzyx.auth.principal import Principal, principal_from_user
|
|
54
|
+
from phzyx.auth.rate_limit import MemoryRateLimiter, RedisRateLimiter
|
|
55
|
+
from phzyx.auth.rbac import has_permission, resolve_permissions, seed_resource_permissions
|
|
56
|
+
from phzyx.auth.service import AuthResult, AuthService, MfaChallenge
|
|
57
|
+
from phzyx.auth.service_async import AsyncAuthService
|
|
58
|
+
from phzyx.auth.sessions import MemorySessionStore
|
|
59
|
+
from phzyx.auth.tokens import JwtService, TokenPair
|
|
60
|
+
|
|
61
|
+
__version__ = "0.1.0"
|
|
62
|
+
|
|
63
|
+
__all__ = [
|
|
64
|
+
"AUTH_MODELS",
|
|
65
|
+
"AbstractUser",
|
|
66
|
+
"AsyncAuthService",
|
|
67
|
+
"AuditLog",
|
|
68
|
+
"AuthConfig",
|
|
69
|
+
"AuthError",
|
|
70
|
+
"AuthResult",
|
|
71
|
+
"AuthService",
|
|
72
|
+
"AuthlibOAuthProvider",
|
|
73
|
+
"ForbiddenError",
|
|
74
|
+
"Group",
|
|
75
|
+
"HmacPasskeyBackend",
|
|
76
|
+
"InvalidCredentialsError",
|
|
77
|
+
"IssuedAPIKey",
|
|
78
|
+
"JwtService",
|
|
79
|
+
"LockedError",
|
|
80
|
+
"HybridUserMap",
|
|
81
|
+
"MFAFactor",
|
|
82
|
+
"MemoryAPIKeyStore",
|
|
83
|
+
"MemoryRateLimiter",
|
|
84
|
+
"MemorySessionStore",
|
|
85
|
+
"MfaChallenge",
|
|
86
|
+
"MfaRequiredError",
|
|
87
|
+
"OAuthAccount",
|
|
88
|
+
"OAuthNotConfiguredError",
|
|
89
|
+
"OAuthProviderConfig",
|
|
90
|
+
"OrmAPIKeyStore",
|
|
91
|
+
"OrmPasswordResetStore",
|
|
92
|
+
"OrmSessionStore",
|
|
93
|
+
"OrmUserRepository",
|
|
94
|
+
"PasswordHasher",
|
|
95
|
+
"Permission",
|
|
96
|
+
"PhzyxAuthz",
|
|
97
|
+
"PhzyxFieldAuthz",
|
|
98
|
+
"Principal",
|
|
99
|
+
"RedisRateLimiter",
|
|
100
|
+
"StaticOAuthProvider",
|
|
101
|
+
"TokenPair",
|
|
102
|
+
"UnauthorizedError",
|
|
103
|
+
"User",
|
|
104
|
+
"ValidationAuthError",
|
|
105
|
+
"__version__",
|
|
106
|
+
"build_provider",
|
|
107
|
+
"create_superuser",
|
|
108
|
+
"default_passkey_backend",
|
|
109
|
+
"generate_token",
|
|
110
|
+
"has_permission",
|
|
111
|
+
"hash_password",
|
|
112
|
+
"mount_auth",
|
|
113
|
+
"mount_auth_litestar",
|
|
114
|
+
"preset_config",
|
|
115
|
+
"principal_from_user",
|
|
116
|
+
"require_auth",
|
|
117
|
+
"require_permissions",
|
|
118
|
+
"require_scopes",
|
|
119
|
+
"require_staff",
|
|
120
|
+
"require_superuser",
|
|
121
|
+
"resolve_permissions",
|
|
122
|
+
"sign_hmac_assertion",
|
|
123
|
+
"seed_resource_permissions",
|
|
124
|
+
"verify_password",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def __getattr__(name: str) -> Any:
|
|
129
|
+
if name == "mount_auth":
|
|
130
|
+
from phzyx.auth.adapters.fastapi import mount_auth
|
|
131
|
+
|
|
132
|
+
return mount_auth
|
|
133
|
+
if name == "mount_auth_litestar":
|
|
134
|
+
from phzyx.auth.adapters.litestar import mount_auth_litestar
|
|
135
|
+
|
|
136
|
+
return mount_auth_litestar
|
|
137
|
+
if name == "create_superuser":
|
|
138
|
+
from phzyx.auth.cli import create_superuser
|
|
139
|
+
|
|
140
|
+
return create_superuser
|
|
141
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Framework adapters (FastAPI, Litestar, …)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
__all__ = ["mount_auth", "mount_auth_litestar"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def __getattr__(name: str) -> Any:
|
|
11
|
+
if name == "mount_auth":
|
|
12
|
+
from phzyx.auth.adapters.fastapi import mount_auth
|
|
13
|
+
|
|
14
|
+
return mount_auth
|
|
15
|
+
if name == "mount_auth_litestar":
|
|
16
|
+
from phzyx.auth.adapters.litestar import mount_auth_litestar
|
|
17
|
+
|
|
18
|
+
return mount_auth_litestar
|
|
19
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|