tigrbl-auth 0.3.2.dev2__py3-none-any.whl → 0.4.0.dev2__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.
Files changed (92) hide show
  1. tigrbl_auth/__init__.py +106 -215
  2. tigrbl_auth/app.py +2 -72
  3. tigrbl_auth/cli.py +5 -0
  4. tigrbl_auth/gateway.py +17 -0
  5. tigrbl_auth/plugin.py +5 -0
  6. tigrbl_auth-0.4.0.dev2.dist-info/METADATA +20 -0
  7. tigrbl_auth-0.4.0.dev2.dist-info/RECORD +8 -0
  8. {tigrbl_auth-0.3.2.dev2.dist-info → tigrbl_auth-0.4.0.dev2.dist-info}/WHEEL +1 -1
  9. tigrbl_auth/adapters/__init__.py +0 -14
  10. tigrbl_auth/adapters/auth_context.py +0 -28
  11. tigrbl_auth/adapters/local_adapter.py +0 -47
  12. tigrbl_auth/adapters/remote_adapter.py +0 -162
  13. tigrbl_auth/backends.py +0 -157
  14. tigrbl_auth/crypto.py +0 -160
  15. tigrbl_auth/db.py +0 -12
  16. tigrbl_auth/deps/__init__.py +0 -170
  17. tigrbl_auth/deps/fastapi.py +0 -33
  18. tigrbl_auth/deps/pydantic.py +0 -21
  19. tigrbl_auth/deps/sqlalchemy.py +0 -10
  20. tigrbl_auth/deps/tigrbl.py +0 -82
  21. tigrbl_auth/errors.py +0 -20
  22. tigrbl_auth/fastapi_deps.py +0 -170
  23. tigrbl_auth/jwtoken.py +0 -304
  24. tigrbl_auth/oidc_discovery.py +0 -135
  25. tigrbl_auth/oidc_id_token.py +0 -187
  26. tigrbl_auth/oidc_userinfo.py +0 -108
  27. tigrbl_auth/orm/__init__.py +0 -35
  28. tigrbl_auth/orm/api_key.py +0 -41
  29. tigrbl_auth/orm/auth_code.py +0 -133
  30. tigrbl_auth/orm/auth_session.py +0 -146
  31. tigrbl_auth/orm/client.py +0 -165
  32. tigrbl_auth/orm/device_code.py +0 -108
  33. tigrbl_auth/orm/pushed_authorization_request.py +0 -133
  34. tigrbl_auth/orm/revoked_token.py +0 -41
  35. tigrbl_auth/orm/service.py +0 -51
  36. tigrbl_auth/orm/service_key.py +0 -57
  37. tigrbl_auth/orm/tenant.py +0 -67
  38. tigrbl_auth/orm/user.py +0 -162
  39. tigrbl_auth/principal_ctx.py +0 -6
  40. tigrbl_auth/rfc/__init__.py +0 -0
  41. tigrbl_auth/rfc/rfc6749.py +0 -100
  42. tigrbl_auth/rfc/rfc6749_token.py +0 -305
  43. tigrbl_auth/rfc/rfc6750.py +0 -61
  44. tigrbl_auth/rfc/rfc7009.py +0 -93
  45. tigrbl_auth/rfc/rfc7515.py +0 -31
  46. tigrbl_auth/rfc/rfc7516.py +0 -52
  47. tigrbl_auth/rfc/rfc7517.py +0 -41
  48. tigrbl_auth/rfc/rfc7518.py +0 -35
  49. tigrbl_auth/rfc/rfc7519.py +0 -32
  50. tigrbl_auth/rfc/rfc7520.py +0 -35
  51. tigrbl_auth/rfc/rfc7521.py +0 -38
  52. tigrbl_auth/rfc/rfc7523.py +0 -48
  53. tigrbl_auth/rfc/rfc7591.py +0 -9
  54. tigrbl_auth/rfc/rfc7592.py +0 -9
  55. tigrbl_auth/rfc/rfc7636_pkce.py +0 -107
  56. tigrbl_auth/rfc/rfc7638.py +0 -72
  57. tigrbl_auth/rfc/rfc7662.py +0 -63
  58. tigrbl_auth/rfc/rfc7662_introspection.py +0 -26
  59. tigrbl_auth/rfc/rfc7800.py +0 -57
  60. tigrbl_auth/rfc/rfc7952.py +0 -350
  61. tigrbl_auth/rfc/rfc8037.py +0 -77
  62. tigrbl_auth/rfc/rfc8176.py +0 -57
  63. tigrbl_auth/rfc/rfc8252.py +0 -57
  64. tigrbl_auth/rfc/rfc8291.py +0 -96
  65. tigrbl_auth/rfc/rfc8414.py +0 -61
  66. tigrbl_auth/rfc/rfc8414_metadata.py +0 -15
  67. tigrbl_auth/rfc/rfc8523.py +0 -177
  68. tigrbl_auth/rfc/rfc8628.py +0 -136
  69. tigrbl_auth/rfc/rfc8693.py +0 -455
  70. tigrbl_auth/rfc/rfc8705.py +0 -69
  71. tigrbl_auth/rfc/rfc8707.py +0 -36
  72. tigrbl_auth/rfc/rfc8725.py +0 -58
  73. tigrbl_auth/rfc/rfc8812.py +0 -56
  74. tigrbl_auth/rfc/rfc8932.py +0 -345
  75. tigrbl_auth/rfc/rfc9068.py +0 -64
  76. tigrbl_auth/rfc/rfc9101.py +0 -81
  77. tigrbl_auth/rfc/rfc9126.py +0 -10
  78. tigrbl_auth/rfc/rfc9207.py +0 -40
  79. tigrbl_auth/rfc/rfc9396.py +0 -81
  80. tigrbl_auth/rfc/rfc9449_dpop.py +0 -143
  81. tigrbl_auth/routers/__init__.py +0 -0
  82. tigrbl_auth/routers/auth_flows.py +0 -64
  83. tigrbl_auth/routers/authz/__init__.py +0 -12
  84. tigrbl_auth/routers/authz/oidc.py +0 -217
  85. tigrbl_auth/routers/schemas.py +0 -58
  86. tigrbl_auth/routers/shared.py +0 -38
  87. tigrbl_auth/routers/surface.py +0 -64
  88. tigrbl_auth/runtime_cfg.py +0 -295
  89. tigrbl_auth/typing.py +0 -57
  90. tigrbl_auth-0.3.2.dev2.dist-info/METADATA +0 -160
  91. tigrbl_auth-0.3.2.dev2.dist-info/RECORD +0 -87
  92. tigrbl_auth-0.3.2.dev2.dist-info/licenses/LICENSE +0 -201
