authgebra 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.
- authgebra/__init__.py +92 -0
- authgebra/_core.py +477 -0
- authgebra/_generated/__init__.py +2 -0
- authgebra/_generated/aio.py +1535 -0
- authgebra/_generated/codes.py +29 -0
- authgebra/_generated/models.py +4041 -0
- authgebra/_generated/operations.py +108 -0
- authgebra/_generated/sync.py +1535 -0
- authgebra/_model.py +252 -0
- authgebra/_parse.py +158 -0
- authgebra/_version.py +3 -0
- authgebra/aclient.py +256 -0
- authgebra/client.py +272 -0
- authgebra/config.py +79 -0
- authgebra/errors.py +177 -0
- authgebra/models.py +263 -0
- authgebra/py.typed +0 -0
- authgebra-0.1.0.dist-info/METADATA +181 -0
- authgebra-0.1.0.dist-info/RECORD +22 -0
- authgebra-0.1.0.dist-info/WHEEL +5 -0
- authgebra-0.1.0.dist-info/licenses/LICENSE +42 -0
- authgebra-0.1.0.dist-info/top_level.txt +1 -0
authgebra/models.py
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"""Typed request and result models (frozen dataclasses, no third-party model library).
|
|
2
|
+
|
|
3
|
+
Only fields the server defines are sent. ``None`` means *omit the field*; the SDK never
|
|
4
|
+
fills in defaults, so the meaning of "absent" vs ``null`` vs ``{}`` is the caller's choice
|
|
5
|
+
(``context=None`` omits it, ``context={}`` sends ``{}``).
|
|
6
|
+
|
|
7
|
+
Revisions and generations are plain ``int`` (arbitrary precision): ``authz_revision`` of
|
|
8
|
+
``9223372036854775807`` survives the round trip.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import uuid
|
|
14
|
+
from dataclasses import dataclass, field
|
|
15
|
+
from enum import Enum
|
|
16
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Sequence, Union
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from ._generated import models as api_models
|
|
20
|
+
|
|
21
|
+
JSONValue = Union[None, bool, int, float, str, List["JSONValue"], Dict[str, "JSONValue"]]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Decision(str, Enum):
|
|
25
|
+
"""Authorization decision. Any other value from the server is a ``ProtocolError``."""
|
|
26
|
+
|
|
27
|
+
ALLOW = "allow"
|
|
28
|
+
DENY = "deny"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _uuid(value: uuid.UUID | str, name: str) -> str:
|
|
32
|
+
try:
|
|
33
|
+
return str(uuid.UUID(str(value)))
|
|
34
|
+
except ValueError as exc:
|
|
35
|
+
raise ValueError(f"{name} must be a UUID") from exc
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True)
|
|
39
|
+
class ResourceRef:
|
|
40
|
+
"""Stable external identity of a resource (never an internal slot)."""
|
|
41
|
+
|
|
42
|
+
resource_type_code: str
|
|
43
|
+
external_id: str
|
|
44
|
+
|
|
45
|
+
def to_json(self) -> dict[str, Any]:
|
|
46
|
+
return {"resource_type_code": self.resource_type_code, "external_id": self.external_id}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass(frozen=True)
|
|
50
|
+
class Meta:
|
|
51
|
+
"""``meta`` of a response. Absent on admin reads: the SDK then exposes ``None``, never 0."""
|
|
52
|
+
|
|
53
|
+
authz_revision: int
|
|
54
|
+
snapshot_generation: int | None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass(frozen=True)
|
|
58
|
+
class PageInfo:
|
|
59
|
+
next_cursor: str | None
|
|
60
|
+
has_more: bool
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass(frozen=True)
|
|
64
|
+
class ResponseInfo:
|
|
65
|
+
"""Correlation data of one HTTP exchange."""
|
|
66
|
+
|
|
67
|
+
status: int
|
|
68
|
+
request_id: str | None
|
|
69
|
+
trace_id: str | None
|
|
70
|
+
request_id_mismatch: bool = False
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@dataclass(frozen=True)
|
|
74
|
+
class ApiResult:
|
|
75
|
+
"""Generic successful response (used by the admin API and the low-level ``request``)."""
|
|
76
|
+
|
|
77
|
+
data: Any
|
|
78
|
+
info: ResponseInfo
|
|
79
|
+
meta: Meta | None = None
|
|
80
|
+
page: PageInfo | None = None
|
|
81
|
+
etag: str | None = None
|
|
82
|
+
#: ``Idempotency-Replayed: true`` was present (the server replayed a stored response).
|
|
83
|
+
replayed: bool = False
|
|
84
|
+
#: ``X-Authz-Revision`` response header, when present and numeric.
|
|
85
|
+
authz_revision_header: int | None = None
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclass(frozen=True)
|
|
89
|
+
class CheckRequest:
|
|
90
|
+
subject_id: uuid.UUID | str
|
|
91
|
+
permission: str
|
|
92
|
+
resource: ResourceRef | None = None
|
|
93
|
+
context: Mapping[str, JSONValue] | None = None
|
|
94
|
+
|
|
95
|
+
def to_json(self) -> dict[str, Any]:
|
|
96
|
+
body: dict[str, Any] = {
|
|
97
|
+
"subject_id": _uuid(self.subject_id, "subject_id"),
|
|
98
|
+
"permission": self.permission,
|
|
99
|
+
}
|
|
100
|
+
if self.resource is not None:
|
|
101
|
+
body["resource"] = self.resource.to_json()
|
|
102
|
+
if self.context is not None:
|
|
103
|
+
body["context"] = dict(self.context)
|
|
104
|
+
return body
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@dataclass(frozen=True)
|
|
108
|
+
class BatchCheckRequest:
|
|
109
|
+
subject_id: uuid.UUID | str
|
|
110
|
+
permission: str
|
|
111
|
+
resources: Sequence[ResourceRef]
|
|
112
|
+
context: Mapping[str, JSONValue] | None = None
|
|
113
|
+
|
|
114
|
+
def to_json(self) -> dict[str, Any]:
|
|
115
|
+
body: dict[str, Any] = {
|
|
116
|
+
"subject_id": _uuid(self.subject_id, "subject_id"),
|
|
117
|
+
"permission": self.permission,
|
|
118
|
+
"resources": [r.to_json() for r in self.resources],
|
|
119
|
+
}
|
|
120
|
+
if self.context is not None:
|
|
121
|
+
body["context"] = dict(self.context)
|
|
122
|
+
return body
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@dataclass(frozen=True)
|
|
126
|
+
class ListResourcesRequest:
|
|
127
|
+
subject_id: uuid.UUID | str
|
|
128
|
+
permission: str
|
|
129
|
+
resource_type: str
|
|
130
|
+
limit: int | None = None
|
|
131
|
+
cursor: str | None = None
|
|
132
|
+
context: Mapping[str, JSONValue] | None = None
|
|
133
|
+
|
|
134
|
+
def to_json(self) -> dict[str, Any]:
|
|
135
|
+
body: dict[str, Any] = {
|
|
136
|
+
"subject_id": _uuid(self.subject_id, "subject_id"),
|
|
137
|
+
"permission": self.permission,
|
|
138
|
+
"resource_type": self.resource_type,
|
|
139
|
+
}
|
|
140
|
+
if self.limit is not None:
|
|
141
|
+
body["limit"] = self.limit
|
|
142
|
+
if self.cursor is not None:
|
|
143
|
+
body["cursor"] = self.cursor
|
|
144
|
+
if self.context is not None:
|
|
145
|
+
body["context"] = dict(self.context)
|
|
146
|
+
return body
|
|
147
|
+
|
|
148
|
+
def with_cursor(self, cursor: str | None) -> ListResourcesRequest:
|
|
149
|
+
return ListResourcesRequest(
|
|
150
|
+
self.subject_id,
|
|
151
|
+
self.permission,
|
|
152
|
+
self.resource_type,
|
|
153
|
+
self.limit,
|
|
154
|
+
cursor,
|
|
155
|
+
self.context,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@dataclass(frozen=True)
|
|
160
|
+
class ExplainRequest:
|
|
161
|
+
subject_id: uuid.UUID | str
|
|
162
|
+
permission: str
|
|
163
|
+
resource: ResourceRef | None = None
|
|
164
|
+
context: Mapping[str, JSONValue] | None = None
|
|
165
|
+
#: Passed through verbatim (``{"max_steps": ...}``-style options defined by the server).
|
|
166
|
+
trace: api_models.ExplainTraceOptions | Mapping[str, JSONValue] | None = None
|
|
167
|
+
|
|
168
|
+
def to_json(self) -> dict[str, Any]:
|
|
169
|
+
body: dict[str, Any] = {
|
|
170
|
+
"subject_id": _uuid(self.subject_id, "subject_id"),
|
|
171
|
+
"permission": self.permission,
|
|
172
|
+
}
|
|
173
|
+
if self.resource is not None:
|
|
174
|
+
body["resource"] = self.resource.to_json()
|
|
175
|
+
if self.context is not None:
|
|
176
|
+
body["context"] = dict(self.context)
|
|
177
|
+
if self.trace is not None:
|
|
178
|
+
body["trace"] = dict(self.trace)
|
|
179
|
+
return body
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
@dataclass(frozen=True)
|
|
183
|
+
class CheckResult:
|
|
184
|
+
decision: Decision
|
|
185
|
+
reason_code: str
|
|
186
|
+
matched_policy: api_models.AuthzPolicyRef | None
|
|
187
|
+
info: ResponseInfo
|
|
188
|
+
meta: Meta | None = None
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def allowed(self) -> bool:
|
|
192
|
+
return self.decision is Decision.ALLOW
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@dataclass(frozen=True)
|
|
196
|
+
class BatchDecision:
|
|
197
|
+
resource: ResourceRef
|
|
198
|
+
reason_code: str
|
|
199
|
+
matched_policy: api_models.AuthzPolicyRef | None
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@dataclass(frozen=True)
|
|
203
|
+
class BatchCheckResult:
|
|
204
|
+
allowed: tuple[BatchDecision, ...]
|
|
205
|
+
denied: tuple[BatchDecision, ...]
|
|
206
|
+
info: ResponseInfo
|
|
207
|
+
meta: Meta | None = None
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
@dataclass(frozen=True)
|
|
211
|
+
class ResourcePage:
|
|
212
|
+
items: tuple[ResourceRef, ...]
|
|
213
|
+
page: PageInfo
|
|
214
|
+
info: ResponseInfo
|
|
215
|
+
meta: Meta | None = None
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@dataclass(frozen=True)
|
|
219
|
+
class ExplainResult:
|
|
220
|
+
decision: Decision
|
|
221
|
+
reason_code: str
|
|
222
|
+
matched_policy: api_models.AuthzPolicyRef | None
|
|
223
|
+
#: Policy explanations as returned by the server (the SDK does not reinterpret them).
|
|
224
|
+
policies: tuple[api_models.AuthzPolicyExplanation, ...]
|
|
225
|
+
truncated: bool
|
|
226
|
+
total_steps: int
|
|
227
|
+
info: ResponseInfo
|
|
228
|
+
meta: Meta | None = None
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@dataclass(frozen=True)
|
|
232
|
+
class RevisionResult:
|
|
233
|
+
db_revision: int
|
|
234
|
+
snapshot_generation: int
|
|
235
|
+
#: ``in_sync`` / ``rebuilding`` / ``stale`` (kept as text so new states do not break clients).
|
|
236
|
+
status: str
|
|
237
|
+
info: ResponseInfo
|
|
238
|
+
meta: Meta | None = None
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
@dataclass(frozen=True)
|
|
242
|
+
class RetryPolicy:
|
|
243
|
+
"""Bounded retries; never unbounded.
|
|
244
|
+
|
|
245
|
+
Reads retry on ``RATE_LIMITED`` / ``NOT_READY`` / timeout / connect / reset. Writes are
|
|
246
|
+
never retried unless ``retry_writes`` is set **and** the call carries an
|
|
247
|
+
``Idempotency-Key``. ``AUTHZ_RELOAD_PENDING`` / ``IDENTITY_RELOAD_PENDING`` are never retried.
|
|
248
|
+
"""
|
|
249
|
+
|
|
250
|
+
max_retries: int = 2
|
|
251
|
+
base_delay: float = 0.2
|
|
252
|
+
#: Upper bound for any single wait, including a server ``Retry-After``.
|
|
253
|
+
max_delay: float = 5.0
|
|
254
|
+
jitter: float = 0.2
|
|
255
|
+
retry_writes: bool = False
|
|
256
|
+
sleep: Any = field(default=None, compare=False)
|
|
257
|
+
async_sleep: Any = field(default=None, compare=False)
|
|
258
|
+
|
|
259
|
+
def __post_init__(self) -> None:
|
|
260
|
+
if not 0 <= self.max_retries <= 10:
|
|
261
|
+
raise ValueError("max_retries must be within 0..=10 (retries are always bounded)")
|
|
262
|
+
if self.base_delay < 0 or self.max_delay < 0:
|
|
263
|
+
raise ValueError("delays must be non-negative")
|
authgebra/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: authgebra
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python client for the Authgebra /api/v1 HTTP API (thin wrapper; performs no authorization computation).
|
|
5
|
+
License: Authgebra 专有软件许可
|
|
6
|
+
|
|
7
|
+
版权所有 (C) 2026 Authgebra 权利人。保留所有权利。
|
|
8
|
+
Copyright (C) 2026 The Authgebra Rights Holder. All rights reserved.
|
|
9
|
+
|
|
10
|
+
本仓库及其全部内容(包括但不限于源代码、二进制、文档、设计、数据集、
|
|
11
|
+
基准报告、测试与部署脚本,以下合称"本软件")是**专有且保密的**(proprietary
|
|
12
|
+
and confidential),受著作权法及国际著作权条约保护。
|
|
13
|
+
|
|
14
|
+
一、无许可授予
|
|
15
|
+
|
|
16
|
+
未经权利人事先书面授权,任何人不得:
|
|
17
|
+
|
|
18
|
+
1. 复制、分发、出租、出借、出售、转授权或以其他方式向第三方提供本软件
|
|
19
|
+
或其任何部分;
|
|
20
|
+
2. 修改、改编、翻译、演绎本软件,或基于本软件创作衍生作品;
|
|
21
|
+
3. 反向工程、反编译或反汇编本软件,法律明确不可排除者除外;
|
|
22
|
+
4. 移除、遮蔽或篡改本软件中的任何著作权、商标或其他权利声明;
|
|
23
|
+
5. 将本软件或其任何部分用于训练、微调、蒸馏或评估任何机器学习模型;
|
|
24
|
+
6. 将本软件作为服务对外提供(包括但不限于 SaaS、托管、API 转售)。
|
|
25
|
+
|
|
26
|
+
二、无担保
|
|
27
|
+
|
|
28
|
+
本软件按"现状"提供,不附带任何明示或默示的担保,包括但不限于对适销性、
|
|
29
|
+
特定用途适用性及不侵权的担保。在任何情况下,权利人不对任何索赔、损害
|
|
30
|
+
或其他责任承担责任,无论是在合同诉讼、侵权行为还是其他方面。
|
|
31
|
+
|
|
32
|
+
三、第三方组件
|
|
33
|
+
|
|
34
|
+
本软件包含或链接第三方开源组件,各自适用其自身许可证;这些组件清单与
|
|
35
|
+
适用条款见 `Cargo.lock`、`fronted/admin/pnpm-lock.yaml` 及
|
|
36
|
+
`docs/05-代码治理/02-依赖决策记录.md`。本节不改变上述组件原有的许可条件,
|
|
37
|
+
也不授予对本软件第一方代码的任何权利。
|
|
38
|
+
|
|
39
|
+
四、商业授权
|
|
40
|
+
|
|
41
|
+
如需获取商业授权、评估许可、OEM 或定制交付,请联系权利人。
|
|
42
|
+
|
|
43
|
+
五、终止
|
|
44
|
+
|
|
45
|
+
任何违反本许可的行为将自动终止本许可下的全部权利,且不影响权利人
|
|
46
|
+
追究其他救济的权利。
|
|
47
|
+
|
|
48
|
+
Project-URL: Repository, https://github.com/iwen-conf/authgebra-sdks
|
|
49
|
+
Project-URL: Releases, https://github.com/iwen-conf/authgebra-sdks/releases
|
|
50
|
+
Requires-Python: >=3.10
|
|
51
|
+
Description-Content-Type: text/markdown
|
|
52
|
+
License-File: LICENSE
|
|
53
|
+
Requires-Dist: httpx<1,>=0.27
|
|
54
|
+
Provides-Extra: dev
|
|
55
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
56
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
57
|
+
Dynamic: license-file
|
|
58
|
+
|
|
59
|
+
# authgebra (Python)
|
|
60
|
+
|
|
61
|
+
Official Python client for the Authgebra `/api/v1` HTTP API. It is a **thin wrapper**: it calls
|
|
62
|
+
the server and interprets the response. It does not evaluate RBAC/ABAC/ReBAC.
|
|
63
|
+
|
|
64
|
+
| | |
|
|
65
|
+
|---|---|
|
|
66
|
+
| Distribution / import | `authgebra` |
|
|
67
|
+
| Python | `>= 3.10` (tested on 3.10.22 and 3.14.7) |
|
|
68
|
+
| Runtime dependency | `httpx` |
|
|
69
|
+
| Server API | `/api/v1` |
|
|
70
|
+
| Contract digest | OpenAPI export `sdks/contracts/openapi.json`, sha256 `907bd9616dba9993c479cf551bc1e69ac046776b72dd58f5af1138be10c34c25` |
|
|
71
|
+
| Verification | **INTEGRATION_TESTED** — [evidence and limits](../DISTRIBUTION.md); native and real integration tests passed |
|
|
72
|
+
| Package status | 0.1.0 wheel and sdist on GitHub Releases; PyPI publication is tracked separately |
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
python -m pip install ./authgebra-0.1.0-py3-none-any.whl
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Quick start
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from authgebra import Client, Config, CheckRequest, ResourceRef
|
|
82
|
+
|
|
83
|
+
config = Config(base_url="https://authgebra.example", token_provider=lambda: access_token)
|
|
84
|
+
with Client(config) as client:
|
|
85
|
+
result = client.authorization.check(
|
|
86
|
+
CheckRequest(subject_id, "document:read", resource=ResourceRef("document", "doc-123"))
|
|
87
|
+
)
|
|
88
|
+
result.allowed # False is a normal result, not an exception
|
|
89
|
+
result.meta # Meta(authz_revision, snapshot_generation) or None
|
|
90
|
+
result.info.request_id, result.info.trace_id
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Async: `AsyncClient` has the same surface (`async with`, `await`, `async for`).
|
|
94
|
+
|
|
95
|
+
`client.admin.<group>.<operation_id>(...)` covers every operation in the OpenAPI export, grouped by
|
|
96
|
+
tag (`admin.users.list_users`, `admin.policies.publish_policy`, `admin.relation_tuples.create_relation_tuple`).
|
|
97
|
+
Admin calls return a named response with typed `data` and the existing `meta`, `page`, `info`,
|
|
98
|
+
`etag`, `replayed`, and `authz_revision_header` members. `from authgebra import api_models` exposes
|
|
99
|
+
generated request, response, nested object, enum, and union models. Both clients share these models.
|
|
100
|
+
Legacy request mappings and response mapping access remain supported. A query filter that collides with an SDK keyword gets a `query_` prefix
|
|
101
|
+
(`query_request_id` for the audit filter).
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from authgebra import api_models
|
|
105
|
+
|
|
106
|
+
request = api_models.CreateRoleRequest(code="reader", name="Reader")
|
|
107
|
+
created = client.admin.roles.create_role(body=request)
|
|
108
|
+
created.data.id
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Optional generated fields default to `UNSET` (absent); assigning `None` sends explicit JSON null,
|
|
112
|
+
only where the schema allows it. Zero, `False`, and empty collections remain values. Models validate
|
|
113
|
+
the reviewed machine constraints before sending; legacy mappings retain server-side validation.
|
|
114
|
+
Response decoding requires mandatory fields, preserves integer precision and accepts new object fields.
|
|
115
|
+
Source comments and `_generated/provenance.json` identify each schema and field's JSON Pointer.
|
|
116
|
+
Only genuinely open JSON schemas use the recursive `JSONValue` type.
|
|
117
|
+
|
|
118
|
+
## Authentication and transport
|
|
119
|
+
|
|
120
|
+
`token_provider` is called before every attempt (so refreshed tokens are used); async clients may pass an
|
|
121
|
+
`async def`. Tokens never appear in logs, `repr`, or exceptions. TLS verification is always on
|
|
122
|
+
(`verify=` takes `True`, a CA bundle path, or an `ssl.SSLContext`; `False` is rejected). Timeouts are
|
|
123
|
+
finite by default (connect 5 s, total 30 s per attempt); responses are capped at 8 MiB.
|
|
124
|
+
Inject `http_client=` or `transport=` to customise proxies, mTLS, etc. (the SDK does not read proxy
|
|
125
|
+
environment variables itself; an injected `httpx` client is never closed by the SDK).
|
|
126
|
+
|
|
127
|
+
## Errors
|
|
128
|
+
|
|
129
|
+
| Class | Meaning |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `ApiError` | The server sent `{"error": {...}}`. Fields: `status`, `code` (raw string), `known_code`, `request_id`, `trace_id`, `violations`, `retryable` (True/False/None), `retry_after_seconds`, `commit_state`, `request_id_mismatch`. |
|
|
132
|
+
| `CursorStaleError`, `NotReadyError`, `RateLimitedError`, `ReloadPendingError` | `ApiError` subclasses for the codes callers most often branch on. |
|
|
133
|
+
| `TransportError` | No usable response: `error` is `timeout`, `connect_error`, `tls_error`, `connection_reset`, `transport`. |
|
|
134
|
+
| `ProtocolError` | A response that violates the contract: `non_json_response`, `malformed_error_body`, `malformed_success_body`, `response_too_large`, `unknown_decision`. |
|
|
135
|
+
| `PaginationError` | The page iterator refused to go on. |
|
|
136
|
+
|
|
137
|
+
Rules: branch on `code`/class, never on `message`. An unknown `code` is kept verbatim with
|
|
138
|
+
`known_code=False`. **`NOT_READY` is never turned into a deny**; an unrecognised `decision` is a
|
|
139
|
+
`ProtocolError`, not an allow.
|
|
140
|
+
|
|
141
|
+
## Writes: idempotency and "committed but not published"
|
|
142
|
+
|
|
143
|
+
* Writes are **never resent automatically**. To allow bounded resends set
|
|
144
|
+
`RetryPolicy(retry_writes=True)` **and** pass the same `idempotency_key=` (`new_idempotency_key()`) with the same body.
|
|
145
|
+
* `AUTHZ_RELOAD_PENDING` / `IDENTITY_RELOAD_PENDING` raise `ReloadPendingError` with
|
|
146
|
+
`commit_state=CommitState.COMMITTED_UNPUBLISHED`: the mutation **executed**; it is never resent,
|
|
147
|
+
and you must not report it as "in effect" before publication is confirmed (for example by reading the
|
|
148
|
+
entity or `authorization.revision()`).
|
|
149
|
+
* A write that times out or loses its connection raises `TransportError` with `commit_state=UNKNOWN`
|
|
150
|
+
(never assume "not committed"). Resend only with the same idempotency key and body.
|
|
151
|
+
* Reads (GET, plus the pure decision POSTs) retry at most `max_retries` (default 2) on `RATE_LIMITED`,
|
|
152
|
+
`NOT_READY`, timeouts and connection failures; `Retry-After` is honoured but capped by `max_delay`.
|
|
153
|
+
|
|
154
|
+
## Tracing
|
|
155
|
+
|
|
156
|
+
Every request carries a valid `X-Request-ID` (`py-<hex>` unless you pass `request_id=`) and a W3C
|
|
157
|
+
`traceparent` (yours via `traceparent=` or `Config.trace_provider`, else a new trace; each retry is a new span of the same
|
|
158
|
+
trace). Results and errors expose `request_id` (response header preferred, body as fallback) and `trace_id`
|
|
159
|
+
(`error.trace_id`, else `X-Trace-ID`/`traceparent` response headers; invalid values are ignored).
|
|
160
|
+
|
|
161
|
+
## Pagination
|
|
162
|
+
|
|
163
|
+
`list_resources(request)` returns one page; `iter_list_resources(request, max_pages=100)` yields pages lazily.
|
|
164
|
+
`CURSOR_STALE` is raised as `CursorStaleError` (the SDK never restarts silently), a snapshot-generation change
|
|
165
|
+
between pages raises `PaginationError`, and the iterator is bounded by `max_pages`.
|
|
166
|
+
|
|
167
|
+
## Versions and numbers
|
|
168
|
+
|
|
169
|
+
`authz_revision` / `snapshot_generation` are Python `int`s parsed from the raw JSON text (no float round trip).
|
|
170
|
+
Admin reads have no `meta`; the SDK reports `None`, never `0`.
|
|
171
|
+
|
|
172
|
+
## Development
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
python -m venv .venv && .venv/bin/pip install -e '.[dev]'
|
|
176
|
+
.venv/bin/python tools/generate.py --check # generated admin surface matches ../contracts/openapi.json
|
|
177
|
+
.venv/bin/python -m pytest # runs all shared fixtures (sync + async) and behavior tests
|
|
178
|
+
.venv/bin/mypy --strict src tests tools examples
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Licensing: proprietary, same terms as the Authgebra repository (`LICENSE`).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
authgebra/__init__.py,sha256=5HqwzJZCp7LuwAwkzoKwwixX2YeLECXIbdaUtFRvqHE,2097
|
|
2
|
+
authgebra/_core.py,sha256=G5e5R_ufGwRGV0Ek6vZzf0vChB6R8V-73QKL6SXI5Kg,16822
|
|
3
|
+
authgebra/_model.py,sha256=XMXElOSrYbqLUjPFOLPufqX4RqJIk1gFSrGK7LNTIzc,10506
|
|
4
|
+
authgebra/_parse.py,sha256=GNG28F14P2wbR6YEwZ-vInKqoLNW9H15hsFTcIl5ZLI,4954
|
|
5
|
+
authgebra/_version.py,sha256=-Nse_rDcaUGqk3m4ohZH32A1Np5hjWuqYW6DyDZPme0,90
|
|
6
|
+
authgebra/aclient.py,sha256=-p49Go0XJWlbgCuLqhN8W_TlR21p2zPViKngGZYoqR8,9655
|
|
7
|
+
authgebra/client.py,sha256=edDHgB2cEUtH6QoWkLTZqyy75dNPdPzoxsQwCmUotj4,10246
|
|
8
|
+
authgebra/config.py,sha256=un68IEFcb0WkRXbuIqE-oEgWE-F8Eac9qjorlNx0wcs,3089
|
|
9
|
+
authgebra/errors.py,sha256=J4jTmlxqEY7RdTyyOsETEBjclxEc2En3_6qGkhVPhkk,5668
|
|
10
|
+
authgebra/models.py,sha256=Kvth9nJTvtsDT749l5vtHwGn1OZHLey7XjKPDTnVzYs,7844
|
|
11
|
+
authgebra/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
authgebra/_generated/__init__.py,sha256=vmGoZGAB67habkrxRoHaZVQUI_T6METmwJZZBKhPPLw,86
|
|
13
|
+
authgebra/_generated/aio.py,sha256=cK2ChrF75GHzcNhXoMMeoAHG8Q39ayeq7gKK-HTErSo,70616
|
|
14
|
+
authgebra/_generated/codes.py,sha256=D1oKBzGT0wWeijklmfQ0CaRxVrA5W0pioXRIGeMTp3k,796
|
|
15
|
+
authgebra/_generated/models.py,sha256=gQCfVArDsI1M1Dp1xyaPv6Mm618DVvUS2RVVkPzcBek,508071
|
|
16
|
+
authgebra/_generated/operations.py,sha256=0r6IXpeXO28EaI-aHTz9mh_4Io89YzQGtU2v6AVSWvU,7637
|
|
17
|
+
authgebra/_generated/sync.py,sha256=OghWJD6Au6rWg1f8vZzSPbqY2iGk0QTzL_iVE9EnLPQ,69381
|
|
18
|
+
authgebra-0.1.0.dist-info/licenses/LICENSE,sha256=gH9QjAENdpwgewtjkqHQUN0G2glhd8y1XTeZQdqDIc8,2048
|
|
19
|
+
authgebra-0.1.0.dist-info/METADATA,sha256=-DAbAKYO7gvuFX3ZpQ8OGLVFZdH8xbF-W8luUwI4Xoo,9849
|
|
20
|
+
authgebra-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
21
|
+
authgebra-0.1.0.dist-info/top_level.txt,sha256=UJV6TdUZc4FRQIbfOT1FeXbGBfudv6M7au_RYI2llbM,10
|
|
22
|
+
authgebra-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Authgebra 专有软件许可
|
|
2
|
+
|
|
3
|
+
版权所有 (C) 2026 Authgebra 权利人。保留所有权利。
|
|
4
|
+
Copyright (C) 2026 The Authgebra Rights Holder. All rights reserved.
|
|
5
|
+
|
|
6
|
+
本仓库及其全部内容(包括但不限于源代码、二进制、文档、设计、数据集、
|
|
7
|
+
基准报告、测试与部署脚本,以下合称"本软件")是**专有且保密的**(proprietary
|
|
8
|
+
and confidential),受著作权法及国际著作权条约保护。
|
|
9
|
+
|
|
10
|
+
一、无许可授予
|
|
11
|
+
|
|
12
|
+
未经权利人事先书面授权,任何人不得:
|
|
13
|
+
|
|
14
|
+
1. 复制、分发、出租、出借、出售、转授权或以其他方式向第三方提供本软件
|
|
15
|
+
或其任何部分;
|
|
16
|
+
2. 修改、改编、翻译、演绎本软件,或基于本软件创作衍生作品;
|
|
17
|
+
3. 反向工程、反编译或反汇编本软件,法律明确不可排除者除外;
|
|
18
|
+
4. 移除、遮蔽或篡改本软件中的任何著作权、商标或其他权利声明;
|
|
19
|
+
5. 将本软件或其任何部分用于训练、微调、蒸馏或评估任何机器学习模型;
|
|
20
|
+
6. 将本软件作为服务对外提供(包括但不限于 SaaS、托管、API 转售)。
|
|
21
|
+
|
|
22
|
+
二、无担保
|
|
23
|
+
|
|
24
|
+
本软件按"现状"提供,不附带任何明示或默示的担保,包括但不限于对适销性、
|
|
25
|
+
特定用途适用性及不侵权的担保。在任何情况下,权利人不对任何索赔、损害
|
|
26
|
+
或其他责任承担责任,无论是在合同诉讼、侵权行为还是其他方面。
|
|
27
|
+
|
|
28
|
+
三、第三方组件
|
|
29
|
+
|
|
30
|
+
本软件包含或链接第三方开源组件,各自适用其自身许可证;这些组件清单与
|
|
31
|
+
适用条款见 `Cargo.lock`、`fronted/admin/pnpm-lock.yaml` 及
|
|
32
|
+
`docs/05-代码治理/02-依赖决策记录.md`。本节不改变上述组件原有的许可条件,
|
|
33
|
+
也不授予对本软件第一方代码的任何权利。
|
|
34
|
+
|
|
35
|
+
四、商业授权
|
|
36
|
+
|
|
37
|
+
如需获取商业授权、评估许可、OEM 或定制交付,请联系权利人。
|
|
38
|
+
|
|
39
|
+
五、终止
|
|
40
|
+
|
|
41
|
+
任何违反本许可的行为将自动终止本许可下的全部权利,且不影响权利人
|
|
42
|
+
追究其他救济的权利。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
authgebra
|