tba-runtime-hosted-authorization-continuation 0.4.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.
@@ -0,0 +1,27 @@
1
+ """Hosted authorization continuation exports."""
2
+
3
+ from .contracts import (
4
+ AuthenticationEvidence,
5
+ ContinuationReason,
6
+ ContinuationRecord,
7
+ ContinuationRequirements,
8
+ ContinuationResult,
9
+ ContinuationStatus,
10
+ ContinuationStore,
11
+ ContinuationUnavailable,
12
+ ValidatedAuthorizationRequest,
13
+ )
14
+ from .runtime import HostedAuthorizationContinuation
15
+
16
+ __all__ = [
17
+ "AuthenticationEvidence",
18
+ "ContinuationReason",
19
+ "ContinuationRecord",
20
+ "ContinuationRequirements",
21
+ "ContinuationResult",
22
+ "ContinuationStatus",
23
+ "ContinuationStore",
24
+ "ContinuationUnavailable",
25
+ "HostedAuthorizationContinuation",
26
+ "ValidatedAuthorizationRequest",
27
+ ]
@@ -0,0 +1,137 @@
1
+ """Contracts for continuing an already-validated hosted authorization request."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping
6
+ from dataclasses import dataclass, field
7
+ from datetime import datetime
8
+ from enum import Enum
9
+ from typing import Protocol
10
+
11
+
12
+ def require_aware(value: datetime) -> None:
13
+ if value.utcoffset() is None:
14
+ raise ValueError("authorization continuation timestamps must be timezone-aware")
15
+
16
+
17
+ @dataclass(frozen=True, slots=True)
18
+ class ValidatedAuthorizationRequest:
19
+ """Snapshot of the request as validated by the host authorization endpoint."""
20
+
21
+ issuer: str
22
+ client_id: str
23
+ redirect_uri: str
24
+ parameters: tuple[tuple[str, str], ...] = field(repr=False)
25
+ tenant_id: str | None = None
26
+
27
+ def __post_init__(self) -> None:
28
+ if not self.issuer or not self.client_id or not self.redirect_uri:
29
+ raise ValueError("issuer, client_id and redirect_uri are required")
30
+ if self.tenant_id == "":
31
+ raise ValueError("tenant ID must be nonempty when supplied")
32
+ snapshot = tuple((key, value) for key, value in self.parameters)
33
+ if any(
34
+ not isinstance(key, str) or not isinstance(value, str)
35
+ for key, value in snapshot
36
+ ):
37
+ raise ValueError("validated request parameters must be strings")
38
+ parameters = dict(snapshot)
39
+ if len(parameters) != len(snapshot):
40
+ raise ValueError("validated request contains duplicate parameters")
41
+ if (
42
+ parameters.get("client_id") != self.client_id
43
+ or parameters.get("redirect_uri") != self.redirect_uri
44
+ ):
45
+ raise ValueError(
46
+ "validated request disagrees with its client or redirect URI"
47
+ )
48
+ object.__setattr__(self, "parameters", snapshot)
49
+
50
+ @classmethod
51
+ def from_parameters(
52
+ cls, issuer: str, parameters: Mapping[str, str], *, tenant_id: str | None = None
53
+ ) -> ValidatedAuthorizationRequest:
54
+ return cls(
55
+ issuer,
56
+ parameters.get("client_id", ""),
57
+ parameters.get("redirect_uri", ""),
58
+ tuple(parameters.items()),
59
+ tenant_id=tenant_id,
60
+ )
61
+
62
+
63
+ @dataclass(frozen=True, slots=True)
64
+ class ContinuationRequirements:
65
+ required_methods: frozenset[str] = frozenset()
66
+ not_before: datetime | None = None
67
+ subject: str | None = None
68
+
69
+ def __post_init__(self) -> None:
70
+ object.__setattr__(self, "required_methods", frozenset(self.required_methods))
71
+ if self.not_before is not None:
72
+ require_aware(self.not_before)
73
+
74
+
75
+ @dataclass(frozen=True, slots=True)
76
+ class AuthenticationEvidence:
77
+ """Trusted host authentication evidence for this browser transaction."""
78
+
79
+ subject: str
80
+ authenticated_at: datetime
81
+ methods: frozenset[str]
82
+
83
+ def __post_init__(self) -> None:
84
+ require_aware(self.authenticated_at)
85
+ object.__setattr__(self, "methods", frozenset(self.methods))
86
+
87
+
88
+ @dataclass(frozen=True, slots=True)
89
+ class ContinuationRecord:
90
+ flow_id: str
91
+ browser_digest: bytes = field(repr=False)
92
+ request: ValidatedAuthorizationRequest
93
+ requirements: ContinuationRequirements
94
+ issued_at: datetime
95
+ expires_at: datetime
96
+
97
+
98
+ class ContinuationStatus(str, Enum):
99
+ RESUME = "resume"
100
+ RESTART_REQUIRED = "restart_required"
101
+ UNAVAILABLE = "unavailable"
102
+
103
+
104
+ class ContinuationReason(str, Enum):
105
+ INVALID_FLOW = "invalid_flow"
106
+ AUTHENTICATION_REQUIRED = "authentication_required"
107
+ REGISTRATION_CHANGED = "registration_changed"
108
+ STORAGE_UNAVAILABLE = "storage_unavailable"
109
+
110
+
111
+ @dataclass(frozen=True, slots=True)
112
+ class ContinuationResult:
113
+ status: ContinuationStatus
114
+ request: ValidatedAuthorizationRequest | None = None
115
+ reason: ContinuationReason | None = None
116
+ restart_client_id: str | None = None
117
+
118
+
119
+ class ContinuationUnavailable(RuntimeError):
120
+ """Expected host storage or registration service unavailability."""
121
+
122
+
123
+ class ContinuationStore(Protocol):
124
+ """Storage for immutable records. Map backend unavailability to ContinuationUnavailable."""
125
+
126
+ def create(self, record: ContinuationRecord, /) -> None:
127
+ """Insert a new record, rejecting duplicate flow IDs."""
128
+
129
+ def get(self, flow_id: str, /) -> ContinuationRecord | None:
130
+ """Return an unconsumed record, including expired records retained for recovery."""
131
+
132
+ def consume(self, record: ContinuationRecord, /, *, now: datetime) -> bool:
133
+ """Atomically consume the matching unexpired record once.
134
+
135
+ Return False if absent, changed, expired or already consumed. Never
136
+ replace or recreate an existing flow ID.
137
+ """
File without changes
@@ -0,0 +1,195 @@
1
+ """Browser-bound hosted OIDC/OAuth authorization continuation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import secrets
7
+ from collections.abc import Callable
8
+ from datetime import datetime, timedelta, timezone
9
+
10
+ from .contracts import (
11
+ AuthenticationEvidence,
12
+ ContinuationReason,
13
+ ContinuationRecord,
14
+ ContinuationRequirements,
15
+ ContinuationResult,
16
+ ContinuationStatus,
17
+ ContinuationStore,
18
+ ContinuationUnavailable,
19
+ ValidatedAuthorizationRequest,
20
+ require_aware,
21
+ )
22
+
23
+
24
+ def _browser_digest(value: str) -> bytes:
25
+ return hashlib.sha256(value.encode("utf-8")).digest()
26
+
27
+
28
+ class HostedAuthorizationContinuation:
29
+ def __init__(
30
+ self,
31
+ store: ContinuationStore,
32
+ *,
33
+ clock: Callable[[], datetime] | None = None,
34
+ recovery_window: timedelta = timedelta(),
35
+ ) -> None:
36
+ if recovery_window < timedelta():
37
+ raise ValueError("recovery window must be nonnegative")
38
+ self._recovery_window = recovery_window
39
+ self._store = store
40
+ self._clock = clock or (lambda: datetime.now(timezone.utc))
41
+
42
+ def _now(self) -> datetime:
43
+ now = self._clock()
44
+ require_aware(now)
45
+ return now
46
+
47
+ def begin(
48
+ self,
49
+ request: ValidatedAuthorizationRequest,
50
+ *,
51
+ browser_transaction_id: str,
52
+ requirements: ContinuationRequirements = ContinuationRequirements(),
53
+ ttl: timedelta = timedelta(minutes=30),
54
+ ) -> ContinuationRecord:
55
+ if not browser_transaction_id or ttl <= timedelta(0):
56
+ raise ValueError("a browser transaction ID and positive TTL are required")
57
+ now = self._now()
58
+ record = ContinuationRecord(
59
+ flow_id=secrets.token_urlsafe(32),
60
+ browser_digest=_browser_digest(browser_transaction_id),
61
+ request=request,
62
+ requirements=requirements,
63
+ issued_at=now,
64
+ expires_at=now + ttl,
65
+ )
66
+ self._store.create(record)
67
+ return record
68
+
69
+ def _lookup(
70
+ self,
71
+ flow_id: str,
72
+ *,
73
+ issuer: str,
74
+ browser_transaction_id: str,
75
+ client_id: str,
76
+ tenant_id: str | None,
77
+ ) -> ContinuationRecord | None:
78
+ if not flow_id or not browser_transaction_id:
79
+ return None
80
+ record = self._store.get(flow_id)
81
+ if (
82
+ record is None
83
+ or record.flow_id != flow_id
84
+ or record.request.issuer != issuer
85
+ or record.request.client_id != client_id
86
+ or getattr(record.request, "tenant_id", None) != tenant_id
87
+ or not secrets.compare_digest(
88
+ record.browser_digest, _browser_digest(browser_transaction_id)
89
+ )
90
+ ):
91
+ return None
92
+ return record
93
+
94
+ def inspect(
95
+ self,
96
+ flow_id: str,
97
+ *,
98
+ issuer: str,
99
+ browser_transaction_id: str,
100
+ client_id: str,
101
+ tenant_id: str | None = None,
102
+ ) -> ContinuationRecord | None:
103
+ """Read a pending flow for policy/UI decisions without consuming it."""
104
+ record = self._lookup(
105
+ flow_id,
106
+ issuer=issuer,
107
+ browser_transaction_id=browser_transaction_id,
108
+ client_id=client_id,
109
+ tenant_id=tenant_id,
110
+ )
111
+ if record is None or self._now() >= record.expires_at:
112
+ return None
113
+ return record
114
+
115
+ def _expired_result(
116
+ self, record: ContinuationRecord, now: datetime
117
+ ) -> ContinuationResult:
118
+ return ContinuationResult(
119
+ ContinuationStatus.RESTART_REQUIRED,
120
+ reason=ContinuationReason.INVALID_FLOW,
121
+ restart_client_id=(
122
+ record.request.client_id
123
+ if now - record.expires_at < self._recovery_window
124
+ else None
125
+ ),
126
+ )
127
+
128
+ def resume(
129
+ self,
130
+ flow_id: str,
131
+ *,
132
+ issuer: str,
133
+ browser_transaction_id: str,
134
+ client_id: str,
135
+ evidence: AuthenticationEvidence | None,
136
+ registration_is_current: Callable[[ValidatedAuthorizationRequest], bool],
137
+ tenant_id: str | None = None,
138
+ ) -> ContinuationResult:
139
+ try:
140
+ record = self._lookup(
141
+ flow_id,
142
+ issuer=issuer,
143
+ browser_transaction_id=browser_transaction_id,
144
+ client_id=client_id,
145
+ tenant_id=tenant_id,
146
+ )
147
+ if record is None:
148
+ return ContinuationResult(
149
+ ContinuationStatus.RESTART_REQUIRED,
150
+ reason=ContinuationReason.INVALID_FLOW,
151
+ )
152
+ now = self._now()
153
+ if now - record.expires_at >= self._recovery_window:
154
+ return self._expired_result(record, now)
155
+ if not registration_is_current(record.request):
156
+ return ContinuationResult(
157
+ ContinuationStatus.RESTART_REQUIRED,
158
+ reason=ContinuationReason.REGISTRATION_CHANGED,
159
+ )
160
+ requirements = record.requirements
161
+ now = self._now()
162
+ if now >= record.expires_at:
163
+ return self._expired_result(record, now)
164
+ if (
165
+ evidence is None
166
+ or not evidence.subject
167
+ or evidence.authenticated_at > now
168
+ or (
169
+ requirements.subject is not None
170
+ and requirements.subject != evidence.subject
171
+ )
172
+ or (
173
+ requirements.not_before is not None
174
+ and evidence.authenticated_at < requirements.not_before
175
+ )
176
+ or not requirements.required_methods.issubset(evidence.methods)
177
+ ):
178
+ return ContinuationResult(
179
+ ContinuationStatus.UNAVAILABLE,
180
+ reason=ContinuationReason.AUTHENTICATION_REQUIRED,
181
+ )
182
+ now = self._now()
183
+ if now >= record.expires_at:
184
+ return self._expired_result(record, now)
185
+ if not self._store.consume(record, now=now):
186
+ return ContinuationResult(
187
+ ContinuationStatus.RESTART_REQUIRED,
188
+ reason=ContinuationReason.INVALID_FLOW,
189
+ )
190
+ except ContinuationUnavailable:
191
+ return ContinuationResult(
192
+ ContinuationStatus.UNAVAILABLE,
193
+ reason=ContinuationReason.STORAGE_UNAVAILABLE,
194
+ )
195
+ return ContinuationResult(ContinuationStatus.RESUME, request=record.request)
@@ -0,0 +1,335 @@
1
+ Metadata-Version: 2.4
2
+ Name: tba-runtime-hosted-authorization-continuation
3
+ Version: 0.4.0
4
+ Summary: Issuer-bound authorization continuation through interactive account verification and enrollment.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ License-File: NOTICE
8
+ Keywords: tigrbl,identity,oauth,oidc,continuation,authorization
9
+ Author: Jacob Stewart
10
+ Author-email: jacob@swarmauri.com
11
+ Requires-Python: >=3.10,<3.16
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Typing :: Typed
17
+ Classifier: Topic :: Internet :: WWW/HTTP
18
+ Classifier: Topic :: Security
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Programming Language :: Python :: 3.15
26
+ Project-URL: Documentation, https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation#readme
27
+ Project-URL: Homepage, https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation#readme
28
+ Project-URL: Issues, https://github.com/tigrbl/tigrbl_auth/issues
29
+ Project-URL: PyPI, https://pypi.org/project/tba-runtime-hosted-authorization-continuation/
30
+ Project-URL: Repository, https://github.com/tigrbl/tigrbl_auth
31
+ Project-URL: Source, https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation
32
+ Project-URL: SSOT, https://github.com/tigrbl/tigrbl_auth/blob/master/.ssot/registry.json
33
+ Description-Content-Type: text/markdown
34
+
35
+ # tba-runtime-hosted-authorization-continuation
36
+
37
+ <!-- readme-standards:begin branding -->
38
+ <p align="center"><a href="https://github.com/tigrbl/tigrbl_auth"><img src="https://raw.githubusercontent.com/tigrbl/tigrbl_auth/master/docs/assets/tba-brand.png" alt="TBA · Tigrbl Auth" width="300"></a></p>
39
+ <p align="center"><strong>tba-runtime-hosted-authorization-continuation</strong></p>
40
+ <p align="center">Issuer-bound authorization continuation through interactive account verification and enrollment.</p>
41
+ <p align="center">
42
+ <a href="https://pypi.org/project/tba-runtime-hosted-authorization-continuation/"><img alt="pypi: tba-runtime-hosted-authorization-continuation" src="https://img.shields.io/pypi/v/tba-runtime-hosted-authorization-continuation?labelColor=1E293B&amp;color=1D4ED8"></a>
43
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/pyproject.toml"><img alt="Source version: 0.4.0" src="https://img.shields.io/static/v1?label=Source%20version&amp;message=0.4.0&amp;labelColor=1E293B&amp;color=4338CA"></a>
44
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/pyproject.toml"><img alt="Python: &gt;=3.10,&lt;3.16" src="https://img.shields.io/static/v1?label=Python&amp;message=%3E%3D3.10%2C%3C3.16&amp;labelColor=1E293B&amp;color=0F766E"></a>
45
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/pyproject.toml"><img alt="Layer: 060-runtime" src="https://img.shields.io/static/v1?label=Layer&amp;message=060-runtime&amp;labelColor=1E293B&amp;color=6D28D9"></a>
46
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&amp;message=active&amp;labelColor=1E293B&amp;color=166534"></a>
47
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&amp;message=Apache-2.0&amp;labelColor=1E293B&amp;color=86198F"></a>
48
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&amp;message=attribution&amp;labelColor=1E293B&amp;color=86198F"></a>
49
+ </p>
50
+ <p align="center">
51
+ <a href="https://pypi.org/project/tba-runtime-hosted-authorization-continuation/"><img alt="Monthly PyPI downloads: tba-runtime-hosted-authorization-continuation" src="https://img.shields.io/pypi/dm/tba-runtime-hosted-authorization-continuation?labelColor=1E293B&amp;color=0E7490"></a>
52
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/README.md"><img alt="README hits: tba-runtime-hosted-authorization-continuation" src="https://hits.sh/github.com/tigrbl/tigrbl_auth/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/README.md.svg?label=README%20hits&amp;labelColor=1E293B&amp;color=0E7490"></a>
53
+ </p>
54
+ <p align="center">
55
+ <a href="https://github.com/tigrbl/tigrbl_auth/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&amp;message=CI%20gate&amp;labelColor=1E293B&amp;color=1D4ED8"></a>
56
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/docs/readme/test_examples.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&amp;message=example%20source&amp;labelColor=1E293B&amp;color=0F766E"></a>
57
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&amp;message=not%20certified&amp;labelColor=1E293B&amp;color=92400E"></a>
58
+ <a href="https://github.com/tigrbl/tigrbl_auth/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&amp;message=repository%20policy&amp;labelColor=1E293B&amp;color=4338CA"></a>
59
+ <a href="https://github.com/tigrbl/tigrbl_auth/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&amp;message=source%20and%20CI&amp;labelColor=1E293B&amp;color=6D28D9"></a>
60
+ </p>
61
+ <p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
62
+ <!-- readme-standards:end branding -->
63
+
64
+ ---
65
+
66
+ ## Overview
67
+
68
+ ### Summary
69
+
70
+ Issuer-bound authorization continuation through interactive account verification and enrollment.
71
+
72
+ ### Why This Package
73
+
74
+ A single durable consume protects the original registered authorization request across hosted authentication steps.
75
+
76
+ ### When to Use
77
+
78
+ Begin after validating the authorization request, then resume it using trusted authentication evidence for the same browser transaction.
79
+
80
+ ### Features
81
+
82
+ - Preserve exact callback, nonce, state, and PKCE parameters.
83
+ - Browser, issuer, and client binding.
84
+ - Typed resume, restart, and unavailable outcomes.
85
+
86
+ ### Non-Goals
87
+
88
+ The runtime leaves request validation, hosted UI, account policy, and registered restart URLs to the host.
89
+
90
+ ---
91
+
92
+ ## Getting Started
93
+
94
+ ### Prerequisites
95
+
96
+ Use Python 3.10 or newer. Supply the transaction and policy interfaces in the public module.
97
+
98
+ ### Installation
99
+
100
+ Install the selected release after publication or use the local package directory during development.
101
+
102
+ #### uv
103
+
104
+ <!-- readme-standards:begin installation.uv -->
105
+ ```bash
106
+ uv add tba-runtime-hosted-authorization-continuation
107
+ ```
108
+ <!-- readme-standards:end installation.uv -->
109
+
110
+ #### pip
111
+
112
+ <!-- readme-standards:begin installation.pip -->
113
+ ```bash
114
+ python -m pip install tba-runtime-hosted-authorization-continuation
115
+ ```
116
+ <!-- readme-standards:end installation.pip -->
117
+
118
+ #### Poetry
119
+
120
+ <!-- readme-standards:begin installation.poetry -->
121
+ ```bash
122
+ poetry add tba-runtime-hosted-authorization-continuation
123
+ ```
124
+ <!-- readme-standards:end installation.poetry -->
125
+
126
+ ### Quick Start
127
+
128
+ Import the runtime and its public contracts before composing the host adapter.
129
+
130
+ #### Example
131
+
132
+ <!-- readme-standards:begin example.quick-start -->
133
+ Source: [docs/readme/quick_start.py](https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/docs/readme/quick_start.py).
134
+
135
+ ```python
136
+ from tba_runtime_hosted_authorization_continuation import ValidatedAuthorizationRequest
137
+
138
+ request = ValidatedAuthorizationRequest.from_parameters(
139
+ 'https://issuer.example.test',
140
+ {'client_id': 'example-app', 'redirect_uri': 'https://rp.example.test/callback'},
141
+ )
142
+ assert request.client_id == 'example-app'
143
+ ```
144
+ <!-- readme-standards:end example.quick-start -->
145
+
146
+ #### Expected Result
147
+
148
+ The example constructs the documented contract and does not require infrastructure or credentials.
149
+
150
+ ---
151
+
152
+ ## Usage
153
+
154
+ ### Common Workflows
155
+
156
+ <!-- readme-standards:begin example.usage -->
157
+ Source: [docs/readme/usage.py](https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/docs/readme/usage.py).
158
+
159
+ ```python
160
+ from tba_runtime_hosted_authorization_continuation import ContinuationRequirements
161
+
162
+ requirements = ContinuationRequirements(required_methods=frozenset({'otp'}))
163
+ assert requirements.required_methods == {'otp'}
164
+ ```
165
+ <!-- readme-standards:end example.usage -->
166
+
167
+ ### Configuration
168
+
169
+ Supply a durable continuation store, stable browser transaction identifier, and flow lifetime.
170
+
171
+ ### Error Handling
172
+
173
+ Map expected storage outages to `ContinuationUnavailable`. The runtime returns an unavailable outcome and includes no saved request.
174
+
175
+ ### Best Practices
176
+
177
+ Consult the current client registration at resume. Safely restart at a host-owned destination. For shared issuers, pass the host-resolved tenant ID when creating the request and again when inspecting or resuming it. A positive recovery window lets a bound browser receive only the current client identifier for a fresh sign-in. Retain unconsumed records for the configured window.
178
+
179
+ ---
180
+
181
+ ## Package Boundary
182
+
183
+ ### What It Owns
184
+
185
+ The runtime snapshots validated request parameters, checks browser and confirmation bindings, and asks the store to consume once.
186
+
187
+ ### Public API and Import Surfaces
188
+
189
+ Import `HostedAuthorizationContinuation`, `ValidatedAuthorizationRequest`, `ContinuationStore`, and the typed outcome contracts from `tba_runtime_hosted_authorization_continuation`.
190
+
191
+ ### Entry Points
192
+
193
+ <!-- readme-standards:begin entry-points -->
194
+ This package declares no command-line, GUI, or plugin entry points in its manifest.
195
+ <!-- readme-standards:end entry-points -->
196
+
197
+ This is a library imported by a host runtime. It installs no executable.
198
+
199
+ ### Injected Dependencies
200
+
201
+ Supply a `ContinuationStore`, registered client recheck, and trusted authentication evidence.
202
+
203
+ ### Protocol Consumers
204
+
205
+ Provider authorization and hosted sign-in routes consume this library after OAuth request validation.
206
+
207
+ ### Extensions
208
+
209
+ A host can select distinct completion requirements such as verified email or fresh factor proof.
210
+
211
+ ---
212
+
213
+ ## Operations and Readiness
214
+
215
+ ### Operational Requirements
216
+
217
+ Persist pending requests securely. The consume operation compares an immutable record and unexpired state in one transaction.
218
+
219
+ ### Health and Observability
220
+
221
+ Record status and reasons without logging authorization parameters or browser identifiers.
222
+
223
+ ### Security and Resource Limits
224
+
225
+ Use an unpredictable browser value and store it in an appropriate host-owned browser credential.
226
+
227
+ ### Compatibility
228
+
229
+ This is the first package release. Pin the selected artifact and verify the host implementation against its storage contract.
230
+
231
+ ---
232
+
233
+ ## Verification
234
+
235
+ ### Tests
236
+
237
+ Run `pkgs/120-tests/tba-tests-browser-session/tests/integration/test_hosted_authorization_continuation.py` with pytest.
238
+
239
+ ### Certification Status
240
+
241
+ No external certification is claimed. Use the linked acceptance scope and changing evidence recorded in SSOT.
242
+
243
+ ### Evidence
244
+
245
+ Use the [SSOT registry](../../../.ssot/registry.json) and execute the repository-owned synthetic tests.
246
+
247
+ ---
248
+
249
+ ## FAQ
250
+
251
+ ### Why
252
+
253
+ Interactive account steps can outlast an authorization page request.
254
+
255
+ ### How
256
+
257
+ Persist a validated request and resume it after the configured account evidence is available.
258
+
259
+ ### When
260
+
261
+ Use when a hosted provider must preserve an authorization request through confirmation or first-factor enrollment.
262
+
263
+ ---
264
+
265
+ ## Documentation and Related Packages
266
+
267
+ ### More Documentation
268
+
269
+ See SPEC-1239 in the repository SSOT.
270
+
271
+ ### Related Packages
272
+
273
+ TBA OAuth and OpenID Connect protocol packages.
274
+
275
+ ### Project Links
276
+
277
+ <!-- readme-standards:begin project-links -->
278
+ - [Documentation](https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation#readme)
279
+ - [Homepage](https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation#readme)
280
+ - [Issues](https://github.com/tigrbl/tigrbl_auth/issues)
281
+ - [PyPI](https://pypi.org/project/tba-runtime-hosted-authorization-continuation/)
282
+ - [Repository](https://github.com/tigrbl/tigrbl_auth)
283
+ - [SSOT](https://github.com/tigrbl/tigrbl_auth/blob/master/.ssot/registry.json)
284
+ - [Source](https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation)
285
+ - [pypi: tba-runtime-hosted-authorization-continuation](https://pypi.org/project/tba-runtime-hosted-authorization-continuation/)
286
+ <!-- readme-standards:end project-links -->
287
+
288
+ ---
289
+
290
+ ## Contributing
291
+
292
+ ### How to Contribute
293
+
294
+ Use the repository contribution guide and include an independent test for behavior changes.
295
+
296
+ ### Development Setup
297
+
298
+ Run the test path listed above with the repository's uv-managed environment.
299
+
300
+ ### Notes for Maintainers
301
+
302
+ Retain the exact validated request and treat one-time consumption as a compatibility requirement.
303
+
304
+ ---
305
+
306
+ ## Governance
307
+
308
+ ### Ownership and Decision Making
309
+
310
+ ADR-1143 assigns continued authorization state to TBA and application-specific restart policy to the host.
311
+
312
+ ### Standards and Policies
313
+
314
+ Follow the repository layer and package policies. The host owns the deployment's identity policy.
315
+
316
+ ### Lifecycle and Migration
317
+
318
+ Adopt the store and browser binding before switching existing sign-in continuation routes.
319
+
320
+ ---
321
+
322
+ ## License and Attribution
323
+
324
+ ### License
325
+
326
+ <!-- readme-standards:begin license -->
327
+ Licensed under `Apache-2.0`. See [LICENSE](https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/LICENSE).
328
+ <!-- readme-standards:end license -->
329
+
330
+ ### Notices
331
+
332
+ <!-- readme-standards:begin notices -->
333
+ See [NOTICE](https://github.com/tigrbl/tigrbl_auth/blob/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation/NOTICE) for attribution.
334
+ <!-- readme-standards:end notices -->
335
+
@@ -0,0 +1,9 @@
1
+ tba_runtime_hosted_authorization_continuation/__init__.py,sha256=WUe585qgp4fBJMxddhVdzgcZD3j0-Po0AuV6ZN4jYhg,684
2
+ tba_runtime_hosted_authorization_continuation/contracts.py,sha256=GlpRjL_XrFg9ixWwe5V8iz-Ec89P71GjuoKLwBBJIHM,4673
3
+ tba_runtime_hosted_authorization_continuation/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ tba_runtime_hosted_authorization_continuation/runtime.py,sha256=vRZ4cGfk6Pwe2Ew506z4UNVsCcR7zAFcVm6BZ2RLPFg,6633
5
+ tba_runtime_hosted_authorization_continuation-0.4.0.dist-info/METADATA,sha256=TqMt2TWosQdbhWG-ViRQjIjReAWCCnS7IzGRQoHOdvY,15206
6
+ tba_runtime_hosted_authorization_continuation-0.4.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
7
+ tba_runtime_hosted_authorization_continuation-0.4.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
+ tba_runtime_hosted_authorization_continuation-0.4.0.dist-info/licenses/NOTICE,sha256=4rLgLyMdFsCd0lIGv3t0BCorB1l2U2-hbKA-3yUgyl4,418
9
+ tba_runtime_hosted_authorization_continuation-0.4.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.5.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ Tigrbl Auth (TBA)
2
+
3
+ Project: https://github.com/tigrbl/tigrbl_auth
4
+ Attribution: Jacob Stewart and the Tigrbl Auth contributors.
5
+
6
+ Distributed under the Apache License, Version 2.0.
7
+ See the accompanying LICENSE file for the license terms.
8
+
9
+ Distribution: tba-runtime-hosted-authorization-continuation
10
+ Source: https://github.com/tigrbl/tigrbl_auth/tree/master/pkgs/060-runtime/tba-runtime-hosted-authorization-continuation