interloper-api 0.120.0__tar.gz → 0.122.0__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.
- {interloper_api-0.120.0 → interloper_api-0.122.0}/PKG-INFO +3 -1
- {interloper_api-0.120.0 → interloper_api-0.122.0}/pyproject.toml +4 -1
- {interloper_api-0.120.0 → interloper_api-0.122.0}/pyproject.toml.orig +4 -1
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/app.py +89 -61
- interloper_api-0.122.0/src/interloper_api/authorization.py +1135 -0
- interloper_api-0.122.0/src/interloper_api/cli.py +157 -0
- interloper_api-0.122.0/src/interloper_api/dependencies/__init__.py +78 -0
- interloper_api-0.122.0/src/interloper_api/dependencies/auth.py +225 -0
- interloper_api-0.122.0/src/interloper_api/dependencies/rbac.py +113 -0
- interloper_api-0.122.0/src/interloper_api/dependencies/state.py +152 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/admin.py +15 -24
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/agent.py +38 -41
- interloper_api-0.122.0/src/interloper_api/routes/apps.py +82 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/auth.py +76 -85
- interloper_api-0.122.0/src/interloper_api/routes/authorization.py +328 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/backfills.py +19 -22
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/catalog.py +19 -66
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/components.py +40 -52
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/executions.py +6 -8
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/oauth.py +28 -19
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/organisations.py +70 -93
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/overview.py +10 -13
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/relations.py +6 -8
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/runs.py +73 -36
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/tokens.py +28 -43
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/websocket.py +30 -27
- interloper_api-0.120.0/src/interloper_api/cli.py +0 -62
- interloper_api-0.120.0/src/interloper_api/dependencies/__init__.py +0 -96
- interloper_api-0.120.0/src/interloper_api/dependencies/auth.py +0 -94
- interloper_api-0.120.0/src/interloper_api/dependencies/rbac.py +0 -218
- interloper_api-0.120.0/src/interloper_api/dependencies/state.py +0 -208
- {interloper_api-0.120.0 → interloper_api-0.122.0}/README.md +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/__init__.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/notifications/__init__.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/notifications/base.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/notifications/invitations.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/notifications/super_admins.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/__init__.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/routes/health.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/server.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/utils/__init__.py +0 -0
- {interloper_api-0.120.0 → interloper_api-0.122.0}/src/interloper_api/utils/time.py +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: interloper-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.122.0
|
|
4
4
|
Summary: Interloper FastAPI routes
|
|
5
5
|
Author: Guillaume Onfroy
|
|
6
6
|
Author-email: Guillaume Onfroy <guillaume@digitlcloud.com>
|
|
7
7
|
Requires-Dist: interloper-core
|
|
8
8
|
Requires-Dist: interloper-db
|
|
9
|
+
Requires-Dist: authlib>=1.9,<2
|
|
10
|
+
Requires-Dist: cryptography>=43.0.0
|
|
9
11
|
Requires-Dist: fastapi>=0.115.0
|
|
10
12
|
Requires-Dist: google-auth>=2.0.0
|
|
11
13
|
Requires-Dist: httpx2>=2.13.1
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "interloper-api"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.122.0"
|
|
4
4
|
description = "Interloper FastAPI routes"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"interloper-core",
|
|
9
9
|
"interloper-db",
|
|
10
|
+
"authlib>=1.9,<2",
|
|
11
|
+
"cryptography>=43.0.0",
|
|
10
12
|
"fastapi>=0.115.0",
|
|
11
13
|
"google-auth>=2.0.0",
|
|
12
14
|
"httpx2>=2.13.1",
|
|
@@ -28,6 +30,7 @@ otel = [
|
|
|
28
30
|
|
|
29
31
|
[project.entry-points."interloper.cli"]
|
|
30
32
|
api = "interloper_api.cli:register"
|
|
33
|
+
oauth = "interloper_api.cli:register_oauth"
|
|
31
34
|
|
|
32
35
|
[build-system]
|
|
33
36
|
requires = ["uv_build>=0.12.9,<0.13"]
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# ###############
|
|
4
4
|
[project]
|
|
5
5
|
name = "interloper-api"
|
|
6
|
-
version = "0.
|
|
6
|
+
version = "0.122.0"
|
|
7
7
|
description = "Interloper FastAPI routes"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
authors = [{ name = "Guillaume Onfroy", email = "guillaume@digitlcloud.com" }]
|
|
@@ -11,6 +11,8 @@ requires-python = ">=3.10"
|
|
|
11
11
|
dependencies = [
|
|
12
12
|
"interloper-core",
|
|
13
13
|
"interloper-db",
|
|
14
|
+
"authlib>=1.9,<2",
|
|
15
|
+
"cryptography>=43.0.0",
|
|
14
16
|
"fastapi>=0.115.0",
|
|
15
17
|
"google-auth>=2.0.0",
|
|
16
18
|
"httpx2>=2.13.1",
|
|
@@ -28,6 +30,7 @@ otel = [
|
|
|
28
30
|
|
|
29
31
|
[project.entry-points."interloper.cli"]
|
|
30
32
|
api = "interloper_api.cli:register"
|
|
33
|
+
oauth = "interloper_api.cli:register_oauth"
|
|
31
34
|
|
|
32
35
|
[build-system]
|
|
33
36
|
requires = ["uv_build>=0.12.9,<0.13"]
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
|
-
from types import ModuleType
|
|
7
6
|
from typing import Any
|
|
8
7
|
|
|
9
8
|
from fastapi import APIRouter, FastAPI, Request
|
|
@@ -21,19 +20,13 @@ from interloper_db import (
|
|
|
21
20
|
Store,
|
|
22
21
|
)
|
|
23
22
|
|
|
24
|
-
from interloper_api.
|
|
25
|
-
|
|
26
|
-
set_agent,
|
|
27
|
-
set_auth_config,
|
|
28
|
-
set_catalog,
|
|
29
|
-
set_features,
|
|
30
|
-
set_quota_defaults,
|
|
31
|
-
set_smtp_config,
|
|
32
|
-
set_store,
|
|
33
|
-
)
|
|
23
|
+
from interloper_api.authorization import AuthorizationServer, CrossOriginMiddleware
|
|
24
|
+
from interloper_api.dependencies import State
|
|
34
25
|
from interloper_api.routes import (
|
|
35
26
|
admin,
|
|
27
|
+
apps,
|
|
36
28
|
auth,
|
|
29
|
+
authorization,
|
|
37
30
|
backfills,
|
|
38
31
|
components,
|
|
39
32
|
executions,
|
|
@@ -50,25 +43,37 @@ from interloper_api.routes import catalog as catalog_routes
|
|
|
50
43
|
|
|
51
44
|
logger = logging.getLogger(__name__)
|
|
52
45
|
|
|
53
|
-
#: Routers mounted under ``/api`` for every deployment
|
|
54
|
-
#:
|
|
55
|
-
|
|
56
|
-
auth,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
overview,
|
|
66
|
-
oauth,
|
|
67
|
-
tokens,
|
|
68
|
-
websocket,
|
|
69
|
-
health,
|
|
46
|
+
#: Routers mounted under ``/api`` for every deployment: the caller's own, the
|
|
47
|
+
#: organisation management and super-admin ones, a run's ingest, and the probes.
|
|
48
|
+
_ROUTERS: tuple[APIRouter, ...] = (
|
|
49
|
+
auth.router,
|
|
50
|
+
authorization.router,
|
|
51
|
+
organisations.router,
|
|
52
|
+
admin.router,
|
|
53
|
+
oauth.router,
|
|
54
|
+
tokens.router,
|
|
55
|
+
apps.router,
|
|
56
|
+
runs.router,
|
|
57
|
+
health.router,
|
|
70
58
|
)
|
|
71
59
|
|
|
60
|
+
#: Routers acting in one organisation, mounted under ``/api/organisations/{org_id}``.
|
|
61
|
+
#: The agent router is absent by design: it is optional and mounted by
|
|
62
|
+
#: :func:`_mount_agent`.
|
|
63
|
+
_ORG_ROUTERS: tuple[APIRouter, ...] = (
|
|
64
|
+
organisations.org_router,
|
|
65
|
+
catalog_routes.org_router,
|
|
66
|
+
components.org_router,
|
|
67
|
+
relations.org_router,
|
|
68
|
+
runs.org_router,
|
|
69
|
+
executions.org_router,
|
|
70
|
+
backfills.org_router,
|
|
71
|
+
overview.org_router,
|
|
72
|
+
websocket.org_router,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
ORG_PREFIX = "/organisations/{org_id}"
|
|
76
|
+
|
|
72
77
|
|
|
73
78
|
# -- Error handling ------------------------------------------------------------
|
|
74
79
|
|
|
@@ -202,17 +207,19 @@ def create_app(
|
|
|
202
207
|
allow_methods=["*"],
|
|
203
208
|
allow_headers=["*"],
|
|
204
209
|
)
|
|
210
|
+
# Added last, so it answers a client-facing endpoint's preflight before the policy above can refuse it.
|
|
211
|
+
app.add_middleware(CrossOriginMiddleware)
|
|
205
212
|
|
|
206
213
|
api = APIRouter(prefix="/api")
|
|
207
|
-
for
|
|
208
|
-
api.include_router(
|
|
214
|
+
for router in _ROUTERS:
|
|
215
|
+
api.include_router(router)
|
|
216
|
+
for org_router in _ORG_ROUTERS:
|
|
217
|
+
api.include_router(org_router, prefix=ORG_PREFIX)
|
|
209
218
|
agent_available = _mount_agent(api, settings)
|
|
210
219
|
app.include_router(api)
|
|
220
|
+
app.include_router(authorization.well_known_router)
|
|
211
221
|
|
|
212
|
-
|
|
213
|
-
# whether the agent actually mounted. Routes read state per request, never
|
|
214
|
-
# at mount time, so the order is safe.
|
|
215
|
-
_install_state(store, catalog, settings, agent_available=agent_available)
|
|
222
|
+
app.state.interloper = _state(store, catalog, settings, agent_available=agent_available)
|
|
216
223
|
|
|
217
224
|
oauth.log_provider_status()
|
|
218
225
|
|
|
@@ -223,7 +230,7 @@ def create_app(
|
|
|
223
230
|
|
|
224
231
|
|
|
225
232
|
def _mount_agent(api: APIRouter, settings: Any | None) -> bool:
|
|
226
|
-
"""Mount the optional agent routes, reporting whether they are available.
|
|
233
|
+
"""Mount the optional agent routes under the organisation prefix, reporting whether they are available.
|
|
227
234
|
|
|
228
235
|
Args:
|
|
229
236
|
api: The ``/api`` router to mount onto.
|
|
@@ -246,42 +253,63 @@ def _mount_agent(api: APIRouter, settings: Any | None) -> bool:
|
|
|
246
253
|
)
|
|
247
254
|
return False
|
|
248
255
|
|
|
249
|
-
api.include_router(agent_routes.
|
|
256
|
+
api.include_router(agent_routes.org_router, prefix=ORG_PREFIX)
|
|
250
257
|
return True
|
|
251
258
|
|
|
252
259
|
|
|
253
|
-
def
|
|
254
|
-
|
|
255
|
-
catalog: Catalog | None,
|
|
256
|
-
settings: Any | None,
|
|
257
|
-
*,
|
|
258
|
-
agent_available: bool,
|
|
259
|
-
) -> None:
|
|
260
|
-
"""Install the process-wide state the request dependencies read back.
|
|
260
|
+
def _state(store: Store | None, catalog: Catalog | None, settings: Any | None, *, agent_available: bool) -> State:
|
|
261
|
+
"""Build the state the request dependencies read back.
|
|
261
262
|
|
|
262
263
|
Args:
|
|
263
|
-
store: The ``Store`` instance, or ``None
|
|
264
|
-
catalog: Catalog instance, or ``None
|
|
265
|
-
settings: Full ``AppSettings``, or ``None``
|
|
266
|
-
|
|
264
|
+
store: The ``Store`` instance, or ``None``.
|
|
265
|
+
catalog: Catalog instance, or ``None``.
|
|
266
|
+
settings: Full ``AppSettings``, or ``None`` for neither an
|
|
267
|
+
authorization server nor an admin config snapshot.
|
|
267
268
|
agent_available: Whether the agent routes mounted, recorded as a
|
|
268
269
|
feature flag and in the admin config snapshot.
|
|
270
|
+
|
|
271
|
+
Returns:
|
|
272
|
+
The state.
|
|
269
273
|
"""
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if catalog:
|
|
273
|
-
set_catalog(catalog)
|
|
274
|
+
features = {"agent": agent_available}
|
|
275
|
+
agent = None
|
|
274
276
|
if agent_available:
|
|
275
277
|
from interloper.settings import AgentSettings
|
|
276
278
|
from interloper_agent import build_agent
|
|
277
279
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
+
agent = build_agent(settings.agent.model if settings else AgentSettings().model)
|
|
281
|
+
if settings is None:
|
|
282
|
+
return State(store=store, catalog=catalog, agent=agent, features=features)
|
|
283
|
+
return State(
|
|
284
|
+
store=store,
|
|
285
|
+
catalog=catalog,
|
|
286
|
+
settings=settings,
|
|
287
|
+
agent=agent,
|
|
288
|
+
features=features,
|
|
289
|
+
admin_config=admin.AdminConfigResponse.from_settings(settings, features=features, catalog=catalog),
|
|
290
|
+
authorization_server=_authorization_server(store, settings),
|
|
291
|
+
)
|
|
280
292
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
293
|
+
|
|
294
|
+
def _authorization_server(store: Store | None, settings: Any) -> AuthorizationServer | None:
|
|
295
|
+
"""Build the OAuth authorization server, when the deployment can run one.
|
|
296
|
+
|
|
297
|
+
Args:
|
|
298
|
+
store: The ``Store`` instance, or ``None``.
|
|
299
|
+
settings: Full ``AppSettings``.
|
|
300
|
+
|
|
301
|
+
Returns:
|
|
302
|
+
The server, or ``None`` without a store, without an encryption key
|
|
303
|
+
(which seals the authorization request while the user decides), or
|
|
304
|
+
when the issuer is refused (plain http on a non-loopback host).
|
|
305
|
+
"""
|
|
306
|
+
if store is None:
|
|
307
|
+
return None
|
|
308
|
+
if not settings.secrets.encryption_key:
|
|
309
|
+
logger.warning("OAuth authorization server not mounted: INTERLOPER_ENCRYPTION_KEY is not configured.")
|
|
310
|
+
return None
|
|
311
|
+
try:
|
|
312
|
+
return AuthorizationServer.from_settings(store, settings)
|
|
313
|
+
except ValueError as error:
|
|
314
|
+
logger.warning("OAuth authorization server not mounted: %s (server.external_url).", error)
|
|
315
|
+
return None
|