justdeploy-sdk 0.2.2__tar.gz → 0.2.3__tar.gz
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.
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/PKG-INFO +44 -25
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/README.md +43 -24
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/_auth.py +21 -8
- justdeploy_sdk-0.2.3/src/justdeploy/_version.py +1 -0
- justdeploy_sdk-0.2.2/src/justdeploy/_version.py +0 -1
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/.gitignore +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/LICENSE +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/pyproject.toml +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/__init__.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/_response.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/_transport.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/_validation.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/client.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/databases.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/errors.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/mail.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/py.typed +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/storages.py +0 -0
- {justdeploy_sdk-0.2.2 → justdeploy_sdk-0.2.3}/src/justdeploy/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: justdeploy-sdk
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Official server-side Python SDK for JustDeploy
|
|
5
5
|
Project-URL: Homepage, https://github.com/cuppasoft/justdeploy-sdk
|
|
6
6
|
Project-URL: Issues, https://github.com/cuppasoft/justdeploy-sdk/issues
|
|
@@ -25,10 +25,22 @@ The official JustDeploy SDK for server-side CPython 3.12, 3.13, and 3.14. Import
|
|
|
25
25
|
|
|
26
26
|
Production supports local Credential authentication and automatic identity in deployed web, API, and cron applications. Development SDK access remains limited to Playground.
|
|
27
27
|
|
|
28
|
+
## Setup through your AI
|
|
29
|
+
|
|
30
|
+
Use **AI Plugin** in [Console](https://console.justdeploy.ai/console/mcp) to connect
|
|
31
|
+
your desktop AI, then ask it to prepare your app’s resources and table structure.
|
|
32
|
+
The SDK runs in your app; the Plugin runs in your AI. Never reuse personal Plugin
|
|
33
|
+
credentials in application code. See the [shared setup and API boundary](../README.md#external-api-scope)
|
|
34
|
+
and the [application API reference](https://www.justdeploy.ai/docs/api).
|
|
35
|
+
|
|
36
|
+
In Development and Production, resource lists and table-management methods return
|
|
37
|
+
`403`; use your connected AI through MCP for those operations. The runtime examples below use IDs supplied through
|
|
38
|
+
server environment variables and tables already prepared through MCP.
|
|
39
|
+
|
|
28
40
|
## Install
|
|
29
41
|
|
|
30
42
|
```bash
|
|
31
|
-
python -m pip install justdeploy-sdk==0.2.
|
|
43
|
+
python -m pip install justdeploy-sdk==0.2.3
|
|
32
44
|
```
|
|
33
45
|
|
|
34
46
|
## Client
|
|
@@ -55,33 +67,19 @@ async def read_orders() -> None:
|
|
|
55
67
|
|
|
56
68
|
For local development, set both `JUSTDEPLOY_ACCESS_KEY` and `JUSTDEPLOY_SECRET_KEY` in the process environment, using a Production Credential and resource IDs from the same organization. Deployed JustDeploy applications need no SDK configuration. A local client cannot use Development Credentials; test a Development organization in its deployed Playground app. If a deployed application explicitly keeps both variables, the SDK accepts and prioritizes them; build feedback recommends the simpler automatic deployment identity without blocking the build.
|
|
57
69
|
|
|
70
|
+
With a manually configured Credential, set `JUSTDEPLOY_ORGANIZATION_ID` to the owning organization's UID to route token requests to its region. For automatic authentication, the SDK uses the organization UID from the deployment identity when present. Requests without a UID use the compatibility route.
|
|
71
|
+
|
|
58
72
|
## Database
|
|
59
73
|
|
|
60
74
|
The examples below run inside an open `with JustDeploy() as justdeploy:` block, using your existing resource IDs. Prepare schema once before starting the application, not on each startup.
|
|
61
75
|
|
|
62
76
|
```python
|
|
63
|
-
databases = justdeploy.databases.list()
|
|
64
77
|
result = justdeploy.databases.query(database_id, "SELECT * FROM orders WHERE customer = ?", params=[customer])
|
|
65
|
-
|
|
66
|
-
tables = justdeploy.databases.list_tables(database_id)
|
|
67
|
-
table = justdeploy.databases.create_table(
|
|
68
|
-
database_id,
|
|
69
|
-
{
|
|
70
|
-
"name": "orders",
|
|
71
|
-
"columns": [{"name": "customer", "type": "string", "nullable": False}],
|
|
72
|
-
},
|
|
73
|
-
)
|
|
74
|
-
justdeploy.databases.update_table(
|
|
75
|
-
database_id,
|
|
76
|
-
"orders",
|
|
77
|
-
{
|
|
78
|
-
"add": [{"name": "paid", "type": "boolean", "default": False}],
|
|
79
|
-
},
|
|
80
|
-
)
|
|
81
|
-
justdeploy.databases.delete_table(database_id, "orders")
|
|
82
78
|
```
|
|
83
79
|
|
|
84
|
-
`query` accepts only the data statements allowed by the JustDeploy API.
|
|
80
|
+
`query` accepts only the data statements allowed by the JustDeploy API. Ask your
|
|
81
|
+
connected AI to change the schema through MCP; do not create tables on app startup.
|
|
82
|
+
Add `await` to each call when using `AsyncJustDeploy`.
|
|
85
83
|
|
|
86
84
|
A read returns `{"rows": [...]}`; a write returns `{"id": ...}`, not `affectedRows`. Separate calls do not share a transaction.
|
|
87
85
|
|
|
@@ -121,7 +119,6 @@ Every call prepares a **new file** and is never automatically retried. A lost re
|
|
|
121
119
|
### Server files: upload bytes or a stream
|
|
122
120
|
|
|
123
121
|
```python
|
|
124
|
-
storages = justdeploy.storages.list()
|
|
125
122
|
file = justdeploy.storages.upload(
|
|
126
123
|
storage_id,
|
|
127
124
|
name="hello.txt",
|
|
@@ -129,7 +126,6 @@ file = justdeploy.storages.upload(
|
|
|
129
126
|
data=b"hello",
|
|
130
127
|
)
|
|
131
128
|
|
|
132
|
-
page = justdeploy.storages.list_files(storage_id, limit=50)
|
|
133
129
|
info = justdeploy.storages.get_file(storage_id, file["id"])
|
|
134
130
|
|
|
135
131
|
with justdeploy.storages.download(storage_id, file["id"]) as download:
|
|
@@ -156,7 +152,8 @@ If a download races with a still-finishing upload, retry after the SDK's clear p
|
|
|
156
152
|
|
|
157
153
|
Upload results have no signed URL. `file["size"]` is the number of bytes successfully transferred. After PUT succeeds, the file can be read without waiting for `active`; metadata may still be `pending`. Before PUT succeeds, `pending` alone does not prove bytes exist. Use `get_file` again only when final metadata is needed. Save the file ID, not the expiring URL.
|
|
158
154
|
|
|
159
|
-
Returned JSON keys stay camelCase in Python.
|
|
155
|
+
Returned JSON keys stay camelCase in Python. Keep the file ID returned by upload
|
|
156
|
+
for later reads and deletion; do not list files to rediscover it.
|
|
160
157
|
|
|
161
158
|
Transfer failures are safe SDK errors, not unchanged exceptions from your byte source. Failed uploads try to remove the pending record; cleanup failure does not replace the transfer error or cancellation.
|
|
162
159
|
|
|
@@ -173,12 +170,34 @@ mail = justdeploy.mail.send(
|
|
|
173
170
|
idempotency_key="welcome-user-123",
|
|
174
171
|
)
|
|
175
172
|
|
|
176
|
-
page = justdeploy.mail.list(limit=50)
|
|
177
173
|
current = justdeploy.mail.get(mail["id"])
|
|
178
174
|
```
|
|
179
175
|
|
|
180
176
|
Use one `idempotency_key` per operation. A retry keeps its key and content; each new password reset needs a new key. The same key with different content is rejected with 409. SDK input uses `sender`; REST input and returned records use `from`. `delivered` means the receiving server accepted the message, not inbox placement. See the shared [Mail and tracking rules](../README.md#request-behavior).
|
|
181
177
|
|
|
178
|
+
## Existing Production management methods
|
|
179
|
+
|
|
180
|
+
These methods remain available in the published SDK for existing Production apps.
|
|
181
|
+
They return `403` in Development. Use MCP for new resource-discovery and schema workflows.
|
|
182
|
+
Async clients expose the same methods with `await`.
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
databases = justdeploy.databases.list()
|
|
186
|
+
tables = justdeploy.databases.list_tables(database_id)
|
|
187
|
+
table = justdeploy.databases.create_table(
|
|
188
|
+
database_id,
|
|
189
|
+
{"name": "orders", "columns": [{"name": "customer", "type": "string", "nullable": False}]},
|
|
190
|
+
)
|
|
191
|
+
justdeploy.databases.update_table(database_id, "orders", {"add": [{"name": "paid", "type": "boolean", "default": False}]})
|
|
192
|
+
justdeploy.databases.delete_table(database_id, "orders")
|
|
193
|
+
storages = justdeploy.storages.list()
|
|
194
|
+
files = justdeploy.storages.list_files(storage_id, limit=50)
|
|
195
|
+
mails = justdeploy.mail.list(limit=50)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
For lists that support pagination, pass `nextCursor` as `cursor` until it is None;
|
|
199
|
+
there is no `next_cursor` response key.
|
|
200
|
+
|
|
182
201
|
## Errors and cancellation
|
|
183
202
|
|
|
184
203
|
Handle SDK failures with `JustDeployError`. API errors expose `status`, `retry_after`, `request_id`, and `details`. For diagnostics, record only `status` and `request_id`, not the whole error, request, SQL, file contents, or credentials. Cancellation does not prove a write was rolled back. Authentication and API time limits are separate; see [request behavior](../README.md#request-behavior).
|
|
@@ -4,10 +4,22 @@ The official JustDeploy SDK for server-side CPython 3.12, 3.13, and 3.14. Import
|
|
|
4
4
|
|
|
5
5
|
Production supports local Credential authentication and automatic identity in deployed web, API, and cron applications. Development SDK access remains limited to Playground.
|
|
6
6
|
|
|
7
|
+
## Setup through your AI
|
|
8
|
+
|
|
9
|
+
Use **AI Plugin** in [Console](https://console.justdeploy.ai/console/mcp) to connect
|
|
10
|
+
your desktop AI, then ask it to prepare your app’s resources and table structure.
|
|
11
|
+
The SDK runs in your app; the Plugin runs in your AI. Never reuse personal Plugin
|
|
12
|
+
credentials in application code. See the [shared setup and API boundary](../README.md#external-api-scope)
|
|
13
|
+
and the [application API reference](https://www.justdeploy.ai/docs/api).
|
|
14
|
+
|
|
15
|
+
In Development and Production, resource lists and table-management methods return
|
|
16
|
+
`403`; use your connected AI through MCP for those operations. The runtime examples below use IDs supplied through
|
|
17
|
+
server environment variables and tables already prepared through MCP.
|
|
18
|
+
|
|
7
19
|
## Install
|
|
8
20
|
|
|
9
21
|
```bash
|
|
10
|
-
python -m pip install justdeploy-sdk==0.2.
|
|
22
|
+
python -m pip install justdeploy-sdk==0.2.3
|
|
11
23
|
```
|
|
12
24
|
|
|
13
25
|
## Client
|
|
@@ -34,33 +46,19 @@ async def read_orders() -> None:
|
|
|
34
46
|
|
|
35
47
|
For local development, set both `JUSTDEPLOY_ACCESS_KEY` and `JUSTDEPLOY_SECRET_KEY` in the process environment, using a Production Credential and resource IDs from the same organization. Deployed JustDeploy applications need no SDK configuration. A local client cannot use Development Credentials; test a Development organization in its deployed Playground app. If a deployed application explicitly keeps both variables, the SDK accepts and prioritizes them; build feedback recommends the simpler automatic deployment identity without blocking the build.
|
|
36
48
|
|
|
49
|
+
With a manually configured Credential, set `JUSTDEPLOY_ORGANIZATION_ID` to the owning organization's UID to route token requests to its region. For automatic authentication, the SDK uses the organization UID from the deployment identity when present. Requests without a UID use the compatibility route.
|
|
50
|
+
|
|
37
51
|
## Database
|
|
38
52
|
|
|
39
53
|
The examples below run inside an open `with JustDeploy() as justdeploy:` block, using your existing resource IDs. Prepare schema once before starting the application, not on each startup.
|
|
40
54
|
|
|
41
55
|
```python
|
|
42
|
-
databases = justdeploy.databases.list()
|
|
43
56
|
result = justdeploy.databases.query(database_id, "SELECT * FROM orders WHERE customer = ?", params=[customer])
|
|
44
|
-
|
|
45
|
-
tables = justdeploy.databases.list_tables(database_id)
|
|
46
|
-
table = justdeploy.databases.create_table(
|
|
47
|
-
database_id,
|
|
48
|
-
{
|
|
49
|
-
"name": "orders",
|
|
50
|
-
"columns": [{"name": "customer", "type": "string", "nullable": False}],
|
|
51
|
-
},
|
|
52
|
-
)
|
|
53
|
-
justdeploy.databases.update_table(
|
|
54
|
-
database_id,
|
|
55
|
-
"orders",
|
|
56
|
-
{
|
|
57
|
-
"add": [{"name": "paid", "type": "boolean", "default": False}],
|
|
58
|
-
},
|
|
59
|
-
)
|
|
60
|
-
justdeploy.databases.delete_table(database_id, "orders")
|
|
61
57
|
```
|
|
62
58
|
|
|
63
|
-
`query` accepts only the data statements allowed by the JustDeploy API.
|
|
59
|
+
`query` accepts only the data statements allowed by the JustDeploy API. Ask your
|
|
60
|
+
connected AI to change the schema through MCP; do not create tables on app startup.
|
|
61
|
+
Add `await` to each call when using `AsyncJustDeploy`.
|
|
64
62
|
|
|
65
63
|
A read returns `{"rows": [...]}`; a write returns `{"id": ...}`, not `affectedRows`. Separate calls do not share a transaction.
|
|
66
64
|
|
|
@@ -100,7 +98,6 @@ Every call prepares a **new file** and is never automatically retried. A lost re
|
|
|
100
98
|
### Server files: upload bytes or a stream
|
|
101
99
|
|
|
102
100
|
```python
|
|
103
|
-
storages = justdeploy.storages.list()
|
|
104
101
|
file = justdeploy.storages.upload(
|
|
105
102
|
storage_id,
|
|
106
103
|
name="hello.txt",
|
|
@@ -108,7 +105,6 @@ file = justdeploy.storages.upload(
|
|
|
108
105
|
data=b"hello",
|
|
109
106
|
)
|
|
110
107
|
|
|
111
|
-
page = justdeploy.storages.list_files(storage_id, limit=50)
|
|
112
108
|
info = justdeploy.storages.get_file(storage_id, file["id"])
|
|
113
109
|
|
|
114
110
|
with justdeploy.storages.download(storage_id, file["id"]) as download:
|
|
@@ -135,7 +131,8 @@ If a download races with a still-finishing upload, retry after the SDK's clear p
|
|
|
135
131
|
|
|
136
132
|
Upload results have no signed URL. `file["size"]` is the number of bytes successfully transferred. After PUT succeeds, the file can be read without waiting for `active`; metadata may still be `pending`. Before PUT succeeds, `pending` alone does not prove bytes exist. Use `get_file` again only when final metadata is needed. Save the file ID, not the expiring URL.
|
|
137
133
|
|
|
138
|
-
Returned JSON keys stay camelCase in Python.
|
|
134
|
+
Returned JSON keys stay camelCase in Python. Keep the file ID returned by upload
|
|
135
|
+
for later reads and deletion; do not list files to rediscover it.
|
|
139
136
|
|
|
140
137
|
Transfer failures are safe SDK errors, not unchanged exceptions from your byte source. Failed uploads try to remove the pending record; cleanup failure does not replace the transfer error or cancellation.
|
|
141
138
|
|
|
@@ -152,12 +149,34 @@ mail = justdeploy.mail.send(
|
|
|
152
149
|
idempotency_key="welcome-user-123",
|
|
153
150
|
)
|
|
154
151
|
|
|
155
|
-
page = justdeploy.mail.list(limit=50)
|
|
156
152
|
current = justdeploy.mail.get(mail["id"])
|
|
157
153
|
```
|
|
158
154
|
|
|
159
155
|
Use one `idempotency_key` per operation. A retry keeps its key and content; each new password reset needs a new key. The same key with different content is rejected with 409. SDK input uses `sender`; REST input and returned records use `from`. `delivered` means the receiving server accepted the message, not inbox placement. See the shared [Mail and tracking rules](../README.md#request-behavior).
|
|
160
156
|
|
|
157
|
+
## Existing Production management methods
|
|
158
|
+
|
|
159
|
+
These methods remain available in the published SDK for existing Production apps.
|
|
160
|
+
They return `403` in Development. Use MCP for new resource-discovery and schema workflows.
|
|
161
|
+
Async clients expose the same methods with `await`.
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
databases = justdeploy.databases.list()
|
|
165
|
+
tables = justdeploy.databases.list_tables(database_id)
|
|
166
|
+
table = justdeploy.databases.create_table(
|
|
167
|
+
database_id,
|
|
168
|
+
{"name": "orders", "columns": [{"name": "customer", "type": "string", "nullable": False}]},
|
|
169
|
+
)
|
|
170
|
+
justdeploy.databases.update_table(database_id, "orders", {"add": [{"name": "paid", "type": "boolean", "default": False}]})
|
|
171
|
+
justdeploy.databases.delete_table(database_id, "orders")
|
|
172
|
+
storages = justdeploy.storages.list()
|
|
173
|
+
files = justdeploy.storages.list_files(storage_id, limit=50)
|
|
174
|
+
mails = justdeploy.mail.list(limit=50)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
For lists that support pagination, pass `nextCursor` as `cursor` until it is None;
|
|
178
|
+
there is no `next_cursor` response key.
|
|
179
|
+
|
|
161
180
|
## Errors and cancellation
|
|
162
181
|
|
|
163
182
|
Handle SDK failures with `JustDeployError`. API errors expose `status`, `retry_after`, `request_id`, and `details`. For diagnostics, record only `status` and `request_id`, not the whole error, request, SQL, file contents, or credentials. Cancellation does not prove a write was rolled back. Authentication and API time limits are separate; see [request behavior](../README.md#request-behavior).
|
|
@@ -40,6 +40,7 @@ class IdentityDocument:
|
|
|
40
40
|
build_id: str
|
|
41
41
|
private_key: str
|
|
42
42
|
api_origin: str
|
|
43
|
+
organization_id: str | None
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
@dataclass(frozen=True, slots=True)
|
|
@@ -55,6 +56,7 @@ class ResolvedAuthentication:
|
|
|
55
56
|
api_origin: str
|
|
56
57
|
credentials: tuple[str, str] | None
|
|
57
58
|
identity: IdentityDocument | None
|
|
59
|
+
organization_id: str | None
|
|
58
60
|
|
|
59
61
|
|
|
60
62
|
def _validate_api_origin(value: object) -> str:
|
|
@@ -141,7 +143,12 @@ def _parse_identity(path: Path, *, require_build_key: bool) -> IdentityDocument
|
|
|
141
143
|
not isinstance(build_id, str) or BUILD_UUID.fullmatch(build_id) is None or not isinstance(private_key, str) or not private_key
|
|
142
144
|
):
|
|
143
145
|
raise JustDeployConfigurationError("The JustDeploy deployment identity is missing a valid build key.")
|
|
144
|
-
|
|
146
|
+
organization_id = value.get("organizationId")
|
|
147
|
+
if "organizationId" in value and (not isinstance(organization_id, str) or PLATFORM_ID.fullmatch(organization_id) is None):
|
|
148
|
+
raise JustDeployConfigurationError("The JustDeploy organization ID in the deployment identity is invalid.")
|
|
149
|
+
return IdentityDocument(
|
|
150
|
+
protocol_version, str(build_id), str(private_key), _validate_api_origin(value.get("apiBaseUrl")), organization_id
|
|
151
|
+
)
|
|
145
152
|
|
|
146
153
|
|
|
147
154
|
def _resolve_authentication(env: Mapping[str, str], identity_path: Path) -> ResolvedAuthentication:
|
|
@@ -156,17 +163,22 @@ def _resolve_authentication(env: Mapping[str, str], identity_path: Path) -> Reso
|
|
|
156
163
|
api_origin = identity.api_origin if identity else DEFAULT_API_ORIGIN
|
|
157
164
|
if has_access and has_secret:
|
|
158
165
|
assert access is not None and secret is not None
|
|
159
|
-
|
|
166
|
+
organization_id = env.get("JUSTDEPLOY_ORGANIZATION_ID")
|
|
167
|
+
if organization_id is not None and PLATFORM_ID.fullmatch(organization_id) is None:
|
|
168
|
+
raise JustDeployConfigurationError("Set JUSTDEPLOY_ORGANIZATION_ID to a valid organization UID.")
|
|
169
|
+
return ResolvedAuthentication(api_origin, (access, secret), None, organization_id)
|
|
160
170
|
if identity is None:
|
|
161
171
|
raise JustDeployAuthenticationError(
|
|
162
172
|
"JustDeploy authentication is not configured. Set JUSTDEPLOY_ACCESS_KEY and JUSTDEPLOY_SECRET_KEY for local development; "
|
|
163
173
|
"deployed JustDeploy applications receive an identity automatically."
|
|
164
174
|
)
|
|
165
|
-
return ResolvedAuthentication(api_origin, None, identity)
|
|
175
|
+
return ResolvedAuthentication(api_origin, None, identity, identity.organization_id)
|
|
166
176
|
|
|
167
177
|
|
|
168
178
|
def _build_request(resolved: ResolvedAuthentication, now: float) -> tuple[str, dict[str, str], dict[str, object]]:
|
|
169
179
|
common_headers = {"accept": "application/json", "content-type": "application/json", "x-justdeploy-sdk": SDK_HEADER}
|
|
180
|
+
if resolved.organization_id is not None:
|
|
181
|
+
common_headers["x-justdeploy-organization"] = resolved.organization_id
|
|
170
182
|
if resolved.credentials:
|
|
171
183
|
access, secret = resolved.credentials
|
|
172
184
|
return (
|
|
@@ -195,7 +207,7 @@ def _build_request(resolved: ResolvedAuthentication, now: float) -> tuple[str, d
|
|
|
195
207
|
)
|
|
196
208
|
|
|
197
209
|
|
|
198
|
-
def _session_from_response(response: httpx.Response, api_origin: str, now: float) -> AuthSession:
|
|
210
|
+
def _session_from_response(response: httpx.Response, api_origin: str, now: float, expected_organization_id: str | None) -> AuthSession:
|
|
199
211
|
if not response.is_success:
|
|
200
212
|
message = "JustDeploy authentication was rejected."
|
|
201
213
|
details: dict[str, Any] = {}
|
|
@@ -229,6 +241,7 @@ def _session_from_response(response: httpx.Response, api_origin: str, now: float
|
|
|
229
241
|
or not token
|
|
230
242
|
or not isinstance(organization_id, str)
|
|
231
243
|
or PLATFORM_ID.fullmatch(organization_id) is None
|
|
244
|
+
or (expected_organization_id is not None and organization_id != expected_organization_id)
|
|
232
245
|
or expires_at <= now
|
|
233
246
|
):
|
|
234
247
|
raise JustDeployAuthenticationError(
|
|
@@ -285,14 +298,14 @@ class SyncAuthManager:
|
|
|
285
298
|
raise JustDeployAuthenticationError("JustDeploy authentication timed out.") from None
|
|
286
299
|
except httpx.HTTPError:
|
|
287
300
|
raise JustDeployAuthenticationError("JustDeploy authentication failed before the server returned a response.") from None
|
|
288
|
-
return _session_from_response(response, resolved.api_origin, self._clock())
|
|
301
|
+
return _session_from_response(response, resolved.api_origin, self._clock(), resolved.organization_id)
|
|
289
302
|
|
|
290
303
|
def _resolve(self) -> ResolvedAuthentication:
|
|
291
304
|
if self._credential_authentication:
|
|
292
305
|
return self._credential_authentication
|
|
293
306
|
resolved = _resolve_authentication(self._env, self._identity_path)
|
|
294
307
|
if resolved.credentials:
|
|
295
|
-
self._credential_authentication =
|
|
308
|
+
self._credential_authentication = resolved
|
|
296
309
|
return self._credential_authentication
|
|
297
310
|
return resolved
|
|
298
311
|
|
|
@@ -344,13 +357,13 @@ class AsyncAuthManager:
|
|
|
344
357
|
raise JustDeployAuthenticationError("JustDeploy authentication timed out.") from None
|
|
345
358
|
except httpx.HTTPError:
|
|
346
359
|
raise JustDeployAuthenticationError("JustDeploy authentication failed before the server returned a response.") from None
|
|
347
|
-
return _session_from_response(response, resolved.api_origin, self._clock())
|
|
360
|
+
return _session_from_response(response, resolved.api_origin, self._clock(), resolved.organization_id)
|
|
348
361
|
|
|
349
362
|
def _resolve(self) -> ResolvedAuthentication:
|
|
350
363
|
if self._credential_authentication:
|
|
351
364
|
return self._credential_authentication
|
|
352
365
|
resolved = _resolve_authentication(self._env, self._identity_path)
|
|
353
366
|
if resolved.credentials:
|
|
354
|
-
self._credential_authentication =
|
|
367
|
+
self._credential_authentication = resolved
|
|
355
368
|
return self._credential_authentication
|
|
356
369
|
return resolved
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|