keepup-admin 0.5.0__tar.gz → 0.6.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.
- {keepup_admin-0.5.0/keepup_admin.egg-info → keepup_admin-0.6.0}/PKG-INFO +3 -1
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/builtin/auth.py +3 -2
- {keepup_admin-0.5.0 → keepup_admin-0.6.0/keepup_admin.egg-info}/PKG-INFO +3 -1
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/keepup_admin.egg-info/requires.txt +3 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/lifecycle.py +6 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/observability.py +54 -2
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/plugins/builtin.json +20 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/pyproject.toml +6 -2
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/LICENSE +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/NOTICE +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/README.md +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/THIRD-PARTY.md +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/__init__.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/api_versions.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/builtin/audit.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/builtin/db.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/builtin/postgres.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/builtin/sqlite.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/builtin/ui.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/builtin/users.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/cache.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/clock.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/instance.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/keepup_admin.egg-info/SOURCES.txt +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/keepup_admin.egg-info/dependency_links.txt +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/keepup_admin.egg-info/top_level.txt +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/__init__.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/call.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/catalogue.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/contributions.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/datasource.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/descriptor.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/loader.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/security.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/services.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/kernel/transports.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/locks.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/logging_setup.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/notification_bus.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/plugins/__init__.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/plugins/base.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/plugins/enablement.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/plugins/registry.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/plugins/route_mask.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/roles.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/sections.json +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/security.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/settings.py +0 -0
- {keepup_admin-0.5.0 → keepup_admin-0.6.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: keepup-admin
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: An admin framework over FastAPI: plugins, panel, users, replicas
|
|
5
5
|
Author-email: Fedor Sergeev <fksergeev@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -49,6 +49,8 @@ Provides-Extra: http
|
|
|
49
49
|
Requires-Dist: keepup-http>=0.4.0; extra == "http"
|
|
50
50
|
Provides-Extra: integration-log
|
|
51
51
|
Requires-Dist: keepup-integration-log>=0.4.0; extra == "integration-log"
|
|
52
|
+
Provides-Extra: gateway
|
|
53
|
+
Requires-Dist: keepup-gateway>=0.5.0; extra == "gateway"
|
|
52
54
|
Provides-Extra: panel
|
|
53
55
|
Requires-Dist: keepup-db>=0.4.0; extra == "panel"
|
|
54
56
|
Requires-Dist: keepup-auth>=0.4.0; extra == "panel"
|
|
@@ -108,11 +108,12 @@ class AuthPlugin(BasePlugin):
|
|
|
108
108
|
pass
|
|
109
109
|
|
|
110
110
|
def get_declared_tables(self) -> List[Any]:
|
|
111
|
-
"""The
|
|
111
|
+
"""The tables this capability owns, declared once, until keepup-124."""
|
|
112
|
+
from keepup_auth.tables import AUTH_RATE_LIMIT, AUTH_TOTP
|
|
112
113
|
from keepup_auth.login_throttle import LOGIN_ATTEMPTS
|
|
113
114
|
from keepup_auth.panel_session import AUTH_SESSION
|
|
114
115
|
|
|
115
|
-
return [AUTH_SESSION, LOGIN_ATTEMPTS]
|
|
116
|
+
return [AUTH_SESSION, LOGIN_ATTEMPTS, AUTH_RATE_LIMIT, AUTH_TOTP]
|
|
116
117
|
|
|
117
118
|
def get_route_permissions(self) -> Dict[str, Any]:
|
|
118
119
|
"""The rights this capability's routes ask for, by name.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: keepup-admin
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: An admin framework over FastAPI: plugins, panel, users, replicas
|
|
5
5
|
Author-email: Fedor Sergeev <fksergeev@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -49,6 +49,8 @@ Provides-Extra: http
|
|
|
49
49
|
Requires-Dist: keepup-http>=0.4.0; extra == "http"
|
|
50
50
|
Provides-Extra: integration-log
|
|
51
51
|
Requires-Dist: keepup-integration-log>=0.4.0; extra == "integration-log"
|
|
52
|
+
Provides-Extra: gateway
|
|
53
|
+
Requires-Dist: keepup-gateway>=0.5.0; extra == "gateway"
|
|
52
54
|
Provides-Extra: panel
|
|
53
55
|
Requires-Dist: keepup-db>=0.4.0; extra == "panel"
|
|
54
56
|
Requires-Dist: keepup-auth>=0.4.0; extra == "panel"
|
|
@@ -175,6 +175,11 @@ class Runtime:
|
|
|
175
175
|
self.loader = loader or PluginLoader(self.plugins_dir, entry_points, builtin_dir=builtin_dir)
|
|
176
176
|
self.catalogue: Dict[str, Any] = {}
|
|
177
177
|
self.contributions = Contributions()
|
|
178
|
+
# The decisions this start took. The panel's plugin report reads it as
|
|
179
|
+
# what is actually running and compares it with the decisions of the
|
|
180
|
+
# moment; empty until the start, so a report asked early answers instead
|
|
181
|
+
# of failing (keepup-167).
|
|
182
|
+
self.resolution = enablement.resolve({}, self.environ, {})
|
|
178
183
|
|
|
179
184
|
# --- what a plugin reaches for ------------------------------------------
|
|
180
185
|
|
|
@@ -638,6 +643,7 @@ class Runtime:
|
|
|
638
643
|
logger.error("The administrator's decisions are unreadable: %s", error)
|
|
639
644
|
overrides = {}
|
|
640
645
|
resolution = enablement.resolve(self.catalogue, self.environ, overrides)
|
|
646
|
+
self.resolution = resolution
|
|
641
647
|
for unknown in resolution.unknown:
|
|
642
648
|
logger.warning(
|
|
643
649
|
"%s/%s name an undeclared plugin: %s",
|
|
@@ -16,12 +16,14 @@ which is a deployment, not a failure.
|
|
|
16
16
|
|
|
17
17
|
from contextlib import asynccontextmanager
|
|
18
18
|
from dataclasses import dataclass, field
|
|
19
|
+
from functools import wraps
|
|
19
20
|
from typing import Any, AsyncIterator, Awaitable, Callable, Mapping, Optional
|
|
20
21
|
|
|
21
22
|
__all__ = [
|
|
22
23
|
"SERVICE_AUDIT",
|
|
23
24
|
"SERVICE_EVENTS",
|
|
24
25
|
"Recording",
|
|
26
|
+
"audited",
|
|
25
27
|
"emit",
|
|
26
28
|
"end_call",
|
|
27
29
|
"recording",
|
|
@@ -76,7 +78,8 @@ def recording() -> Optional[Recording]:
|
|
|
76
78
|
|
|
77
79
|
@asynccontextmanager
|
|
78
80
|
async def start_call(method: str, endpoint: str, host: str,
|
|
79
|
-
request_data: Mapping[str, Any]
|
|
81
|
+
request_data: Mapping[str, Any],
|
|
82
|
+
actor: Optional[Mapping[str, Any]] = None) -> AsyncIterator[Any]:
|
|
80
83
|
"""Open the record of one call, or a record that writes nowhere.
|
|
81
84
|
|
|
82
85
|
Args:
|
|
@@ -84,6 +87,9 @@ async def start_call(method: str, endpoint: str, host: str,
|
|
|
84
87
|
endpoint: the route's path as declared.
|
|
85
88
|
host: what the call came through.
|
|
86
89
|
request_data: what is known about the request.
|
|
90
|
+
actor: who called, when the transport resolved them. Kept apart from
|
|
91
|
+
``request_data`` so that redaction of the body does not hide the
|
|
92
|
+
one fact an incident is read for (keepup-172).
|
|
87
93
|
|
|
88
94
|
Yields:
|
|
89
95
|
The request id the call is finished with.
|
|
@@ -93,7 +99,7 @@ async def start_call(method: str, endpoint: str, host: str,
|
|
|
93
99
|
yield None
|
|
94
100
|
return
|
|
95
101
|
async with current.start(method=method, endpoint=endpoint, host=host,
|
|
96
|
-
request_data=request_data) as request_id:
|
|
102
|
+
request_data=request_data, actor=actor) as request_id:
|
|
97
103
|
yield request_id
|
|
98
104
|
|
|
99
105
|
|
|
@@ -125,3 +131,49 @@ async def emit(event_type: str, payload: Mapping[str, Any] = None) -> int:
|
|
|
125
131
|
await emitter(event_type, payload or {})
|
|
126
132
|
written += 1
|
|
127
133
|
return written
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def audited(action: str, method: str = "POST", actor: str = "current_user",
|
|
137
|
+
host: str = "framework"):
|
|
138
|
+
"""Record a framework route that the transport did not wrap (keepup-172).
|
|
139
|
+
|
|
140
|
+
A plugin route reaches the audit through the route runtime. The framework's
|
|
141
|
+
own administrative routes are FastAPI endpoints, and until now they wrote
|
|
142
|
+
nothing: changing a password, granting ADMIN, toggling a plugin or stopping
|
|
143
|
+
a replica left a line in the rotating application log and no row in the
|
|
144
|
+
audit. This decorator is the same seam for those routes.
|
|
145
|
+
|
|
146
|
+
The actor is read from the keyword argument FastAPI injects (``admin`` for
|
|
147
|
+
most of these routes), never guessed from the body.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
action: what the row is called, e.g. ``users.roles``.
|
|
151
|
+
method: the verb the audit names.
|
|
152
|
+
actor: the keyword argument holding the signed-in account.
|
|
153
|
+
host: what the call came through; the framework's own routes have no
|
|
154
|
+
plugin host.
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
def decorate(handler):
|
|
158
|
+
@wraps(handler)
|
|
159
|
+
async def wrapper(*args, **kwargs):
|
|
160
|
+
caller = kwargs.get(actor)
|
|
161
|
+
async with start_call(method, action, host, {}, actor=caller) as request_id:
|
|
162
|
+
try:
|
|
163
|
+
answer = await handler(*args, **kwargs)
|
|
164
|
+
except Exception as error:
|
|
165
|
+
await end_call(
|
|
166
|
+
request_id,
|
|
167
|
+
getattr(error, "status_code", 500),
|
|
168
|
+
error_message=getattr(error, "detail", type(error).__name__),
|
|
169
|
+
)
|
|
170
|
+
raise
|
|
171
|
+
await end_call(
|
|
172
|
+
request_id, 200,
|
|
173
|
+
response_data=answer if isinstance(answer, dict) else None,
|
|
174
|
+
)
|
|
175
|
+
return answer
|
|
176
|
+
|
|
177
|
+
return wrapper
|
|
178
|
+
|
|
179
|
+
return decorate
|
|
@@ -160,6 +160,26 @@
|
|
|
160
160
|
],
|
|
161
161
|
"distribution": "keepup-integration-log"
|
|
162
162
|
},
|
|
163
|
+
{
|
|
164
|
+
"id": "gateway",
|
|
165
|
+
"name": "Gateway",
|
|
166
|
+
"kind": "optional",
|
|
167
|
+
"priority": 10000,
|
|
168
|
+
"provides": [
|
|
169
|
+
"gateway>=1"
|
|
170
|
+
],
|
|
171
|
+
"wants": [
|
|
172
|
+
"auth>=1",
|
|
173
|
+
"permissions>=1",
|
|
174
|
+
"datasource>=1"
|
|
175
|
+
],
|
|
176
|
+
"contributions": [
|
|
177
|
+
"routes",
|
|
178
|
+
"sections",
|
|
179
|
+
"tables"
|
|
180
|
+
],
|
|
181
|
+
"distribution": "keepup-gateway"
|
|
182
|
+
},
|
|
163
183
|
{
|
|
164
184
|
"id": "audit",
|
|
165
185
|
"name": "Event audit",
|
|
@@ -17,7 +17,7 @@ build-backend = "setuptools.build_meta"
|
|
|
17
17
|
|
|
18
18
|
[project]
|
|
19
19
|
name = "keepup-admin"
|
|
20
|
-
version = "0.
|
|
20
|
+
version = "0.6.0"
|
|
21
21
|
description = "An admin framework over FastAPI: plugins, panel, users, replicas"
|
|
22
22
|
readme = "README.md"
|
|
23
23
|
requires-python = ">=3.11"
|
|
@@ -103,6 +103,9 @@ cluster = ["keepup-cluster>=0.4.0"]
|
|
|
103
103
|
log_shipping = ["keepup-log-shipping>=0.4.0"]
|
|
104
104
|
http = ["keepup-http>=0.4.0"]
|
|
105
105
|
integration_log = ["keepup-integration-log>=0.4.0"]
|
|
106
|
+
# The gateway is not part of the panel: it is the way in for services beside the
|
|
107
|
+
# application, installed and enabled by a deployment that has them.
|
|
108
|
+
gateway = ["keepup-gateway>=0.5.0"]
|
|
106
109
|
|
|
107
110
|
# `pip install keepup-admin[panel,postgres]` is the full admin panel: the
|
|
108
111
|
# capabilities the `panel` profile enables, plus one driver -- one, because two
|
|
@@ -189,6 +192,7 @@ source = [
|
|
|
189
192
|
"keepup_audit",
|
|
190
193
|
"keepup_metrics",
|
|
191
194
|
"keepup_integration_log",
|
|
195
|
+
"keepup_gateway",
|
|
192
196
|
]
|
|
193
197
|
# The tests live inside the package, and without this they would count as
|
|
194
198
|
# their own coverage: a test file that has just run is covered almost
|
|
@@ -237,7 +241,7 @@ asyncio_default_fixture_loop_scope = "function"
|
|
|
237
241
|
python_files = ["*_tests.py", "test_*.py"]
|
|
238
242
|
# The directory above the package, so that `import keepup` resolves whether
|
|
239
243
|
# the package sits in its own repository or inside an application's.
|
|
240
|
-
pythonpath = ["..", "packages/keepup-db", "packages/keepup-postgres", "packages/keepup-sqlite", "packages/keepup-auth", "packages/keepup-users", "packages/keepup-ui", "packages/keepup-audit", "packages/keepup-metrics", "packages/keepup-integration-log"]
|
|
244
|
+
pythonpath = ["..", "packages/keepup-db", "packages/keepup-postgres", "packages/keepup-sqlite", "packages/keepup-auth", "packages/keepup-users", "packages/keepup-ui", "packages/keepup-audit", "packages/keepup-metrics", "packages/keepup-integration-log", "packages/keepup-gateway"]
|
|
241
245
|
markers = [
|
|
242
246
|
"slow: a check that takes seconds rather than milliseconds",
|
|
243
247
|
]
|
|
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
|
|
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
|
|
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
|