litestar-security 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.
- litestar_security/__init__.py +194 -0
- litestar_security/__metadata__.py +12 -0
- litestar_security/_cli.py +28 -0
- litestar_security/_openapi.py +557 -0
- litestar_security/accounts/__init__.py +353 -0
- litestar_security/accounts/_access_tokens.py +315 -0
- litestar_security/accounts/_controllers.py +739 -0
- litestar_security/accounts/_internal.py +108 -0
- litestar_security/accounts/_login.py +316 -0
- litestar_security/accounts/_mfa.py +1045 -0
- litestar_security/accounts/_mfa_controllers.py +669 -0
- litestar_security/accounts/_mfa_schemas.py +166 -0
- litestar_security/accounts/_operations.py +120 -0
- litestar_security/accounts/_passkeys.py +1047 -0
- litestar_security/accounts/_passwords.py +469 -0
- litestar_security/accounts/_profiles.py +936 -0
- litestar_security/accounts/_purpose_tokens.py +410 -0
- litestar_security/accounts/_rate_limits.py +493 -0
- litestar_security/accounts/_receipts.py +306 -0
- litestar_security/accounts/_records.py +423 -0
- litestar_security/accounts/_recovery.py +633 -0
- litestar_security/accounts/_refresh.py +820 -0
- litestar_security/accounts/_refresh_tokens.py +325 -0
- litestar_security/accounts/_registration.py +321 -0
- litestar_security/accounts/_schemas.py +131 -0
- litestar_security/accounts/_sessions.py +1196 -0
- litestar_security/accounts/_stores.py +396 -0
- litestar_security/authentication.py +1134 -0
- litestar_security/config.py +368 -0
- litestar_security/context.py +472 -0
- litestar_security/guards.py +496 -0
- litestar_security/headers.py +276 -0
- litestar_security/plugin.py +676 -0
- litestar_security/providers/__init__.py +142 -0
- litestar_security/providers/_internal.py +59 -0
- litestar_security/providers/api_key/__init__.py +27 -0
- litestar_security/providers/api_key/_api_key.py +601 -0
- litestar_security/providers/api_key/_runtime.py +315 -0
- litestar_security/providers/iap/__init__.py +5 -0
- litestar_security/providers/iap/_iap.py +223 -0
- litestar_security/providers/jwks/__init__.py +27 -0
- litestar_security/providers/jwks/_cache.py +127 -0
- litestar_security/providers/jwks/_documents.py +97 -0
- litestar_security/providers/jwks/_fetching.py +187 -0
- litestar_security/providers/jwks/_internal.py +69 -0
- litestar_security/providers/jwks/_provider.py +457 -0
- litestar_security/providers/jwt/__init__.py +49 -0
- litestar_security/providers/jwt/_bearer.py +297 -0
- litestar_security/providers/jwt/_claims.py +418 -0
- litestar_security/providers/jwt/_internal.py +146 -0
- litestar_security/providers/jwt/_keyring.py +380 -0
- litestar_security/providers/jwt/_keys.py +294 -0
- litestar_security/providers/jwt/_signing.py +100 -0
- litestar_security/providers/jwt/_verification.py +294 -0
- litestar_security/providers/jwt/_workers.py +66 -0
- litestar_security/providers/oauth/__init__.py +151 -0
- litestar_security/providers/oauth/_accounts.py +709 -0
- litestar_security/providers/oauth/_local.py +105 -0
- litestar_security/providers/oauth/_provider.py +988 -0
- litestar_security/providers/oauth/_routes.py +848 -0
- litestar_security/providers/oauth/_transactions.py +740 -0
- litestar_security/providers/oidc/__init__.py +28 -0
- litestar_security/providers/oidc/_discovery.py +345 -0
- litestar_security/providers/oidc/_internal.py +36 -0
- litestar_security/providers/oidc/_keycloak.py +126 -0
- litestar_security/providers/oidc/_logout.py +65 -0
- litestar_security/providers/oidc/_provider.py +398 -0
- litestar_security/providers/oidc/_service.py +192 -0
- litestar_security/providers/oidc/_urls.py +85 -0
- litestar_security/py.typed +0 -0
- litestar_security/testing.py +953 -0
- litestar_security/websocket.py +841 -0
- litestar_security-0.1.0.dist-info/METADATA +109 -0
- litestar_security-0.1.0.dist-info/RECORD +77 -0
- litestar_security-0.1.0.dist-info/WHEEL +4 -0
- litestar_security-0.1.0.dist-info/entry_points.txt +2 -0
- litestar_security-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""Public package exports for Litestar Security."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any
|
|
4
|
+
|
|
5
|
+
from litestar_security.__metadata__ import __project__, __version__
|
|
6
|
+
from litestar_security.authentication import (
|
|
7
|
+
Authenticated,
|
|
8
|
+
AuthenticationMechanism,
|
|
9
|
+
AuthenticationOutcome,
|
|
10
|
+
AuthenticationPolicy,
|
|
11
|
+
AuthenticationRegistry,
|
|
12
|
+
AuthorizationResolver,
|
|
13
|
+
CredentialExtraction,
|
|
14
|
+
CredentialSlot,
|
|
15
|
+
IdentityResolution,
|
|
16
|
+
IdentityResolver,
|
|
17
|
+
InvalidCredentials,
|
|
18
|
+
MechanismRequirement,
|
|
19
|
+
NoCredentials,
|
|
20
|
+
PresentedCredential,
|
|
21
|
+
RequestAuthenticator,
|
|
22
|
+
VerificationUnavailable,
|
|
23
|
+
all_of,
|
|
24
|
+
any_of,
|
|
25
|
+
at_least,
|
|
26
|
+
mechanism,
|
|
27
|
+
optional,
|
|
28
|
+
public,
|
|
29
|
+
required,
|
|
30
|
+
)
|
|
31
|
+
from litestar_security.config import BlockingIntegration, ExternalCSRF, MFAConfig, PasskeyConfig, SecurityConfig
|
|
32
|
+
from litestar_security.context import (
|
|
33
|
+
AuthenticationEvidence,
|
|
34
|
+
AuthorizationSnapshot,
|
|
35
|
+
CredentialRestrictions,
|
|
36
|
+
LitestarSessionHandle,
|
|
37
|
+
NullSessionHandle,
|
|
38
|
+
Principal,
|
|
39
|
+
ResourcePermission,
|
|
40
|
+
SecurityContext,
|
|
41
|
+
SessionHandle,
|
|
42
|
+
SessionPersistenceUnavailableError,
|
|
43
|
+
SessionUnavailableError,
|
|
44
|
+
intersect_authorization,
|
|
45
|
+
)
|
|
46
|
+
from litestar_security.guards import (
|
|
47
|
+
AssuranceRequirement,
|
|
48
|
+
AssuranceTrait,
|
|
49
|
+
AuthorizationDecision,
|
|
50
|
+
AuthorizationPredicate,
|
|
51
|
+
requires_assurance,
|
|
52
|
+
requires_authenticated,
|
|
53
|
+
requires_capability,
|
|
54
|
+
requires_role,
|
|
55
|
+
requires_scope,
|
|
56
|
+
requires_team_role,
|
|
57
|
+
requires_tenant,
|
|
58
|
+
)
|
|
59
|
+
from litestar_security.guards import all_of as guard_all_of
|
|
60
|
+
from litestar_security.guards import any_of as guard_any_of
|
|
61
|
+
from litestar_security.guards import at_least as guard_at_least
|
|
62
|
+
from litestar_security.guards import one_of as guard_one_of
|
|
63
|
+
from litestar_security.headers import ContentSecurityPolicy, CSPMode, SecurityHeadersConfig, csp_nonce
|
|
64
|
+
from litestar_security.plugin import CurrentUser, SecurityPlugin
|
|
65
|
+
from litestar_security.websocket import (
|
|
66
|
+
AuthorizationSnapshotRefresher,
|
|
67
|
+
InMemoryWebSocketTicketStore,
|
|
68
|
+
IssuedWebSocketTicket,
|
|
69
|
+
WebSocketBinding,
|
|
70
|
+
WebSocketCloseCodes,
|
|
71
|
+
WebSocketRevocationSource,
|
|
72
|
+
WebSocketSecurityConfig,
|
|
73
|
+
WebSocketTicketRecord,
|
|
74
|
+
WebSocketTicketService,
|
|
75
|
+
WebSocketTicketStore,
|
|
76
|
+
issue_websocket_ticket,
|
|
77
|
+
websocket_policy_fingerprint,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
if TYPE_CHECKING:
|
|
81
|
+
from litestar_security.providers.oauth import (
|
|
82
|
+
GitHubOAuthProvider,
|
|
83
|
+
OAuthAccountService,
|
|
84
|
+
OAuthAccountStore,
|
|
85
|
+
OAuthConfig,
|
|
86
|
+
OAuthProvider,
|
|
87
|
+
OAuthRouteService,
|
|
88
|
+
TokenVault,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
__all__ = (
|
|
92
|
+
"AssuranceRequirement",
|
|
93
|
+
"AssuranceTrait",
|
|
94
|
+
"Authenticated",
|
|
95
|
+
"AuthenticationEvidence",
|
|
96
|
+
"AuthenticationMechanism",
|
|
97
|
+
"AuthenticationOutcome",
|
|
98
|
+
"AuthenticationPolicy",
|
|
99
|
+
"AuthenticationRegistry",
|
|
100
|
+
"AuthorizationDecision",
|
|
101
|
+
"AuthorizationPredicate",
|
|
102
|
+
"AuthorizationResolver",
|
|
103
|
+
"AuthorizationSnapshot",
|
|
104
|
+
"AuthorizationSnapshotRefresher",
|
|
105
|
+
"BlockingIntegration",
|
|
106
|
+
"CSPMode",
|
|
107
|
+
"ContentSecurityPolicy",
|
|
108
|
+
"CredentialExtraction",
|
|
109
|
+
"CredentialRestrictions",
|
|
110
|
+
"CredentialSlot",
|
|
111
|
+
"CurrentUser",
|
|
112
|
+
"ExternalCSRF",
|
|
113
|
+
"GitHubOAuthProvider",
|
|
114
|
+
"IdentityResolution",
|
|
115
|
+
"IdentityResolver",
|
|
116
|
+
"InMemoryWebSocketTicketStore",
|
|
117
|
+
"InvalidCredentials",
|
|
118
|
+
"IssuedWebSocketTicket",
|
|
119
|
+
"LitestarSessionHandle",
|
|
120
|
+
"MFAConfig",
|
|
121
|
+
"MechanismRequirement",
|
|
122
|
+
"NoCredentials",
|
|
123
|
+
"NullSessionHandle",
|
|
124
|
+
"OAuthAccountService",
|
|
125
|
+
"OAuthAccountStore",
|
|
126
|
+
"OAuthConfig",
|
|
127
|
+
"OAuthProvider",
|
|
128
|
+
"OAuthRouteService",
|
|
129
|
+
"PasskeyConfig",
|
|
130
|
+
"PresentedCredential",
|
|
131
|
+
"Principal",
|
|
132
|
+
"RequestAuthenticator",
|
|
133
|
+
"ResourcePermission",
|
|
134
|
+
"SecurityConfig",
|
|
135
|
+
"SecurityContext",
|
|
136
|
+
"SecurityHeadersConfig",
|
|
137
|
+
"SecurityPlugin",
|
|
138
|
+
"SessionHandle",
|
|
139
|
+
"SessionPersistenceUnavailableError",
|
|
140
|
+
"SessionUnavailableError",
|
|
141
|
+
"TokenVault",
|
|
142
|
+
"VerificationUnavailable",
|
|
143
|
+
"WebSocketBinding",
|
|
144
|
+
"WebSocketCloseCodes",
|
|
145
|
+
"WebSocketRevocationSource",
|
|
146
|
+
"WebSocketSecurityConfig",
|
|
147
|
+
"WebSocketTicketRecord",
|
|
148
|
+
"WebSocketTicketService",
|
|
149
|
+
"WebSocketTicketStore",
|
|
150
|
+
"__project__",
|
|
151
|
+
"__version__",
|
|
152
|
+
"all_of",
|
|
153
|
+
"any_of",
|
|
154
|
+
"at_least",
|
|
155
|
+
"csp_nonce",
|
|
156
|
+
"guard_all_of",
|
|
157
|
+
"guard_any_of",
|
|
158
|
+
"guard_at_least",
|
|
159
|
+
"guard_one_of",
|
|
160
|
+
"intersect_authorization",
|
|
161
|
+
"issue_websocket_ticket",
|
|
162
|
+
"mechanism",
|
|
163
|
+
"optional",
|
|
164
|
+
"public",
|
|
165
|
+
"required",
|
|
166
|
+
"requires_assurance",
|
|
167
|
+
"requires_authenticated",
|
|
168
|
+
"requires_capability",
|
|
169
|
+
"requires_role",
|
|
170
|
+
"requires_scope",
|
|
171
|
+
"requires_team_role",
|
|
172
|
+
"requires_tenant",
|
|
173
|
+
"websocket_policy_fingerprint",
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
_OAUTH_EXPORTS = frozenset({
|
|
177
|
+
"GitHubOAuthProvider",
|
|
178
|
+
"OAuthAccountService",
|
|
179
|
+
"OAuthAccountStore",
|
|
180
|
+
"OAuthConfig",
|
|
181
|
+
"OAuthProvider",
|
|
182
|
+
"OAuthRouteService",
|
|
183
|
+
"TokenVault",
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def __getattr__(name: str) -> Any: # noqa: ANN401 - module lazy-export hooks are dynamically typed
|
|
188
|
+
"""Resolve curated OAuth exports without loading providers at root import."""
|
|
189
|
+
if name in _OAUTH_EXPORTS:
|
|
190
|
+
from litestar_security import providers # noqa: PLC0415 - preserve lightweight package-root imports
|
|
191
|
+
|
|
192
|
+
return getattr(providers, name)
|
|
193
|
+
message = f"module {__name__!r} has no attribute {name!r}"
|
|
194
|
+
raise AttributeError(message)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Package metadata."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, metadata, version
|
|
4
|
+
|
|
5
|
+
__all__ = ("__project__", "__version__")
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
__version__ = version("litestar-security")
|
|
9
|
+
__project__ = metadata("litestar-security")["Name"]
|
|
10
|
+
except PackageNotFoundError: # pragma: no cover
|
|
11
|
+
__version__ = "0.1.0"
|
|
12
|
+
__project__ = "litestar-security"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""CLI commands for Litestar Security."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from litestar_security.__metadata__ import __project__, __version__
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from click import Group
|
|
11
|
+
|
|
12
|
+
__all__ = ("register", "security_group")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@click.group(name="security", help="Litestar Security operations.", no_args_is_help=True)
|
|
16
|
+
@click.version_option(version=__version__, prog_name=__project__)
|
|
17
|
+
def security_group() -> None:
|
|
18
|
+
"""Manage Litestar Security integrations."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def register(cli: "Group") -> None:
|
|
22
|
+
"""Attach the security command group to a Click group once.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
cli: The Click group to attach to. Calling this repeatedly is safe.
|
|
26
|
+
"""
|
|
27
|
+
if security_group.name not in cli.commands:
|
|
28
|
+
cli.add_command(security_group)
|