tigrbl_auth/__init__.py CHANGED
@@ -1,218 +1,109 @@
1
- """tigrbl_auth – OAuth utilities and helpers.
1
+ """tigrbl_auth
2
2
 
3
- This package aggregates optional helpers for various OAuth 2.0 RFCs such as
4
- RFC 7636 (PKCE), RFC 8705 (mutual-TLS client authentication), and RFC 9396
5
- (Rich Authorization Requests).
3
+ Tigrbl-native authentication and authorization package checkpoint.
4
+
5
+ This package keeps top-level imports lightweight for governance and report
6
+ workflows while still exposing the dependency-light RFC helper surface expected
7
+ by the repository tests and previous checkpoints.
6
8
  """
7
9
 
8
- from .rfc.rfc7636_pkce import (
9
- makeCodeChallenge,
10
- makeCodeVerifier,
11
- verify_code_challenge,
12
- create_code_challenge,
13
- create_code_verifier,
14
- )
15
- from .rfc.rfc8628 import (
16
- generate_device_code,
17
- generate_user_code,
18
- validate_user_code,
19
- RFC8628_SPEC_URL,
20
- )
21
- from .rfc.rfc9396 import (
22
- AuthorizationDetail,
23
- parse_authorization_details,
24
- RFC9396_SPEC_URL,
25
- )
26
-
27
- from .rfc.rfc6750 import extract_bearer_token
28
- from .rfc import rfc7662, rfc7591, rfc7592, rfc9101
29
- from .rfc.rfc7662 import introspect_token, register_token, reset_tokens
30
- from .rfc.rfc9207 import RFC9207_SPEC_URL, extract_issuer
31
- from .rfc.rfc8932 import RFC8932_SPEC_URL, enforce_encrypted_dns
32
- from .orm.pushed_authorization_request import DEFAULT_PAR_EXPIRY
33
- from .rfc.rfc8707 import extract_resource, RFC8707_SPEC_URL
34
- from .rfc.rfc8705 import (
35
- RFC8705_SPEC_URL,
36
- thumbprint_from_cert_pem,
37
- validate_certificate_binding,
38
- )
39
- from .rfc.rfc8252 import is_native_redirect_uri, validate_native_redirect_uri
40
- from .rfc.rfc7638 import jwk_thumbprint, verify_jwk_thumbprint
41
- from .rfc.rfc7800 import add_cnf_claim, verify_proof_of_possession
42
- from .rfc.rfc8291 import encrypt_push_message, decrypt_push_message, RFC8291_SPEC_URL
43
- from .rfc.rfc8812 import (
44
- is_webauthn_algorithm,
45
- WEBAUTHN_ALGORITHMS,
46
- RFC8812_SPEC_URL,
47
- )
48
- from .rfc.rfc9068 import add_rfc9068_claims, validate_rfc9068_claims
49
- from .rfc.rfc8037 import sign_eddsa, verify_eddsa, RFC8037_SPEC_URL
50
- from .rfc.rfc8176 import (
51
- validate_amr_claim,
52
- AMR_VALUES,
53
- RFC8176_SPEC_URL,
54
- )
55
-
56
- from .rfc.rfc7515 import sign_jws, verify_jws
57
- from .rfc.rfc7516 import encrypt_jwe, decrypt_jwe
58
- from .rfc.rfc7517 import load_signing_jwk, load_public_jwk
59
- from .rfc.rfc7518 import supported_algorithms
60
- from .rfc.rfc7519 import encode_jwt, decode_jwt
61
-
62
- from .rfc.rfc7520 import jws_then_jwe, jwe_then_jws, RFC7520_SPEC_URL
63
- from .rfc.rfc7591 import RFC7591_SPEC_URL
64
- from .rfc.rfc7592 import RFC7592_SPEC_URL
65
-
66
- from .rfc.rfc7521 import validate_jwt_assertion, RFC7521_SPEC_URL
67
- from .rfc.rfc7523 import validate_client_jwt_bearer, RFC7523_SPEC_URL
68
-
69
- # New RFC implementations
70
- from .rfc.rfc8523 import (
71
- validate_enhanced_jwt_bearer,
72
- makeClientAssertionJwt,
73
- is_jwt_replay,
74
- RFC8523_SPEC_URL,
75
- create_client_assertion_jwt,
76
- )
77
- from .rfc.rfc7952 import (
78
- makeSecurityEventToken,
79
- validate_security_event_token,
80
- extract_event_data,
81
- get_set_subject_identifiers,
82
- makeAccountDisabledSet,
83
- makeSessionRevokedSet,
84
- SET_EVENT_TYPES,
85
- RFC7952_SPEC_URL,
86
- create_security_event_token,
87
- create_account_disabled_set,
88
- create_session_revoked_set,
89
- )
90
- from .rfc.rfc8693 import (
91
- TokenExchangeRequest,
92
- TokenExchangeResponse,
93
- TokenType,
94
- validate_token_exchange_request,
95
- validate_subject_token,
96
- exchange_token,
97
- makeImpersonationToken,
98
- makeDelegationToken,
99
- TOKEN_EXCHANGE_GRANT_TYPE,
100
- RFC8693_SPEC_URL,
101
- include_rfc8693,
102
- create_impersonation_token,
103
- create_delegation_token,
104
- )
105
- from .rfc.rfc8932 import (
106
- get_enhanced_authorization_server_metadata,
107
- validate_metadata_consistency,
108
- get_capability_matrix,
109
- )
110
-
111
- from .oidc_id_token import mint_id_token, verify_id_token
112
-
113
- __all__ = [
114
- "makeCodeVerifier",
115
- "makeCodeChallenge",
116
- "verify_code_challenge",
117
- "create_code_verifier",
118
- "create_code_challenge",
119
- "generate_user_code",
120
- "validate_user_code",
121
- "generate_device_code",
122
- "RFC8628_SPEC_URL",
123
- "parse_authorization_details",
124
- "AuthorizationDetail",
125
- "RFC9396_SPEC_URL",
126
- "extract_bearer_token",
127
- "extract_issuer",
128
- "extract_resource",
129
- "RFC8707_SPEC_URL",
130
- "RFC8705_SPEC_URL",
131
- "RFC9207_SPEC_URL",
132
- "enforce_encrypted_dns",
133
- "RFC8932_SPEC_URL",
134
- "introspect_token",
135
- "register_token",
136
- "reset_tokens",
137
- "DEFAULT_PAR_EXPIRY",
138
- "thumbprint_from_cert_pem",
139
- "validate_certificate_binding",
140
- "add_rfc9068_claims",
141
- "validate_rfc9068_claims",
142
- "is_native_redirect_uri",
143
- "validate_native_redirect_uri",
144
- "sign_jws",
145
- "verify_jws",
146
- "encrypt_jwe",
147
- "decrypt_jwe",
148
- "load_signing_jwk",
149
- "load_public_jwk",
150
- "supported_algorithms",
151
- "encode_jwt",
152
- "decode_jwt",
153
- "jws_then_jwe",
154
- "jwe_then_jws",
155
- "RFC7591_SPEC_URL",
156
- "RFC7592_SPEC_URL",
157
- "jwk_thumbprint",
158
- "verify_jwk_thumbprint",
159
- "add_cnf_claim",
160
- "verify_proof_of_possession",
161
- "encrypt_push_message",
162
- "decrypt_push_message",
163
- "RFC8291_SPEC_URL",
164
- "is_webauthn_algorithm",
165
- "WEBAUTHN_ALGORITHMS",
166
- "RFC8812_SPEC_URL",
167
- "validate_jwt_assertion",
168
- "RFC7521_SPEC_URL",
169
- "RFC7520_SPEC_URL",
170
- "sign_eddsa",
171
- "verify_eddsa",
172
- "RFC8037_SPEC_URL",
173
- "validate_amr_claim",
174
- "AMR_VALUES",
175
- "RFC8176_SPEC_URL",
176
- "validate_client_jwt_bearer",
177
- "RFC7523_SPEC_URL",
178
- # New RFC implementations
179
- "validate_enhanced_jwt_bearer",
180
- "makeClientAssertionJwt",
181
- "is_jwt_replay",
182
- "RFC8523_SPEC_URL",
183
- "makeSecurityEventToken",
184
- "validate_security_event_token",
185
- "extract_event_data",
186
- "get_set_subject_identifiers",
187
- "makeAccountDisabledSet",
188
- "makeSessionRevokedSet",
189
- "SET_EVENT_TYPES",
190
- "RFC7952_SPEC_URL",
191
- "TokenExchangeRequest",
192
- "TokenExchangeResponse",
193
- "TokenType",
194
- "validate_token_exchange_request",
195
- "validate_subject_token",
196
- "exchange_token",
197
- "makeImpersonationToken",
198
- "makeDelegationToken",
199
- "TOKEN_EXCHANGE_GRANT_TYPE",
200
- "RFC8693_SPEC_URL",
201
- "include_rfc8693",
202
- "create_client_assertion_jwt",
203
- "create_security_event_token",
204
- "create_account_disabled_set",
205
- "create_session_revoked_set",
206
- "create_impersonation_token",
207
- "create_delegation_token",
208
- "get_enhanced_authorization_server_metadata",
209
- "validate_metadata_consistency",
210
- "get_capability_matrix",
211
- "RFC8932_SPEC_URL",
212
- "rfc7591",
213
- "rfc7592",
214
- "rfc7662",
215
- "rfc9101",
216
- "mint_id_token",
217
- "verify_id_token",
218
- ]
10
+ from __future__ import annotations
11
+
12
+ import sys
13
+ from http import HTTPStatus as _HTTPStatus
14
+ from importlib import import_module
15
+ from typing import Any
16
+
17
+
18
+ def _install_tomllib_alias() -> None:
19
+ """Backfill ``tomllib`` on Python 3.10 using ``tomli`` if available."""
20
+
21
+ if sys.version_info >= (3, 11):
22
+ return
23
+ try: # pragma: no cover - exercised on Python 3.10 CI lanes
24
+ import tomllib as _tomllib # noqa: F401
25
+ except ModuleNotFoundError:
26
+ try:
27
+ import tomli as _tomllib # type: ignore[no-redef]
28
+ except ModuleNotFoundError:
29
+ return
30
+ sys.modules.setdefault("tomllib", _tomllib)
31
+
32
+
33
+ def _install_http_status_aliases() -> None:
34
+ """Provide Starlette-style ``HTTP_<code>_<NAME>`` aliases on ``HTTPStatus``.
35
+
36
+ The repository tests and some release-path modules historically rely on the
37
+ constant-style names exported by Starlette/FastAPI. Tigrbl uses the stdlib
38
+ ``http.HTTPStatus`` enum, so install integer aliases once at package import
39
+ time to keep both surfaces compatible.
40
+ """
41
+
42
+ for item in _HTTPStatus:
43
+ alias = f"HTTP_{int(item)}_{item.name}"
44
+ if not hasattr(_HTTPStatus, alias):
45
+ setattr(_HTTPStatus, alias, int(item))
46
+
47
+ _install_tomllib_alias()
48
+ _install_http_status_aliases()
49
+
50
+ _MODULE_EXPORTS = {
51
+ "framework": "tigrbl_auth.framework",
52
+ "runtime_cfg": "tigrbl_auth.runtime_cfg",
53
+ "rfc7591": "tigrbl_auth.rfc.rfc7591",
54
+ "rfc7592": "tigrbl_auth.rfc.rfc7592",
55
+ "rfc7662": "tigrbl_auth.rfc.rfc7662",
56
+ "rfc9101": "tigrbl_auth.rfc.rfc9101",
57
+ }
58
+
59
+ _SYMBOL_EXPORTS = {
60
+ "encode_jwt": ("tigrbl_auth.standards.jose.rfc7519", "encode_jwt"),
61
+ "decode_jwt": ("tigrbl_auth.standards.jose.rfc7519", "decode_jwt"),
62
+ "encrypt_jwe": ("tigrbl_auth.standards.jose.rfc7516", "encrypt_jwe"),
63
+ "decrypt_jwe": ("tigrbl_auth.standards.jose.rfc7516", "decrypt_jwe"),
64
+ "sign_jws": ("tigrbl_auth.standards.jose.rfc7515", "sign_jws"),
65
+ "verify_jws": ("tigrbl_auth.standards.jose.rfc7515", "verify_jws"),
66
+ "load_signing_jwk": ("tigrbl_auth.standards.jose.rfc7517", "load_signing_jwk"),
67
+ "load_public_jwk": ("tigrbl_auth.standards.jose.rfc7517", "load_public_jwk"),
68
+ "supported_algorithms": ("tigrbl_auth.standards.jose.rfc7518", "supported_algorithms"),
69
+ "RFC7520_SPEC_URL": ("tigrbl_auth.rfc.rfc7520", "RFC7520_SPEC_URL"),
70
+ "jws_then_jwe": ("tigrbl_auth.rfc.rfc7520", "jws_then_jwe"),
71
+ "jwe_then_jws": ("tigrbl_auth.rfc.rfc7520", "jwe_then_jws"),
72
+ "makeCodeVerifier": ("tigrbl_auth.rfc.rfc7636_pkce", "makeCodeVerifier"),
73
+ "makeCodeChallenge": ("tigrbl_auth.rfc.rfc7636_pkce", "makeCodeChallenge"),
74
+ "verify_code_challenge": ("tigrbl_auth.rfc.rfc7636_pkce", "verify_code_challenge"),
75
+ "RFC8628_SPEC_URL": ("tigrbl_auth.rfc.rfc8628", "RFC8628_SPEC_URL"),
76
+ "generate_user_code": ("tigrbl_auth.rfc.rfc8628", "generate_user_code"),
77
+ "validate_user_code": ("tigrbl_auth.rfc.rfc8628", "validate_user_code"),
78
+ "generate_device_code": ("tigrbl_auth.rfc.rfc8628", "generate_device_code"),
79
+ "RFC9207_SPEC_URL": ("tigrbl_auth.rfc.rfc9207", "RFC9207_SPEC_URL"),
80
+ "extract_issuer": ("tigrbl_auth.rfc.rfc9207", "extract_issuer"),
81
+ "AuthorizationDetail": ("tigrbl_auth.rfc.rfc9396", "AuthorizationDetail"),
82
+ "RFC9396_SPEC_URL": ("tigrbl_auth.rfc.rfc9396", "RFC9396_SPEC_URL"),
83
+ "parse_authorization_details": ("tigrbl_auth.rfc.rfc9396", "parse_authorization_details"),
84
+ "RFC8932_SPEC_URL": ("tigrbl_auth.rfc.rfc8932", "RFC8932_SPEC_URL"),
85
+ "enforce_encrypted_dns": ("tigrbl_auth.rfc.rfc8932", "enforce_encrypted_dns"),
86
+ }
87
+
88
+
89
+ def __getattr__(name: str) -> Any:
90
+ module_name = _MODULE_EXPORTS.get(name)
91
+ if module_name is not None:
92
+ module = import_module(module_name)
93
+ globals()[name] = module
94
+ return module
95
+ symbol = _SYMBOL_EXPORTS.get(name)
96
+ if symbol is not None:
97
+ module_name, attr_name = symbol
98
+ module = import_module(module_name)
99
+ value = getattr(module, attr_name)
100
+ globals()[name] = value
101
+ return value
102
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
103
+
104
+
105
+ def __dir__() -> list[str]:
106
+ return sorted(set(globals()) | set(_MODULE_EXPORTS) | set(_SYMBOL_EXPORTS))
107
+
108
+
109
+ __all__ = sorted(set(_MODULE_EXPORTS) | set(_SYMBOL_EXPORTS))
tigrbl_auth/app.py CHANGED
@@ -1,75 +1,5 @@
1
- """
2
- tigrbl_auth.app
3
- ===============
4
-
5
- FastAPI application factory for the **tigrbl-auth** service.
6
-
7
- Features
8
- --------
9
- * Async SQLAlchemy engine (SQLite or Postgres driven by `DATABASE_URL`)
10
- * Auto-generated CRUD router for Tenant / Client / User / ApiKey
11
- * Public credential routes (/register, /login, /logout, …)
12
- * OIDC discovery (`/.well-known/openid-configuration`) + `jwks.json`
13
- * System diagnostics endpoints (healthz, methodz, hookz, kernelz)
14
- """
15
-
16
1
  from __future__ import annotations
17
2
 
18
- from tigrbl_auth.deps import TigrblApp
19
- import inspect
20
-
21
- from .routers.surface import surface_api
22
- from .db import dsn
23
- from .runtime_cfg import settings
24
- from .rfc.rfc8414 import include_rfc8414
25
- from .oidc_discovery import include_oidc_discovery
26
- from .rfc.rfc8693 import include_rfc8693
27
- from .oidc_userinfo import include_oidc_userinfo
28
- from .rfc.rfc7009 import include_rfc7009
29
-
30
-
31
- import logging
32
-
33
- logging.getLogger("uvicorn").setLevel(logging.DEBUG)
34
- # --------------------------------------------------------------------
35
- # TigrblApp application
36
- # --------------------------------------------------------------------
37
- app = TigrblApp(
38
- title="Tigrbl-Auth",
39
- version="0.1.0",
40
- openapi_url="/openapi.json",
41
- docs_url="/docs",
42
- engine=dsn,
43
- )
44
-
45
- # Mount routers
46
- surface_api.mount_jsonrpc(prefix="/rpc")
47
- surface_api.attach_diagnostics(prefix="/system")
48
- app.include_router(surface_api) # /authn/<model> resources & flows
49
-
50
-
51
- include_oidc_userinfo(app)
52
-
53
- if settings.enable_rfc8693:
54
- include_rfc8693(app)
55
-
56
- if settings.enable_rfc7009:
57
- include_rfc7009(app)
58
-
59
- if settings.enable_rfc8414:
60
- include_rfc8414(app)
61
- include_oidc_discovery(app)
62
-
63
-
64
- async def _startup() -> None:
65
- # 1 – metadata validation / SQLite convenience mode
66
- # When running on SQLite, attach the same file under the "authn" alias
67
- # so schema-qualified tables like "authn.tenants" work.
68
- # this should work without sqlite_attachments, if sqlite_attachments are required use:
69
- # > await surface_api.initialize(sqlite_attachments={"authn": "./authn.db"})
70
- init = surface_api.initialize()
71
- if inspect.isawaitable(init):
72
- await init
73
-
3
+ from tigrbl_identity_server.app import app, build_app, build_application_runtime_plan
74
4
 
75
- app.add_event_handler("startup", _startup)
5
+ __all__ = ["app", "build_app", "build_application_runtime_plan"]
tigrbl_auth/cli.py ADDED
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ from tigrbl_identity_operator.cli.main import main
4
+
5
+ __all__ = ["main"]
tigrbl_auth/gateway.py ADDED
@@ -0,0 +1,17 @@
1
+ from __future__ import annotations
2
+
3
+ from tigrbl_identity_server.gateway import (
4
+ app,
5
+ build_app,
6
+ build_gateway,
7
+ build_gateway_runtime_plan,
8
+ resolve_gateway_deployment,
9
+ )
10
+
11
+ __all__ = [
12
+ "app",
13
+ "build_app",
14
+ "build_gateway",
15
+ "build_gateway_runtime_plan",
16
+ "resolve_gateway_deployment",
17
+ ]
tigrbl_auth/plugin.py ADDED
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ from tigrbl_identity_server.plugin import TigrblAuthPlugin, install
4
+
5
+ __all__ = ["TigrblAuthPlugin", "install"]
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: tigrbl-auth
3
+ Version: 0.4.0.dev2
4
+ Summary: Compatibility facade for the Tigrbl identity package suite.
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10,<3.15
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Description-Content-Type: text/markdown
14
+
15
+ # tigrbl-auth
16
+
17
+ Compatibility facade for the Tigrbl identity package suite.
18
+
19
+ This package uses the independent import root `tigrbl_auth`.
20
+
@@ -0,0 +1,8 @@
1
+ tigrbl_auth/__init__.py,sha256=k1HF9z4ZOE76gs4FpjfEVFZogKysOdurthGRQ44gEcg,4589
2
+ tigrbl_auth/app.py,sha256=Rnd2NgRZ-2MtmbP7fEmYg5duu4EryPrb34Ktj2mXIck,188
3
+ tigrbl_auth/cli.py,sha256=4vT1N_fCWxbM8CPSbgL6GItoxqV043qJyBe1V8fwSpE,107
4
+ tigrbl_auth/gateway.py,sha256=E5zqsuKzMN_mVWfL8W7-2XoDG_2qA8_8xkQ5T7aQ-UY,322
5
+ tigrbl_auth/plugin.py,sha256=qY_XeIAC3qoWFeQwtUrA8AnyCrSuFGU4gfUtor-vepU,147
6
+ tigrbl_auth-0.4.0.dev2.dist-info/METADATA,sha256=BIZRVp8GBAN-wiupFRryMdnrO_ESE15pKMy2yUesxgU,672
7
+ tigrbl_auth-0.4.0.dev2.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
8
+ tigrbl_auth-0.4.0.dev2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.3.1
2
+ Generator: poetry-core 2.4.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,14 +0,0 @@
1
- # tigrbl_auth/v2/adapters/__init__.py
2
- def __getattr__(name):
3
- if name == "RemoteAuthNAdapter":
4
- from .remote_adapter import RemoteAuthNAdapter
5
-
6
- return RemoteAuthNAdapter
7
- if name == "LocalAuthNAdapter":
8
- from .local_adapter import LocalAuthNAdapter
9
-
10
- return LocalAuthNAdapter
11
- raise AttributeError(name)
12
-
13
-
14
- __all__ = ["LocalAuthNAdapter", "RemoteAuthNAdapter"]
@@ -1,28 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from tigrbl_auth.deps import Request, TIGRBL_AUTH_CONTEXT_ATTR
4
-
5
-
6
- def set_auth_context(request: Request, principal: dict | None) -> None:
7
- """Populate request.state with the auth context expected by Tigrbl.
8
-
9
- Parameters
10
- ----------
11
- request:
12
- Incoming FastAPI request whose state should be populated.
13
- principal:
14
- Principal dictionary containing ``tenant_id`` (``tid``) and ``user_id``
15
- (``sub``). May be ``None`` when no authenticated principal is present.
16
- """
17
- ctx: dict[str, str] = {}
18
- if principal:
19
- tid = principal.get("tid") or principal.get("tenant_id")
20
- uid = principal.get("sub") or principal.get("user_id")
21
- if tid is not None:
22
- ctx["tenant_id"] = tid
23
- if uid is not None:
24
- ctx["user_id"] = uid
25
- setattr(request.state, TIGRBL_AUTH_CONTEXT_ATTR, ctx)
26
-
27
-
28
- __all__ = ["set_auth_context"]
@@ -1,47 +0,0 @@
1
- """
2
- tigrbl_auth.adapters.local_adapter
3
- ──────────────────
4
- Concrete implementation of the ``AuthNProvider`` ABC declared by
5
- ``tigrbl.authn_abc``. It merely **adapts** the public helpers that already
6
- exist in *tigrbl_auth* so that Tigrbl can consume them automatically.
7
-
8
- Usage
9
- -----
10
- >>> from tigrbl import TigrblApi
11
- >>> from tigrbl_auth.adapters import LocalAuthNAdapter
12
- >>> api = TigrblApi(engine=ENGINE, authn=LocalAuthNAdapter())
13
- """
14
-
15
- from __future__ import annotations
16
-
17
- from tigrbl_auth.deps import AuthNProvider, Request
18
- from ..fastapi_deps import get_principal
19
- from ..principal_ctx import principal_var # noqa: F401 # ensure ContextVar is initialised
20
- from .auth_context import set_auth_context
21
-
22
-
23
- class LocalAuthNAdapter(AuthNProvider):
24
- """
25
- Thin wrapper that plugs existing *tigrbl_auth* functions into
26
- the abstract interface expected by Tigrbl.
27
- """
28
-
29
- # ------------------------------------------------------------------ #
30
- # FastAPI dependency (mandatory) #
31
- # ------------------------------------------------------------------ #
32
- async def get_principal(self, request: Request) -> dict: # noqa: D401
33
- """
34
- Delegate to ``tigrbl_auth.fastapi_deps.get_principal`` and forward
35
- whatever dict it returns.
36
-
37
- Raises
38
- ------
39
- fastapi.HTTPException(401)
40
- If the API‑key / bearer token is invalid or expired.
41
- """
42
- principal = await get_principal(request) # type: ignore[arg-type]
43
- set_auth_context(request, principal)
44
- return principal
45
-
46
-
47
- __all__ = ["LocalAuthNAdapter"]