terp-cli 0.44.0__tar.gz → 0.45.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.
- {terp_cli-0.44.0 → terp_cli-0.45.0}/PKG-INFO +9 -9
- {terp_cli-0.44.0 → terp_cli-0.45.0}/pyproject.toml +9 -9
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/__init__.py +4 -68
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/envschema.py +3 -0
- terp_cli-0.45.0/src/terp/cli/guide_security.py +77 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/manifest.py +5 -1
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/sign.py +4 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/.gitignore +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/signer/Dockerfile +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/signer/terp-arch-releases.json +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/_appref.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/_cors_view.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/_engine.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/_output.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/_subjects.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/access.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/api_contract.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/api_contract_bounds.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/api_contract_check.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/api_contract_schemas.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/api_contract_shapes.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/apidocs.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/audit_findings.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/authz_surface.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/capabilities.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/dependency_audit.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/dependency_risk.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/dependency_scan.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/deploy_safety.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/deployment_adopt.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/deployment_app.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/deployment_check.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/deployment_declare.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/deployment_render.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/dev.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/docker.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/docker_masks.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/envfile.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/envrequired.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/envseams.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/fmt.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/grants.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/guide_capability.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/guide_deployment.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/guide_files.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/guide_maintenance.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/guide_migrations.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/guide_passwords.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/heartbeat.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/jobs.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/leases.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/locks.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/__init__.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_images.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_packages.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_platform.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_report.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/maintenance/_vulnerabilities.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/module_roles.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/npm_tree.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/openapi.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/outbox.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/ports.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/profiles.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/py.typed +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/python_audit.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/__init__.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_archives.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_common.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_compare.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_dockerfile.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_git.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_history.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_image.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_locks.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_migrations.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_npm_lock.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_osv.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_plan.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_registry.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_render.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/_sandbox.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/build.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/cli.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/dsse.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/gate.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/release/promote.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/reseal.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/reseal_report.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/risk_authority.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/routes.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/scaffold.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/scaffold_frontend.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/schema.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/seed.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/service_accounts.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/smoke.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/upgrade_recipes.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/users.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/verify.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/version.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/workbench.py +0 -0
- {terp_cli-0.44.0 → terp_cli-0.45.0}/src/terp/cli/workbench_adopt.py +0 -0
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: terp-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.45.0
|
|
4
4
|
Summary: Terp command-line tool — inspect, scaffolding, migrations, checks, api-docs.
|
|
5
5
|
Project-URL: Repository, https://github.com/AITT-NL/terp-framework
|
|
6
6
|
Project-URL: Changelog, https://github.com/AITT-NL/terp-framework/blob/main/CHANGELOG.md
|
|
7
7
|
License-Expression: Apache-2.0
|
|
8
8
|
Requires-Python: >=3.13
|
|
9
9
|
Requires-Dist: pyyaml>=6.0
|
|
10
|
-
Requires-Dist: terp-arch==0.
|
|
11
|
-
Requires-Dist: terp-core==0.
|
|
12
|
-
Requires-Dist: terp-migrations==0.
|
|
10
|
+
Requires-Dist: terp-arch==0.45.0
|
|
11
|
+
Requires-Dist: terp-core==0.45.0
|
|
12
|
+
Requires-Dist: terp-migrations==0.45.0
|
|
13
13
|
Provides-Extra: jobs
|
|
14
|
-
Requires-Dist: terp-cap-outbox==0.
|
|
15
|
-
Requires-Dist: terp-cap-scheduler-apscheduler==0.
|
|
14
|
+
Requires-Dist: terp-cap-outbox==0.45.0; extra == 'jobs'
|
|
15
|
+
Requires-Dist: terp-cap-scheduler-apscheduler==0.45.0; extra == 'jobs'
|
|
16
16
|
Provides-Extra: release
|
|
17
17
|
Requires-Dist: cryptography>=46; extra == 'release'
|
|
18
18
|
Requires-Dist: packaging>=24; extra == 'release'
|
|
19
|
-
Requires-Dist: terp-cap-egress==0.
|
|
19
|
+
Requires-Dist: terp-cap-egress==0.45.0; extra == 'release'
|
|
20
20
|
Provides-Extra: scheduler
|
|
21
|
-
Requires-Dist: terp-cap-scheduler-apscheduler==0.
|
|
21
|
+
Requires-Dist: terp-cap-scheduler-apscheduler==0.45.0; extra == 'scheduler'
|
|
22
22
|
Provides-Extra: worker
|
|
23
|
-
Requires-Dist: terp-cap-outbox==0.
|
|
23
|
+
Requires-Dist: terp-cap-outbox==0.45.0; extra == 'worker'
|
|
@@ -4,18 +4,18 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "terp-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.45.0"
|
|
8
8
|
description = "Terp command-line tool — inspect, scaffolding, migrations, checks, api-docs."
|
|
9
9
|
requires-python = ">=3.13"
|
|
10
10
|
license = "Apache-2.0"
|
|
11
11
|
dependencies = [
|
|
12
|
-
"terp-core==0.
|
|
12
|
+
"terp-core==0.45.0",
|
|
13
13
|
# `terp migrate` delegates to terp-migrations (lazily imported), keeping Alembic
|
|
14
14
|
# off the path for `terp inspect` / `terp guide` while making migrations work.
|
|
15
|
-
"terp-migrations==0.
|
|
15
|
+
"terp-migrations==0.45.0",
|
|
16
16
|
# `terp guide rules` projects the live rule registry; terp-arch is imported lazily
|
|
17
17
|
# (only when that topic is rendered), so it stays off the common `terp guide` path.
|
|
18
|
-
"terp-arch==0.
|
|
18
|
+
"terp-arch==0.45.0",
|
|
19
19
|
# `terp verify --only env-seams` and `terp smoke` read the compose profiles as data
|
|
20
20
|
# (anchors and `<<:` merge keys resolved), so both answer without a Docker daemon or
|
|
21
21
|
# even the `docker` binary. Declared explicitly rather than leant on: every app
|
|
@@ -29,11 +29,11 @@ dependencies = [
|
|
|
29
29
|
# or a scheduler engine into apps that only use inspect/check/migrate. Deployments can select
|
|
30
30
|
# one process role, while `jobs` is the convenient complete jobs-process bundle.
|
|
31
31
|
[project.optional-dependencies]
|
|
32
|
-
worker = ["terp-cap-outbox==0.
|
|
33
|
-
scheduler = ["terp-cap-scheduler-apscheduler==0.
|
|
32
|
+
worker = ["terp-cap-outbox==0.45.0"]
|
|
33
|
+
scheduler = ["terp-cap-scheduler-apscheduler==0.45.0"]
|
|
34
34
|
jobs = [
|
|
35
|
-
"terp-cap-outbox==0.
|
|
36
|
-
"terp-cap-scheduler-apscheduler==0.
|
|
35
|
+
"terp-cap-outbox==0.45.0",
|
|
36
|
+
"terp-cap-scheduler-apscheduler==0.45.0",
|
|
37
37
|
]
|
|
38
38
|
# `terp release` and `terp promote` (ADR 0187): the DSSE signature (cryptography), the lock's
|
|
39
39
|
# markers (packaging), and the one declared way to a registry, an index and the vulnerability
|
|
@@ -42,7 +42,7 @@ jobs = [
|
|
|
42
42
|
release = [
|
|
43
43
|
"cryptography>=46",
|
|
44
44
|
"packaging>=24",
|
|
45
|
-
"terp-cap-egress==0.
|
|
45
|
+
"terp-cap-egress==0.45.0",
|
|
46
46
|
]
|
|
47
47
|
|
|
48
48
|
[project.scripts]
|
|
@@ -65,6 +65,7 @@ from terp.cli import (
|
|
|
65
65
|
guide_maintenance,
|
|
66
66
|
guide_migrations,
|
|
67
67
|
guide_passwords,
|
|
68
|
+
guide_security,
|
|
68
69
|
)
|
|
69
70
|
from terp.cli.grants import (
|
|
70
71
|
grant_add_command,
|
|
@@ -1174,72 +1175,7 @@ Multi-tenant rows (tenancy capability)
|
|
|
1174
1175
|
Sign the tenant into the token at login with
|
|
1175
1176
|
build_login_module(authenticate, tenant_resolver=...).
|
|
1176
1177
|
""",
|
|
1177
|
-
"security":
|
|
1178
|
-
The security declaration (SecurityConfig, refused at production boot)
|
|
1179
|
-
|
|
1180
|
-
- ONE declaration, wired on the control plane, read by create_app:
|
|
1181
|
-
from terp.core import ControlPlane, CorsPolicy, RateLimit, SecurityConfig
|
|
1182
|
-
control_plane = ControlPlane(security=SecurityConfig(
|
|
1183
|
-
cors=CorsPolicy.allow(["https://app.example.com"]),
|
|
1184
|
-
trusted_proxy_hops=1,
|
|
1185
|
-
))
|
|
1186
|
-
- FOUR of its states refuse a production boot (SecurityConfig.production_problems();
|
|
1187
|
-
create_app raises BootError "insecure production security config"). Each has exactly
|
|
1188
|
-
one declaration that answers it:
|
|
1189
|
-
1. CORS unset -> CorsPolicy.from_environment(), .allow([...]) or .disabled(reason=...)
|
|
1190
|
-
2. CORS allowing '*' -> name the origins; a wildcard with credentials is no origin check
|
|
1191
|
-
3. rate_limit disabled -> RateLimit(requests=..., window_seconds=...)
|
|
1192
|
-
4. an override disabled -> an override may LOWER or RAISE a limit, never remove it
|
|
1193
|
-
Declining is a full answer and must be said out loud: CorsPolicy.disabled(reason=...)
|
|
1194
|
-
is the same-origin deployment's answer, and the reason is the point of it.
|
|
1195
|
-
Which browser origins may call the API is a fact of an environment, not of the source:
|
|
1196
|
-
CorsPolicy.from_environment() takes the allowlist from BACKEND_CORS_ORIGINS when the app
|
|
1197
|
-
is composed (ADR 0210). An environment that names none serves no cross-origin access; an
|
|
1198
|
-
entry that is not an origin (a path, a trailing slash, '*') refuses the boot. Without
|
|
1199
|
-
that declaration the variable opens nothing, and a boot that finds it set says so.
|
|
1200
|
-
`terp verify --only production-readiness` asks these before you ship, so the refusal
|
|
1201
|
-
arrives in the gate rather than at the deploy.
|
|
1202
|
-
- rate_limit_overrides is a PER-PREFIX BUCKET, not a shared counter (ADR 0115):
|
|
1203
|
-
SecurityConfig(rate_limit_overrides={"/api/v1/auth": RateLimit.for_credentials()})
|
|
1204
|
-
Longest prefix wins; everything unmatched keeps rate_limit. Separate buckets on
|
|
1205
|
-
purpose - a credential endpoint and an asset read share a process, not a counter, so
|
|
1206
|
-
exhausting one family must not 429 the other. The shape mirrors the per-mount
|
|
1207
|
-
max_request_bytes map: one way to scope a limit to a path, not two.
|
|
1208
|
-
- trusted_proxy_hops: NAME THE PROXY YOU ACTUALLY RUN BEHIND. It defaults to 0, meaning
|
|
1209
|
-
the direct TCP peer identifies the caller and X-Forwarded-For is ignored as
|
|
1210
|
-
attacker-supplied. Behind one reverse proxy (the shipped nginx profile) set 1, or every
|
|
1211
|
-
caller collapses onto the proxy's address and your per-caller controls - the rate limit,
|
|
1212
|
-
the OIDC callback throttle - stop being per-caller. The symptom is intermittent 429s
|
|
1213
|
-
that look like a traffic spike. Nothing refuses this at boot, because 0 is correct for a
|
|
1214
|
-
directly-exposed app: it is a deployment fact only you know.
|
|
1215
|
-
- expose_api_docs is a deliberate opt-in, OFF in production: /docs, /redoc and
|
|
1216
|
-
/openapi.json are hidden there because a production API's full schema is not public
|
|
1217
|
-
information. Development always serves them, and `terp openapi` exports the document
|
|
1218
|
-
either way - so turning this on is a choice to publish, not a way to get the file.
|
|
1219
|
-
Commit that file instead: `openapi.json` is the app's API contract, the one a mobile
|
|
1220
|
-
app or a site in another repository pins, and `terp verify --only api-contract` holds
|
|
1221
|
-
it to the API the app serves, naming every change to its shape, the ones that break a
|
|
1222
|
-
client first (ADR 0194). Who may call a route is not in it: authz-surface pins that.
|
|
1223
|
-
- headers ships a safe SecurityHeaders set; max_request_bytes (1 MiB) is the body cap and
|
|
1224
|
-
is per-mount overridable (ADR 0067); request_id_header names the correlation header
|
|
1225
|
-
("X-Request-ID") echoed on every response.
|
|
1226
|
-
- A NATIVE MOBILE CLIENT stays signed in through its own routes, opt-in with a reason
|
|
1227
|
-
(ADR 0195): build_login_module(..., native_clients=NativeClients(reason="...")) mounts
|
|
1228
|
-
POST /api/v1/auth/native/login, /native/refresh and /native/logout. The first two answer
|
|
1229
|
-
the refresh token in the JSON body and run the same rotation, reuse detection and
|
|
1230
|
-
revocation as the cookie, its rotation grace window included; /native/logout takes the
|
|
1231
|
-
token and revokes its whole family without minting a successor. The client keeps that
|
|
1232
|
-
token in the OS keychain or keystore and nowhere else, and treats a 401 from
|
|
1233
|
-
/native/refresh as signed out. All three refuse any request with browser provenance
|
|
1234
|
-
(Origin, any Sec-Fetch-* header, the refresh cookie) with 403 native_client_only before
|
|
1235
|
-
the body is validated, so a browser stays on /login, /refresh and /logout. A HYBRID app
|
|
1236
|
-
(a page inside a native shell) calls them from its native layer and hands its page only
|
|
1237
|
-
access tokens: a page that holds the refresh token has given up what the cookie
|
|
1238
|
-
protects. No route that mints a credential (/login, /token, /refresh, /native/login,
|
|
1239
|
-
/native/refresh) accepts an Idempotency-Key; retry without one.
|
|
1240
|
-
- No terp.arch check applies - there is no module code shape to police. Enforcement is
|
|
1241
|
-
the create_app production fail-fast plus the production-readiness verify lane.
|
|
1242
|
-
""",
|
|
1178
|
+
"security": guide_security.TOPIC,
|
|
1243
1179
|
"logging": """\
|
|
1244
1180
|
Logging (one JSON record per line, the terp-log/1 schema, ADR 0188)
|
|
1245
1181
|
|
|
@@ -2505,8 +2441,8 @@ committed, .app.env is not.
|
|
|
2505
2441
|
|
|
2506
2442
|
Never write a secret value into the manifest, .env.example, .app.env.example, source,
|
|
2507
2443
|
tests, prompts or logs. Platform-owned names (SECRET_KEY, POSTGRES_PASSWORD, TERP_RUNTIME_DB_PASSWORD, TERP_MIGRATION_DATABASE_URL, DATABASE_URL,
|
|
2508
|
-
ENVIRONMENT, WEB_PORT, BACKEND_CORS_ORIGINS) are refused
|
|
2509
|
-
have an owner.
|
|
2444
|
+
ENVIRONMENT, WEB_PORT, BACKEND_CORS_ORIGINS, TERP_RELEASE_TAG, TERP_EDGE_HOPS) are refused
|
|
2445
|
+
in the manifest: they already have an owner.
|
|
2510
2446
|
|
|
2511
2447
|
SCOPING A VARIABLE TO ONE SERVICE (not available yet)
|
|
2512
2448
|
|
|
@@ -45,6 +45,8 @@ RESOLVED_BY_VALUES = frozenset({"host", "container", "browser"})
|
|
|
45
45
|
#: is the per-release tag the production profile's image names read (ADR 0185), spelled once
|
|
46
46
|
#: in ``terp.arch.deployment.generator.RELEASE_TAG_VARIABLE`` and held equal to this entry by
|
|
47
47
|
#: ``tests/architecture/test_prod_profile.py``: this module stays off terp-arch's import path.
|
|
48
|
+
#: ``TERP_EDGE_HOPS`` is the hop a deploy tool's edge puts in front of the app, which
|
|
49
|
+
#: ``create_app`` adds to the declared count (ADR 0220): the tool that runs the edge sets it.
|
|
48
50
|
PLATFORM_OWNED_NAMES = frozenset(
|
|
49
51
|
{
|
|
50
52
|
"SECRET_KEY",
|
|
@@ -56,6 +58,7 @@ PLATFORM_OWNED_NAMES = frozenset(
|
|
|
56
58
|
"WEB_PORT",
|
|
57
59
|
"BACKEND_CORS_ORIGINS",
|
|
58
60
|
"TERP_RELEASE_TAG",
|
|
61
|
+
"TERP_EDGE_HOPS",
|
|
59
62
|
}
|
|
60
63
|
)
|
|
61
64
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""The ``terp guide security`` topic: the security declaration, refused at production boot."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
TOPIC = """\
|
|
6
|
+
The security declaration (SecurityConfig, refused at production boot)
|
|
7
|
+
|
|
8
|
+
- ONE declaration, wired on the control plane, read by create_app:
|
|
9
|
+
from terp.core import ControlPlane, CorsPolicy, RateLimit, SecurityConfig
|
|
10
|
+
control_plane = ControlPlane(security=SecurityConfig(
|
|
11
|
+
cors=CorsPolicy.allow(["https://app.example.com"]),
|
|
12
|
+
trusted_proxy_hops=1,
|
|
13
|
+
))
|
|
14
|
+
- FOUR of its states refuse a production boot (SecurityConfig.production_problems();
|
|
15
|
+
create_app raises BootError "insecure production security config"). Each has exactly
|
|
16
|
+
one declaration that answers it:
|
|
17
|
+
1. CORS unset -> CorsPolicy.from_environment(), .allow([...]) or .disabled(reason=...)
|
|
18
|
+
2. CORS allowing '*' -> name the origins; a wildcard with credentials is no origin check
|
|
19
|
+
3. rate_limit disabled -> RateLimit(requests=..., window_seconds=...)
|
|
20
|
+
4. an override disabled -> an override may LOWER or RAISE a limit, never remove it
|
|
21
|
+
Declining is a full answer and must be said out loud: CorsPolicy.disabled(reason=...)
|
|
22
|
+
is the same-origin deployment's answer, and the reason is the point of it.
|
|
23
|
+
Which browser origins may call the API is a fact of an environment, not of the source:
|
|
24
|
+
CorsPolicy.from_environment() takes the allowlist from BACKEND_CORS_ORIGINS when the app
|
|
25
|
+
is composed (ADR 0210). An environment that names none serves no cross-origin access; an
|
|
26
|
+
entry that is not an origin (a path, a trailing slash, '*') refuses the boot. Without
|
|
27
|
+
that declaration the variable opens nothing, and a boot that finds it set says so.
|
|
28
|
+
`terp verify --only production-readiness` asks these before you ship, so the refusal
|
|
29
|
+
arrives in the gate rather than at the deploy.
|
|
30
|
+
- rate_limit_overrides is a PER-PREFIX BUCKET, not a shared counter (ADR 0115):
|
|
31
|
+
SecurityConfig(rate_limit_overrides={"/api/v1/auth": RateLimit.for_credentials()})
|
|
32
|
+
Longest prefix wins; everything unmatched keeps rate_limit. Separate buckets on
|
|
33
|
+
purpose - a credential endpoint and an asset read share a process, not a counter, so
|
|
34
|
+
exhausting one family must not 429 the other. The shape mirrors the per-mount
|
|
35
|
+
max_request_bytes map: one way to scope a limit to a path, not two.
|
|
36
|
+
- trusted_proxy_hops: NAME THE PROXY YOU ACTUALLY RUN BEHIND. It defaults to 0, meaning
|
|
37
|
+
the direct TCP peer identifies the caller and X-Forwarded-For is ignored as
|
|
38
|
+
attacker-supplied. Behind one reverse proxy (the shipped nginx profile) set 1, or every
|
|
39
|
+
caller collapses onto the proxy's address and your per-caller controls - the rate limit,
|
|
40
|
+
the OIDC callback throttle - stop being per-caller. The symptom is intermittent 429s
|
|
41
|
+
that look like a traffic spike. Nothing refuses this at boot, because 0 is correct for a
|
|
42
|
+
directly-exposed app: it is a deployment fact only you know.
|
|
43
|
+
Count only the proxies your own code puts in front: a deploy tool that serves the app
|
|
44
|
+
through an edge of its own (the Terp runner) sets TERP_EDGE_HOPS=1, and create_app adds
|
|
45
|
+
that hop to your count (ADR 0220). Never count the edge here as well: one hop too many
|
|
46
|
+
reads past the edge's entry, where there is either none (every caller shares one bucket
|
|
47
|
+
again) or one the caller wrote. TERP_EDGE_HOPS is the deploy tool's, set only on a unit
|
|
48
|
+
reached through its edge alone, so environment.schema.json may not declare it, and a
|
|
49
|
+
value other than 0 or 1 refuses the boot.
|
|
50
|
+
- expose_api_docs is a deliberate opt-in, OFF in production: /docs, /redoc and
|
|
51
|
+
/openapi.json are hidden there because a production API's full schema is not public
|
|
52
|
+
information. Development always serves them, and `terp openapi` exports the document
|
|
53
|
+
either way - so turning this on is a choice to publish, not a way to get the file.
|
|
54
|
+
Commit that file instead: `openapi.json` is the app's API contract, the one a mobile
|
|
55
|
+
app or a site in another repository pins, and `terp verify --only api-contract` holds
|
|
56
|
+
it to the API the app serves, naming every change to its shape, the ones that break a
|
|
57
|
+
client first (ADR 0194). Who may call a route is not in it: authz-surface pins that.
|
|
58
|
+
- headers ships a safe SecurityHeaders set; max_request_bytes (1 MiB) is the body cap and
|
|
59
|
+
is per-mount overridable (ADR 0067); request_id_header names the correlation header
|
|
60
|
+
("X-Request-ID") echoed on every response.
|
|
61
|
+
- A NATIVE MOBILE CLIENT stays signed in through its own routes, opt-in with a reason
|
|
62
|
+
(ADR 0195): build_login_module(..., native_clients=NativeClients(reason="...")) mounts
|
|
63
|
+
POST /api/v1/auth/native/login, /native/refresh and /native/logout. The first two answer
|
|
64
|
+
the refresh token in the JSON body and run the same rotation, reuse detection and
|
|
65
|
+
revocation as the cookie, its rotation grace window included; /native/logout takes the
|
|
66
|
+
token and revokes its whole family without minting a successor. The client keeps that
|
|
67
|
+
token in the OS keychain or keystore and nowhere else, and treats a 401 from
|
|
68
|
+
/native/refresh as signed out. All three refuse any request with browser provenance
|
|
69
|
+
(Origin, any Sec-Fetch-* header, the refresh cookie) with 403 native_client_only before
|
|
70
|
+
the body is validated, so a browser stays on /login, /refresh and /logout. A HYBRID app
|
|
71
|
+
(a page inside a native shell) calls them from its native layer and hands its page only
|
|
72
|
+
access tokens: a page that holds the refresh token has given up what the cookie
|
|
73
|
+
protects. No route that mints a credential (/login, /token, /refresh, /native/login,
|
|
74
|
+
/native/refresh) accepts an Idempotency-Key; retry without one.
|
|
75
|
+
- No terp.arch check applies - there is no module code shape to police. Enforcement is
|
|
76
|
+
the create_app production fail-fast plus the production-readiness verify lane.
|
|
77
|
+
"""
|
|
@@ -4,7 +4,9 @@ ADR 0187 decision 6. Serialised canonically (sorted keys, no whitespace, UTF-8,
|
|
|
4
4
|
signed as a DSSE envelope (:mod:`terp.cli.release.dsse`). Three sections:
|
|
5
5
|
|
|
6
6
|
* ``inputs``, recomputed by ``sign`` from the commit's tree, so two cold builds of one commit
|
|
7
|
-
with one tag give the same bytes: the commit, the tag, the toolchain, the
|
|
7
|
+
with one tag give the same bytes: the commit, the tag, the toolchain, the framework the
|
|
8
|
+
release runs (the ``terp-core`` its lock pins, which a deploy tool reads to know what the
|
|
9
|
+
app's runtime does, ADR 0220), the Terp Standard
|
|
8
10
|
release the declaration was written against and its schema's SHA-256, the build state, the
|
|
9
11
|
generator's files, the project root's place in the checkout, the development profile a deploy
|
|
10
12
|
tool keeps apart, the declaration and every profile file with its content, the base images, the datastore table
|
|
@@ -144,6 +146,7 @@ def inputs(
|
|
|
144
146
|
*,
|
|
145
147
|
tag: str,
|
|
146
148
|
toolchain: dict[str, str],
|
|
149
|
+
framework: dict[str, str],
|
|
147
150
|
spec: dict[str, str],
|
|
148
151
|
generator: dict[str, Any] | None,
|
|
149
152
|
datastore_table: dict[str, Any],
|
|
@@ -167,6 +170,7 @@ def inputs(
|
|
|
167
170
|
"commit": {"sha": tree.commit, "tree": tree.tree},
|
|
168
171
|
"releaseTag": tag,
|
|
169
172
|
"toolchain": toolchain,
|
|
173
|
+
"framework": framework,
|
|
170
174
|
"spec": spec,
|
|
171
175
|
"build": plan.declaration.build,
|
|
172
176
|
"projectRoot": PROJECT_ROOT,
|
|
@@ -315,6 +315,9 @@ def sign(
|
|
|
315
315
|
cli_pin, arch_pin = pinned(lock, "terp-cli"), pinned(lock, "terp-arch")
|
|
316
316
|
if cli_pin is None or arch_pin is None:
|
|
317
317
|
raise ReleaseError(f"{UV_LOCK} pins no single terp-cli and terp-arch, so the commit's toolchain is unknown")
|
|
318
|
+
core_pin = pinned(lock, "terp-core")
|
|
319
|
+
if core_pin is None:
|
|
320
|
+
raise ReleaseError(f"{UV_LOCK} pins no single terp-core, so the framework the release runs is unknown")
|
|
318
321
|
required_ids = set()
|
|
319
322
|
if gate[GATE_DOCUMENT] > 1:
|
|
320
323
|
project = tomllib.loads(tree.read_text("pyproject.toml"))
|
|
@@ -414,6 +417,7 @@ def sign(
|
|
|
414
417
|
inputs(
|
|
415
418
|
tree, plan, tag=tag,
|
|
416
419
|
toolchain={"signer": _signer_version(), "terpCli": cli_pin, "terpArch": arch_pin},
|
|
420
|
+
framework={"terpCore": core_pin},
|
|
417
421
|
spec={"release": arch.spec, "schemaSha256": arch.schema_sha256},
|
|
418
422
|
generator=generator, datastore_table=arch.datastores, platform=platform,
|
|
419
423
|
),
|
|
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
|
|
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
|
|
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
|