keepup-admin 0.3.0__tar.gz → 0.5.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.
Files changed (137) hide show
  1. {keepup_admin-0.3.0/keepup_admin.egg-info → keepup_admin-0.5.0}/PKG-INFO +107 -44
  2. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/README.md +65 -27
  3. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/__init__.py +21 -5
  4. keepup_admin-0.5.0/builtin/audit.py +146 -0
  5. keepup_admin-0.5.0/builtin/auth.py +132 -0
  6. keepup_admin-0.5.0/builtin/db.py +175 -0
  7. keepup_admin-0.5.0/builtin/postgres.py +78 -0
  8. keepup_admin-0.5.0/builtin/sqlite.py +76 -0
  9. keepup_admin-0.5.0/builtin/ui.py +146 -0
  10. keepup_admin-0.5.0/builtin/users.py +136 -0
  11. keepup_admin-0.5.0/clock.py +28 -0
  12. {keepup_admin-0.3.0 → keepup_admin-0.5.0/keepup_admin.egg-info}/PKG-INFO +107 -44
  13. keepup_admin-0.5.0/keepup_admin.egg-info/SOURCES.txt +85 -0
  14. keepup_admin-0.5.0/keepup_admin.egg-info/requires.txt +64 -0
  15. keepup_admin-0.5.0/kernel/__init__.py +120 -0
  16. keepup_admin-0.5.0/kernel/call.py +304 -0
  17. keepup_admin-0.5.0/kernel/catalogue.py +243 -0
  18. keepup_admin-0.5.0/kernel/contributions.py +319 -0
  19. keepup_admin-0.5.0/kernel/datasource.py +95 -0
  20. keepup_admin-0.5.0/kernel/descriptor.py +209 -0
  21. keepup_admin-0.5.0/kernel/lifecycle.py +814 -0
  22. keepup_admin-0.5.0/kernel/loader.py +240 -0
  23. keepup_admin-0.5.0/kernel/observability.py +127 -0
  24. keepup_admin-0.5.0/kernel/security.py +113 -0
  25. keepup_admin-0.5.0/kernel/services.py +290 -0
  26. keepup_admin-0.5.0/kernel/transports.py +119 -0
  27. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/locks.py +29 -145
  28. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/logging_setup.py +7 -43
  29. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/notification_bus.py +85 -113
  30. keepup_admin-0.5.0/plugins/builtin.json +289 -0
  31. keepup_admin-0.5.0/plugins/registry.py +284 -0
  32. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/pyproject.toml +116 -50
  33. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/security.py +1 -1
  34. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/settings.py +11 -9
  35. keepup_admin-0.3.0/admin_trail.py +0 -60
  36. keepup_admin-0.3.0/api_docs.py +0 -76
  37. keepup_admin-0.3.0/audit.py +0 -486
  38. keepup_admin-0.3.0/auth/__init__.py +0 -7
  39. keepup_admin-0.3.0/auth/config.py +0 -128
  40. keepup_admin-0.3.0/auth/dependencies.py +0 -556
  41. keepup_admin-0.3.0/auth/dto/__init__.py +0 -0
  42. keepup_admin-0.3.0/auth/dto/token.py +0 -31
  43. keepup_admin-0.3.0/auth/external_accounts.py +0 -144
  44. keepup_admin-0.3.0/auth/factory.py +0 -28
  45. keepup_admin-0.3.0/auth/identity/__init__.py +0 -33
  46. keepup_admin-0.3.0/auth/identity/access.py +0 -119
  47. keepup_admin-0.3.0/auth/identity/accounts.py +0 -86
  48. keepup_admin-0.3.0/auth/identity/config.py +0 -220
  49. keepup_admin-0.3.0/auth/identity/contract.py +0 -174
  50. keepup_admin-0.3.0/auth/identity/loader.py +0 -119
  51. keepup_admin-0.3.0/auth/identity/runtime.py +0 -265
  52. keepup_admin-0.3.0/auth/login_throttle.py +0 -181
  53. keepup_admin-0.3.0/auth/oidc.py +0 -255
  54. keepup_admin-0.3.0/auth/oidc_policy.py +0 -122
  55. keepup_admin-0.3.0/auth/oidc_routes.py +0 -265
  56. keepup_admin-0.3.0/auth/panel_session.py +0 -386
  57. keepup_admin-0.3.0/auth/permissions.py +0 -59
  58. keepup_admin-0.3.0/auth/providers/__init__.py +0 -0
  59. keepup_admin-0.3.0/auth/providers/base.py +0 -216
  60. keepup_admin-0.3.0/auth/providers/local.py +0 -212
  61. keepup_admin-0.3.0/auth/routes.py +0 -514
  62. keepup_admin-0.3.0/auth/seed_accounts.py +0 -352
  63. keepup_admin-0.3.0/auth/session_lifetime.py +0 -104
  64. keepup_admin-0.3.0/auth/signing_key.py +0 -138
  65. keepup_admin-0.3.0/auth/socket_sessions.py +0 -176
  66. keepup_admin-0.3.0/auth/user_roles.py +0 -376
  67. keepup_admin-0.3.0/auth/user_routes.py +0 -313
  68. keepup_admin-0.3.0/auth/usernames.py +0 -36
  69. keepup_admin-0.3.0/auth/websocket.py +0 -88
  70. keepup_admin-0.3.0/body_limit.py +0 -156
  71. keepup_admin-0.3.0/cluster.py +0 -643
  72. keepup_admin-0.3.0/db.py +0 -603
  73. keepup_admin-0.3.0/events.py +0 -506
  74. keepup_admin-0.3.0/events_api.py +0 -236
  75. keepup_admin-0.3.0/factory.py +0 -609
  76. keepup_admin-0.3.0/integrations.py +0 -224
  77. keepup_admin-0.3.0/keepup_admin.egg-info/SOURCES.txt +0 -213
  78. keepup_admin-0.3.0/keepup_admin.egg-info/requires.txt +0 -25
  79. keepup_admin-0.3.0/log_shipping.py +0 -695
  80. keepup_admin-0.3.0/metrics.py +0 -587
  81. keepup_admin-0.3.0/metrics_api.py +0 -277
  82. keepup_admin-0.3.0/metrics_retention.py +0 -377
  83. keepup_admin-0.3.0/modules.py +0 -688
  84. keepup_admin-0.3.0/plugins/admin.py +0 -271
  85. keepup_admin-0.3.0/plugins/registry.py +0 -190
  86. keepup_admin-0.3.0/plugins/routes.py +0 -518
  87. keepup_admin-0.3.0/positional_sql.py +0 -120
  88. keepup_admin-0.3.0/retention.py +0 -84
  89. keepup_admin-0.3.0/scheduler.py +0 -124
  90. keepup_admin-0.3.0/schema.py +0 -319
  91. keepup_admin-0.3.0/static/css/aos.css +0 -1
  92. keepup_admin-0.3.0/static/css/main_nebula.css +0 -232
  93. keepup_admin-0.3.0/static/css/main_new.css +0 -869
  94. keepup_admin-0.3.0/static/css/tailwind.css +0 -1
  95. keepup_admin-0.3.0/static/index_nebula.html +0 -282
  96. keepup_admin-0.3.0/static/index_new.html +0 -275
  97. keepup_admin-0.3.0/static/js/aos.js +0 -1
  98. keepup_admin-0.3.0/static/js/feather-icons.js +0 -13
  99. keepup_admin-0.3.0/static/js/layout_bootstrap.js +0 -29
  100. keepup_admin-0.3.0/static/js/main_new.js +0 -2076
  101. keepup_admin-0.3.0/static/js/tailwind.js +0 -83
  102. keepup_admin-0.3.0/static/modules/css/background_tasks.css +0 -233
  103. keepup_admin-0.3.0/static/modules/css/cluster.css +0 -16
  104. keepup_admin-0.3.0/static/modules/css/event_manager.css +0 -386
  105. keepup_admin-0.3.0/static/modules/css/integration_logs.css +0 -33
  106. keepup_admin-0.3.0/static/modules/css/metrics.css +0 -115
  107. keepup_admin-0.3.0/static/modules/css/modules.css +0 -189
  108. keepup_admin-0.3.0/static/modules/css/themes.css +0 -563
  109. keepup_admin-0.3.0/static/modules/css/users.css +0 -278
  110. keepup_admin-0.3.0/static/modules/js/background_tasks.js +0 -679
  111. keepup_admin-0.3.0/static/modules/js/chart.js +0 -14
  112. keepup_admin-0.3.0/static/modules/js/chartjs-adapter-date-fns.bundle.min.js +0 -7
  113. keepup_admin-0.3.0/static/modules/js/cluster.js +0 -374
  114. keepup_admin-0.3.0/static/modules/js/event_manager.js +0 -1007
  115. keepup_admin-0.3.0/static/modules/js/integration_logs.js +0 -795
  116. keepup_admin-0.3.0/static/modules/js/metrics.js +0 -929
  117. keepup_admin-0.3.0/static/modules/js/modules.js +0 -1128
  118. keepup_admin-0.3.0/static/modules/js/themes.js +0 -684
  119. keepup_admin-0.3.0/static/modules/js/users.js +0 -898
  120. keepup_admin-0.3.0/tables.py +0 -304
  121. keepup_admin-0.3.0/themes.py +0 -547
  122. keepup_admin-0.3.0/web.py +0 -194
  123. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/LICENSE +0 -0
  124. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/NOTICE +0 -0
  125. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/THIRD-PARTY.md +0 -0
  126. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/api_versions.py +0 -0
  127. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/cache.py +0 -0
  128. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/instance.py +0 -0
  129. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/keepup_admin.egg-info/dependency_links.txt +0 -0
  130. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/keepup_admin.egg-info/top_level.txt +0 -0
  131. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/plugins/__init__.py +0 -0
  132. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/plugins/base.py +0 -0
  133. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/plugins/enablement.py +0 -0
  134. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/plugins/route_mask.py +0 -0
  135. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/roles.py +0 -0
  136. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/sections.json +0 -0
  137. {keepup_admin-0.3.0 → keepup_admin-0.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: keepup-admin
3
- Version: 0.3.0
3
+ Version: 0.5.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
@@ -18,29 +18,54 @@ Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
19
  License-File: NOTICE
20
20
  License-File: THIRD-PARTY.md
21
- Requires-Dist: fastapi<1,>=0.128
22
- Requires-Dist: starlette<2,>=1.3.1
23
- Requires-Dist: pydantic<3,>=2.11
24
- Requires-Dist: sqlalchemy<3,>=2.0
25
- Requires-Dist: psycopg2-binary>=2.9
26
- Requires-Dist: apscheduler<4,>=3.10
27
- Requires-Dist: bcrypt<5,>=4.0
28
- Requires-Dist: pyjwt[crypto]<3,>=2.15
29
21
  Requires-Dist: python-multipart>=0.0.31
30
- Requires-Dist: PyYAML<7,>=6.0
31
- Requires-Dist: psutil>=7.0
32
- Requires-Dist: prometheus-client>=0.24
33
- Requires-Dist: requests>=2.33
34
- Requires-Dist: httpx>=0.28
35
- Requires-Dist: cryptography>=50.0
36
- Requires-Dist: urllib3>=2.8
37
22
  Provides-Extra: test
38
23
  Requires-Dist: pytest>=8; extra == "test"
39
24
  Requires-Dist: pytest-asyncio>=0.24; extra == "test"
40
25
  Requires-Dist: pytest-cov>=5; extra == "test"
41
26
  Requires-Dist: uvicorn>=0.30; extra == "test"
27
+ Requires-Dist: fastapi<1,>=0.128; extra == "test"
28
+ Provides-Extra: db
29
+ Requires-Dist: keepup-db>=0.4.0; extra == "db"
30
+ Provides-Extra: auth
31
+ Requires-Dist: keepup-auth>=0.4.0; extra == "auth"
32
+ Provides-Extra: users
33
+ Requires-Dist: keepup-users>=0.4.0; extra == "users"
34
+ Provides-Extra: ui
35
+ Requires-Dist: keepup-ui>=0.4.0; extra == "ui"
36
+ Provides-Extra: audit
37
+ Requires-Dist: keepup-audit>=0.4.0; extra == "audit"
38
+ Provides-Extra: metrics
39
+ Requires-Dist: keepup-metrics>=0.4.0; extra == "metrics"
40
+ Provides-Extra: tasks
41
+ Requires-Dist: keepup-tasks>=0.4.0; extra == "tasks"
42
+ Provides-Extra: modules
43
+ Requires-Dist: keepup-modules>=0.4.0; extra == "modules"
44
+ Provides-Extra: cluster
45
+ Requires-Dist: keepup-cluster>=0.4.0; extra == "cluster"
46
+ Provides-Extra: log-shipping
47
+ Requires-Dist: keepup-log-shipping>=0.4.0; extra == "log-shipping"
48
+ Provides-Extra: http
49
+ Requires-Dist: keepup-http>=0.4.0; extra == "http"
50
+ Provides-Extra: integration-log
51
+ Requires-Dist: keepup-integration-log>=0.4.0; extra == "integration-log"
52
+ Provides-Extra: panel
53
+ Requires-Dist: keepup-db>=0.4.0; extra == "panel"
54
+ Requires-Dist: keepup-auth>=0.4.0; extra == "panel"
55
+ Requires-Dist: keepup-users>=0.4.0; extra == "panel"
56
+ Requires-Dist: keepup-ui>=0.4.0; extra == "panel"
57
+ Requires-Dist: keepup-audit>=0.4.0; extra == "panel"
58
+ Requires-Dist: keepup-metrics>=0.4.0; extra == "panel"
59
+ Requires-Dist: keepup-tasks>=0.4.0; extra == "panel"
60
+ Requires-Dist: keepup-modules>=0.4.0; extra == "panel"
61
+ Requires-Dist: keepup-http>=0.4.0; extra == "panel"
62
+ Requires-Dist: keepup-cluster>=0.4.0; extra == "panel"
63
+ Requires-Dist: keepup-log-shipping>=0.4.0; extra == "panel"
64
+ Requires-Dist: keepup-integration-log>=0.4.0; extra == "panel"
42
65
  Provides-Extra: postgres
43
- Requires-Dist: asyncpg>=0.31; extra == "postgres"
66
+ Requires-Dist: keepup-postgres>=0.4.0; extra == "postgres"
67
+ Provides-Extra: sqlite
68
+ Requires-Dist: keepup-sqlite>=0.4.0; extra == "sqlite"
44
69
  Dynamic: license-file
45
70
 
46
71
  # keepup
@@ -52,17 +77,9 @@ Dynamic: license-file
52
77
 
53
78
  [Project page](https://fedorsergeev.github.io/keepup-admin/) ·
54
79
  [Package](https://pypi.org/project/keepup-admin/) ·
80
+ [Install](INSTALL.md) ·
55
81
  [Changes](CHANGELOG.md)
56
82
 
57
- Four badges, not six checks. These answer what somebody deciding whether to
58
- install asks: does it run on my Python, is there a known vulnerability in what
59
- it pulls in, what will I get, and may I use it. `quality`, `build` and `codeql`
60
- are housekeeping and live on the Actions page -- six badges in a row stop being
61
- read at all.
62
-
63
- A badge shows; it does not require. What keeps a red check from being merged is
64
- a branch rule, not a picture -- see `doc/keepup.md`.
65
-
66
83
  An admin framework over FastAPI. You give it settings; it gives you an
67
84
  application with a panel, a plugin runtime, users, a database layer, an audit,
68
85
  metrics and coordination between replicas already wired.
@@ -73,14 +90,40 @@ from keepup import KeepupSettings, create_app
73
90
  app = create_app(KeepupSettings(title="Your product", project_name="yours"))
74
91
  ```
75
92
 
76
- That is a running application with a working panel at `/selfcare`: the shell,
77
- the themes and eight administrative sections ship inside the package, so there
78
- is nothing to copy into your tree to see them.
93
+ That is a running application with a working panel at `/selfcare` once the
94
+ capabilities are installed: the shell, the themes and eight administrative
95
+ sections ship with them, so there is nothing to copy into your tree to see them.
79
96
 
80
97
  Installed as `keepup-admin`; imported as `keepup`. The name `keepup` on PyPI
81
98
  belongs to an unrelated project from 2015 that installs a script and no module,
82
99
  so the import name is free.
83
100
 
101
+ ## Install
102
+
103
+ Python 3.11 or newer. PostgreSQL in production; SQLite works and is meant for
104
+ development.
105
+
106
+ ```bash
107
+ pip install "keepup-admin[panel,postgres]"
108
+ ```
109
+
110
+ That is the base plus the capabilities the panel profile enables and the
111
+ PostgreSQL driver. The base alone is the constructor:
112
+
113
+ ```bash
114
+ pip install keepup-admin
115
+ ```
116
+
117
+ — the kernel, the catalogue, the service registry, the lifecycle and the
118
+ transport seam, carrying no capability of its own. Each capability is an extra:
119
+ `db`, `auth`, `users`, `ui`, `audit`, `metrics`, `tasks`, `modules`, `cluster`,
120
+ `log_shipping`, `http`, `integration_log`, and one driver, `postgres` or
121
+ `sqlite` — one, because two drivers of one required service stop the start on
122
+ purpose.
123
+
124
+ `INSTALL.md` has the long form: every extra and what it brings, installing from
125
+ the repository, the build and the release.
126
+
84
127
  ## What it gives you
85
128
 
86
129
  | | |
@@ -116,35 +159,55 @@ with an underscore, whatever module it sits in.
116
159
  repository: a name taken out of the framework and not declared public fails the
117
160
  run, and the failure says what to do about it.
118
161
 
119
- ## Requirements
162
+ ## Build
120
163
 
121
- Python 3.11 or newer. PostgreSQL in production; SQLite works and is meant for
122
- development. `pip install keepup-admin[postgres]` adds the driver the bus
123
- between replicas needs.
164
+ A release is one distribution per capability, and `build.yml` checks on every
165
+ change that they are publishable rather than discovering it at a tag:
166
+
167
+ ```bash
168
+ python -m pip install --upgrade build twine
169
+
170
+ python -m build # the base, keepup-admin
171
+ for package in packages/*; do # each capability
172
+ python -m build --outdir dist "$package"
173
+ done
174
+
175
+ python -m twine check --strict dist/*
176
+ ```
177
+
178
+ The same job then installs the built wheels into an empty virtual environment
179
+ and imports the framework there: a version on PyPI cannot be replaced, and a
180
+ wheel that installs and does not import is the one failure a metadata check
181
+ cannot see. The tag is the release's number and the job refuses one the metadata
182
+ disagrees with; see `.github/workflows/release.yml` and `INSTALL.md`.
124
183
 
125
184
  ## Tests
126
185
 
127
186
  ```bash
128
- pip install -e ".[test]"
129
- pytest tests/
187
+ pip install -e ".[test]" -e packages/keepup-*
188
+ python -m pytest tests/ -q --cov --cov-config=pyproject.toml
130
189
  ```
131
190
 
132
191
  **Install first, then test.** Pointing pytest at the checkout does not work on
133
192
  its own: `import keepup` has to resolve, and the directory a clone lands in is
134
193
  called `keepup-admin`, so nothing is named `keepup` until the package is
135
- installed. The `test` extra carries what the suite needs beyond the package —
136
- notably `cryptography`, which the framework itself never imports and the OIDC
137
- tests sign tokens with.
194
+ installed. The capabilities are distributions of their own in `packages/` —
195
+ each carries the libraries it needs, and the suite imports them — so a clone
196
+ installs them from the tree; the extras name the same ones for an installation
197
+ from the index.
138
198
 
139
199
  The suite runs against SQLite with no network, needs no application beside the
140
200
  package, and holds a coverage floor declared in `pyproject.toml`. Checks that
141
201
  genuinely need a consumer of the framework find one by trait and skip with a
142
- reason when there is none, so a skip here always says what is missing.
143
-
144
- Every one of these runs on push and on a pull request; see `.github/workflows/`.
145
- `security.yml` also runs weekly, because that check goes red without anybody
146
- touching the repository — an advisory gets published against a version that was
147
- fine yesterday.
202
+ reason when there is none, so a skip here always says what is missing. A test is
203
+ named `*_tests.py` and run by path — `python -m pytest tests/runtime_tests.py -v`.
204
+
205
+ Every one of these runs on push and on a pull request, on Python 3.11, 3.12 and
206
+ 3.13; see `.github/workflows/`. `security.yml` also runs weekly, because that
207
+ check goes red without anybody touching the repository — an advisory gets
208
+ published against a version that was fine yesterday. `INSTALL.md` carries the
209
+ heavier checks: the wheel installed into a throwaway environment, and the
210
+ security audit.
148
211
 
149
212
  ## Licence
150
213
 
@@ -7,17 +7,9 @@
7
7
 
8
8
  [Project page](https://fedorsergeev.github.io/keepup-admin/) ·
9
9
  [Package](https://pypi.org/project/keepup-admin/) ·
10
+ [Install](INSTALL.md) ·
10
11
  [Changes](CHANGELOG.md)
11
12
 
12
- Four badges, not six checks. These answer what somebody deciding whether to
13
- install asks: does it run on my Python, is there a known vulnerability in what
14
- it pulls in, what will I get, and may I use it. `quality`, `build` and `codeql`
15
- are housekeeping and live on the Actions page -- six badges in a row stop being
16
- read at all.
17
-
18
- A badge shows; it does not require. What keeps a red check from being merged is
19
- a branch rule, not a picture -- see `doc/keepup.md`.
20
-
21
13
  An admin framework over FastAPI. You give it settings; it gives you an
22
14
  application with a panel, a plugin runtime, users, a database layer, an audit,
23
15
  metrics and coordination between replicas already wired.
@@ -28,14 +20,40 @@ from keepup import KeepupSettings, create_app
28
20
  app = create_app(KeepupSettings(title="Your product", project_name="yours"))
29
21
  ```
30
22
 
31
- That is a running application with a working panel at `/selfcare`: the shell,
32
- the themes and eight administrative sections ship inside the package, so there
33
- is nothing to copy into your tree to see them.
23
+ That is a running application with a working panel at `/selfcare` once the
24
+ capabilities are installed: the shell, the themes and eight administrative
25
+ sections ship with them, so there is nothing to copy into your tree to see them.
34
26
 
35
27
  Installed as `keepup-admin`; imported as `keepup`. The name `keepup` on PyPI
36
28
  belongs to an unrelated project from 2015 that installs a script and no module,
37
29
  so the import name is free.
38
30
 
31
+ ## Install
32
+
33
+ Python 3.11 or newer. PostgreSQL in production; SQLite works and is meant for
34
+ development.
35
+
36
+ ```bash
37
+ pip install "keepup-admin[panel,postgres]"
38
+ ```
39
+
40
+ That is the base plus the capabilities the panel profile enables and the
41
+ PostgreSQL driver. The base alone is the constructor:
42
+
43
+ ```bash
44
+ pip install keepup-admin
45
+ ```
46
+
47
+ — the kernel, the catalogue, the service registry, the lifecycle and the
48
+ transport seam, carrying no capability of its own. Each capability is an extra:
49
+ `db`, `auth`, `users`, `ui`, `audit`, `metrics`, `tasks`, `modules`, `cluster`,
50
+ `log_shipping`, `http`, `integration_log`, and one driver, `postgres` or
51
+ `sqlite` — one, because two drivers of one required service stop the start on
52
+ purpose.
53
+
54
+ `INSTALL.md` has the long form: every extra and what it brings, installing from
55
+ the repository, the build and the release.
56
+
39
57
  ## What it gives you
40
58
 
41
59
  | | |
@@ -71,35 +89,55 @@ with an underscore, whatever module it sits in.
71
89
  repository: a name taken out of the framework and not declared public fails the
72
90
  run, and the failure says what to do about it.
73
91
 
74
- ## Requirements
92
+ ## Build
75
93
 
76
- Python 3.11 or newer. PostgreSQL in production; SQLite works and is meant for
77
- development. `pip install keepup-admin[postgres]` adds the driver the bus
78
- between replicas needs.
94
+ A release is one distribution per capability, and `build.yml` checks on every
95
+ change that they are publishable rather than discovering it at a tag:
96
+
97
+ ```bash
98
+ python -m pip install --upgrade build twine
99
+
100
+ python -m build # the base, keepup-admin
101
+ for package in packages/*; do # each capability
102
+ python -m build --outdir dist "$package"
103
+ done
104
+
105
+ python -m twine check --strict dist/*
106
+ ```
107
+
108
+ The same job then installs the built wheels into an empty virtual environment
109
+ and imports the framework there: a version on PyPI cannot be replaced, and a
110
+ wheel that installs and does not import is the one failure a metadata check
111
+ cannot see. The tag is the release's number and the job refuses one the metadata
112
+ disagrees with; see `.github/workflows/release.yml` and `INSTALL.md`.
79
113
 
80
114
  ## Tests
81
115
 
82
116
  ```bash
83
- pip install -e ".[test]"
84
- pytest tests/
117
+ pip install -e ".[test]" -e packages/keepup-*
118
+ python -m pytest tests/ -q --cov --cov-config=pyproject.toml
85
119
  ```
86
120
 
87
121
  **Install first, then test.** Pointing pytest at the checkout does not work on
88
122
  its own: `import keepup` has to resolve, and the directory a clone lands in is
89
123
  called `keepup-admin`, so nothing is named `keepup` until the package is
90
- installed. The `test` extra carries what the suite needs beyond the package —
91
- notably `cryptography`, which the framework itself never imports and the OIDC
92
- tests sign tokens with.
124
+ installed. The capabilities are distributions of their own in `packages/` —
125
+ each carries the libraries it needs, and the suite imports them — so a clone
126
+ installs them from the tree; the extras name the same ones for an installation
127
+ from the index.
93
128
 
94
129
  The suite runs against SQLite with no network, needs no application beside the
95
130
  package, and holds a coverage floor declared in `pyproject.toml`. Checks that
96
131
  genuinely need a consumer of the framework find one by trait and skip with a
97
- reason when there is none, so a skip here always says what is missing.
98
-
99
- Every one of these runs on push and on a pull request; see `.github/workflows/`.
100
- `security.yml` also runs weekly, because that check goes red without anybody
101
- touching the repository — an advisory gets published against a version that was
102
- fine yesterday.
132
+ reason when there is none, so a skip here always says what is missing. A test is
133
+ named `*_tests.py` and run by path — `python -m pytest tests/runtime_tests.py -v`.
134
+
135
+ Every one of these runs on push and on a pull request, on Python 3.11, 3.12 and
136
+ 3.13; see `.github/workflows/`. `security.yml` also runs weekly, because that
137
+ check goes red without anybody touching the repository — an advisory gets
138
+ published against a version that was fine yesterday. `INSTALL.md` carries the
139
+ heavier checks: the wheel installed into a throwaway environment, and the
140
+ security audit.
103
141
 
104
142
  ## Licence
105
143
 
@@ -1,13 +1,13 @@
1
1
  """KeepUP — a framework over FastAPI for applications built like this one.
2
2
 
3
3
  An application supplies a :class:`~keepup.settings.KeepupSettings` and gets an
4
- application back from :func:`~keepup.factory.create_app`. Everything the
4
+ application back from :func:`~keepup_http.factory.create_app`. Everything the
5
5
  framework cannot know -- the product's name, the collector its logs go to,
6
6
  which fields of a request are secret, what a password must look like, which
7
7
  tables belong to the product -- travels in those settings, never as a default
8
8
  in here. See ``doc/keepup.md``.
9
9
 
10
- Imported lazily: ``keepup.factory`` pulls in the database layer and the
10
+ Imported lazily: ``keepup_http.factory`` pulls in the database layer and the
11
11
  authentication provider, and importing the package to reach one constant
12
12
  should not do that.
13
13
  """
@@ -29,13 +29,29 @@ except Exception:
29
29
  __all__ = ["KeepupSettings", "StaticMount", "create_app", "__version__"]
30
30
 
31
31
 
32
+ def _create_app():
33
+ """The application, built by the HTTP transport that owns it (keepup-121).
34
+
35
+ `create_app` stays the public name and the base keeps it: the assembly --
36
+ FastAPI, the routes, the middleware, the panel shell -- is
37
+ `keepup-http`'s, because a deployment that serves something other than HTTP
38
+ must not install a web framework to build its runtime.
39
+ """
40
+ try:
41
+ from keepup_http.factory import create_app
42
+ except ImportError as error: # pragma: no cover - the message is the point
43
+ raise ImportError(
44
+ "create_app needs the HTTP transport: install keepup-http "
45
+ "(pip install 'keepup-admin[http]')"
46
+ ) from error
47
+ return create_app
48
+
49
+
32
50
  def __getattr__(name):
33
51
  if name in ("KeepupSettings", "StaticMount"):
34
52
  from keepup import settings
35
53
 
36
54
  return getattr(settings, name)
37
55
  if name == "create_app":
38
- from keepup.factory import create_app
39
-
40
- return create_app
56
+ return _create_app()
41
57
  raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,146 @@
1
+ """The audit: incoming calls, the application's events and the administrator's trail.
2
+
3
+ Task keepup-111. These live in three modules of the kernel -- ``audit.py``
4
+ (incoming requests, redaction, retention), ``events.py`` (the application's own
5
+ event log) and ``admin_trail.py`` (what an administrator decided) -- and all
6
+ three import SQLAlchemy, so the base bundle cannot be assembled without a
7
+ database library while they stay. The plugin here owns the two tables and
8
+ publishes the two services; the kernel's own trail and the route wrapper reach
9
+ them through the names (``keepup/kernel/observability.py``), not by importing
10
+ these modules.
11
+
12
+ The routes of the event log and the section that shows it travel with the panel
13
+ (keepup-104); what is here is the recording itself, its retention and the two
14
+ names.
15
+ """
16
+
17
+ import asyncio
18
+ import logging
19
+ from typing import Any, Dict, List
20
+
21
+ from keepup.kernel.datasource import SERVICE_DATASOURCE
22
+ from keepup.kernel.descriptor import KIND_OPTIONAL, PluginDescriptor
23
+ from keepup.kernel.observability import SERVICE_AUDIT, SERVICE_EVENTS, Recording
24
+ from keepup_audit.tables import INCOMING_REQUESTS
25
+ from keepup_audit.events import APP_EVENTS
26
+ from keepup.plugins.base import BasePlugin
27
+
28
+ logger = logging.getLogger(__name__)
29
+
30
+ __all__ = ["AuditPlugin", "AuditRecording"]
31
+
32
+
33
+ class AuditRecording(Recording):
34
+ """The framework's own recording, behind the kernel's two names.
35
+
36
+ It delegates to the modules that already do the work (``keepup_audit.audit``,
37
+ ``keepup_audit.events``) so that nothing changes for a deployment today; those
38
+ modules travel into this capability's distribution in keepup-124.
39
+ """
40
+
41
+ def __init__(self, datasource: Any = None):
42
+ from keepup_audit.audit import IncomingRequestLogger, log_api_request
43
+
44
+ super().__init__(start=log_api_request, end=IncomingRequestLogger.end_request,
45
+ name="keepup audit")
46
+
47
+ def watch(self, emitter: Any) -> None:
48
+ """Add another emitter, for a capability that keeps events of its own."""
49
+ self.emitters.append(emitter)
50
+
51
+
52
+ class AuditPlugin(BasePlugin):
53
+ """The capability: two tables, two services and the retention they need."""
54
+
55
+ descriptor = PluginDescriptor(
56
+ id="audit",
57
+ name="Event audit",
58
+ version="0.5.0",
59
+ distribution="keepup-audit",
60
+ kind=KIND_OPTIONAL,
61
+ priority=60,
62
+ provides=("audit>=1", "events>=1"),
63
+ requires=("datasource>=1",),
64
+ wants=("locks>=1", "scheduler>=1"),
65
+ contributions=("routes", "sections", "tables", "events"),
66
+ )
67
+
68
+ def __init__(self, config=None):
69
+ super().__init__("audit", "Event audit", config)
70
+
71
+ def register(self, services):
72
+ """Publish the recording where there is a data source to write it to.
73
+
74
+ Args:
75
+ services: the runtime's registry.
76
+ """
77
+ if services.has(SERVICE_DATASOURCE):
78
+ self.recording = AuditRecording(services.require(SERVICE_DATASOURCE))
79
+ services.provide(SERVICE_AUDIT, self.recording, version=1, plugin_id="audit")
80
+ services.provide(SERVICE_EVENTS, self.recording, version=1, plugin_id="audit")
81
+
82
+ async def initialize(self):
83
+ """Keep the recording published at registration; build one if there is none."""
84
+ if getattr(self, "recording", None) is None:
85
+ self.recording = AuditRecording(self.services.require(SERVICE_DATASOURCE))
86
+ return True
87
+
88
+ async def post_construct(self):
89
+ """Start this capability's loops: the buffer, the audit sweep, the events'.
90
+
91
+ They were `asyncio.create_task` calls in the kernel's lifespan, so a
92
+ deployment that never installed the audit still flushed and swept
93
+ (keepup-109).
94
+ """
95
+ from keepup_audit.audit import audit_retention_background, background_buffer_flusher
96
+ from keepup_audit.events import events_retention_background
97
+
98
+ self._tasks = [
99
+ asyncio.create_task(background_buffer_flusher()),
100
+ asyncio.create_task(audit_retention_background()),
101
+ asyncio.create_task(events_retention_background()),
102
+ ]
103
+
104
+ async def cleanup(self):
105
+ """Stop them, and ship what the buffer still holds.
106
+
107
+ The flush used to be the kernel's, after its own cancellations; the
108
+ owner of the buffer is the one that empties it (keepup-109).
109
+ """
110
+ tasks, self._tasks = getattr(self, "_tasks", []), []
111
+ for task in tasks:
112
+ task.cancel()
113
+ for task in tasks:
114
+ try:
115
+ await task
116
+ except asyncio.CancelledError:
117
+ pass
118
+ from keepup_audit import audit as recording
119
+
120
+ try:
121
+ flushed = await recording.IncomingRequestLogger.flush_buffer(include_in_flight=True)
122
+ logger.info("Flushed %s remaining incoming-request rows", flushed)
123
+ except Exception as error: # noqa: BLE001 - shutdown must not raise
124
+ logger.error("Could not flush the remaining incoming-request rows: %s", error)
125
+
126
+ def get_declared_tables(self):
127
+ """The two tables this capability owns, declared once, until keepup-124."""
128
+ return [INCOMING_REQUESTS, APP_EVENTS]
129
+
130
+ def get_event_sinks(self) -> List[Any]:
131
+ """What writes an event down, for the kernel's own trail."""
132
+ return [self.emit]
133
+
134
+ async def emit(self, event_type: str, payload: Dict[str, Any] = None) -> None:
135
+ """Write one event through the module that still owns the table."""
136
+ from keepup_audit.events import emit_event
137
+
138
+ await emit_event(event_type, payload or {})
139
+
140
+ def get_api_routes(self):
141
+ """No routes yet: the event log's own travel with the panel (keepup-104)."""
142
+ return []
143
+
144
+ def get_handlers(self):
145
+ """What another plugin may reach instead of importing the audit."""
146
+ return {"recording": self.recording, "emit": self.emit}
@@ -0,0 +1,132 @@
1
+ """Sign-in as a capability: who is calling, and what they may do.
2
+
3
+ Task keepup-116, first half. The kernel owns the shapes and the two names
4
+ (``keepup/kernel/security.py``, keepup-119); this plugin is a deployment putting
5
+ an answer behind them, and the tables that answer needs -- the panel's sessions
6
+ and the login attempts that throttle a guesser -- belong to it.
7
+
8
+ The sign-in machinery itself (``auth/routes.py``, ``panel_session.py``,
9
+ ``login_throttle.py``, the providers, OIDC and somebody else's identity system)
10
+ travels into this capability's distribution in keepup-124, together with the
11
+ routes, the sockets and the CSRF middleware it contributes. What is here is the
12
+ claim: two services, two tables, and an identity the runtime adopts.
13
+ """
14
+
15
+ import asyncio
16
+ import logging
17
+ from typing import Any, Dict, List
18
+
19
+ from keepup.kernel.datasource import SERVICE_DATASOURCE
20
+ from keepup.kernel.descriptor import KIND_OPTIONAL, PluginDescriptor
21
+ from keepup.kernel.security import SERVICE_AUTH, SERVICE_PERMISSIONS, Identity
22
+ from keepup.plugins.base import BasePlugin
23
+
24
+ logger = logging.getLogger(__name__)
25
+
26
+ __all__ = ["AuthPlugin", "build_identity"]
27
+
28
+
29
+ def build_identity(name: str = "keepup-auth") -> Identity:
30
+ """The framework's own sign-in, behind the shape the kernel owns.
31
+
32
+ Args:
33
+ name: what to call it in a log line.
34
+
35
+ Returns:
36
+ The identity: how a caller is found, and what decides a right.
37
+ """
38
+ from keepup_auth.dependencies import get_panel_user
39
+ from keepup_auth.identity import access
40
+
41
+ return Identity(subject_dependency=get_panel_user, checker=access.check, name=name)
42
+
43
+
44
+ class AuthPlugin(BasePlugin):
45
+ """The capability: sessions, attempts, and the two services that answer."""
46
+
47
+ descriptor = PluginDescriptor(
48
+ id="auth",
49
+ name="Sign-in and sessions",
50
+ version="0.5.0",
51
+ distribution="keepup-auth",
52
+ kind=KIND_OPTIONAL,
53
+ priority=30,
54
+ provides=("auth>=1", "permissions>=1"),
55
+ requires=("datasource>=1",),
56
+ contributions=("routes", "sockets", "middleware", "tables", "permissions"),
57
+ )
58
+
59
+ def __init__(self, config=None):
60
+ super().__init__("auth", "Sign-in and sessions", config)
61
+
62
+ def register(self, services):
63
+ """Publish the identity under both names, once there is storage.
64
+
65
+ Args:
66
+ services: the runtime's registry.
67
+ """
68
+ if services.has(SERVICE_DATASOURCE):
69
+ self.identity = build_identity()
70
+ services.provide(SERVICE_AUTH, self.identity, version=1, plugin_id="auth")
71
+ services.provide(SERVICE_PERMISSIONS, self.identity, version=1, plugin_id="auth")
72
+
73
+ async def initialize(self):
74
+ """Keep the identity published at registration; build one if there is none."""
75
+ if getattr(self, "identity", None) is None:
76
+ self.identity = build_identity()
77
+ return True
78
+
79
+ async def post_construct(self):
80
+ """Start the sweep that closes a socket whose session was revoked, and
81
+ give the accounts that predate the role set the role they were created
82
+ with.
83
+
84
+ Both are the capability's: the kernel's task became the sign-in's when
85
+ the loops moved (keepup-65, keepup-109), and the one-time read of the
86
+ legacy ``users.role`` column is nobody else's business (keepup-157).
87
+ """
88
+ from keepup_auth import seed_accounts, socket_sessions, user_roles
89
+
90
+ try:
91
+ # The first accounts and the legacy roles: one place creates them,
92
+ # and it is the capability that signs people in (keepup-158).
93
+ await asyncio.to_thread(seed_accounts.create_first_accounts)
94
+ await asyncio.to_thread(user_roles.backfill_from_legacy_column)
95
+ except Exception as error: # noqa: BLE001 - a start that cannot seed still serves
96
+ logger.warning("Could not create the first accounts: %s", error)
97
+ self._socket_sweep = asyncio.create_task(socket_sessions.run_forever())
98
+
99
+ async def cleanup(self):
100
+ """Stop the sweep with the application that started it."""
101
+ task, self._socket_sweep = getattr(self, "_socket_sweep", None), None
102
+ if task is None:
103
+ return
104
+ task.cancel()
105
+ try:
106
+ await task
107
+ except asyncio.CancelledError:
108
+ pass
109
+
110
+ def get_declared_tables(self) -> List[Any]:
111
+ """The two tables this capability owns, declared once, until keepup-124."""
112
+ from keepup_auth.login_throttle import LOGIN_ATTEMPTS
113
+ from keepup_auth.panel_session import AUTH_SESSION
114
+
115
+ return [AUTH_SESSION, LOGIN_ATTEMPTS]
116
+
117
+ def get_route_permissions(self) -> Dict[str, Any]:
118
+ """The rights this capability's routes ask for, by name.
119
+
120
+ Empty here, and declared all the same: the kind of contribution is what
121
+ another plugin reads to know that a right it asks for exists.
122
+ """
123
+ return {}
124
+
125
+ def get_api_routes(self) -> List[Any]:
126
+ """No routes yet: the sign-in's own (sign in, out, refresh, WebSocket, CSRF)
127
+ travel into this capability's distribution in keepup-124."""
128
+ return []
129
+
130
+ def get_handlers(self) -> Dict[str, Any]:
131
+ """What another plugin may reach instead of importing the sign-in."""
132
+ return {"identity": self.identity}