Compare commits
7 Commits
v0.5.2
...
323e2038b6
| Author | SHA1 | Date | |
|---|---|---|---|
| 323e2038b6 | |||
| 852137982d | |||
| 7e8bdd9c39 | |||
| be8f198b00 | |||
| e263344897 | |||
| 43b9fb86c7 | |||
| 9fb26adca0 |
@@ -19,4 +19,4 @@ jobs:
|
||||
run: |
|
||||
docker run --rm -v "$PWD:/repo" -w /repo \
|
||||
-e REGISTRY_TOKEN -e REGISTRY_USER -e REPO_TOKEN -e REPOSITORY -e SERVER_URL \
|
||||
node:26.13.0-alpine3.24 node registry-cleanup/cleanup.ts
|
||||
node:26.13.1-alpine3.24 node registry-cleanup/cleanup.ts
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
GIT_TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker run --rm -v "$PWD:/repo" -w /repo node:26.13.0-alpine3.24 \
|
||||
docker run --rm -v "$PWD:/repo" -w /repo node:26.13.1-alpine3.24 \
|
||||
node release-tooling/contract-version.ts "$GIT_TAG" src/plugin-host/plugin.ts
|
||||
- name: Promote the commit-hash image to semver + latest
|
||||
env:
|
||||
@@ -100,9 +100,9 @@ jobs:
|
||||
VERSION=${INPUT_VERSION:-${GIT_TAG#v}}
|
||||
VERSION=${VERSION#v}
|
||||
# An empty dispatch input falls back to the branch name, so gate this like a tag.
|
||||
docker run --rm -v "$PWD:/repo" -w /repo node:26.13.0-alpine3.24 \
|
||||
docker run --rm -v "$PWD:/repo" -w /repo node:26.13.1-alpine3.24 \
|
||||
node release-tooling/contract-version.ts "$VERSION" src/plugin-host/plugin.ts
|
||||
docker run --rm -v "$PWD:/repo" -w /repo \
|
||||
-e DOCKERHUB_REPO -e DOCKERHUB_TOKEN -e DOCKERHUB_USER \
|
||||
node:26.13.0-alpine3.24 \
|
||||
node:26.13.1-alpine3.24 \
|
||||
node release-tooling/dockerhub-overview.ts "$VERSION"
|
||||
|
||||
@@ -60,11 +60,11 @@ jobs:
|
||||
if [ -z "$BUMPS" ]; then
|
||||
echo "Renovate commits since ${LATEST}, but none carry Release-Bump — nothing reached a running Plainpages; skipping"; exit 0
|
||||
fi
|
||||
NEXT=$(docker run --rm -v "$PWD:/repo" -w /repo node:26.13.0-alpine3.24 \
|
||||
NEXT=$(docker run --rm -v "$PWD:/repo" -w /repo node:26.13.1-alpine3.24 \
|
||||
node release-tooling/next-version.ts "$LATEST" $BUMPS)
|
||||
# Read the constant off origin/main, not the checkout, which lags the merges this run made.
|
||||
git show origin/main:src/plugin-host/plugin.ts \
|
||||
| docker run -i --rm -v "$PWD:/repo" -w /repo node:26.13.0-alpine3.24 \
|
||||
| docker run -i --rm -v "$PWD:/repo" -w /repo node:26.13.1-alpine3.24 \
|
||||
node release-tooling/contract-version.ts "$NEXT" -
|
||||
echo "Releasing $LATEST -> $NEXT"
|
||||
git tag "$NEXT" origin/main
|
||||
|
||||
@@ -98,6 +98,7 @@ on; a review honours them.
|
||||
- A permission name is always `<resource>:<action>`, enforced at discovery
|
||||
- Permission names are authored in plugin code; only grants live in Keto
|
||||
- A permission's `<resource>` is global, not plugin-scoped
|
||||
- The `Resource` namespace is shared by all plugins, and an object is `<resource>:<row-id>`
|
||||
- Declaring a permission stays optional
|
||||
- `ADMIN_PERMISSIONS` defaults to empty, and an unusable value is dropped with a warning
|
||||
- `actionForMethod` is plugin-local and stays out of `@plainpages/plugin-api`
|
||||
|
||||
@@ -263,6 +263,13 @@ proxy in front of Plainpages can't store a signed-in page and serve it to the ne
|
||||
whose page is the same for everyone can still set its own `cache-control` through
|
||||
`RouteResult.headers`; assets are unchanged.
|
||||
|
||||
### A per-row Keto grant names its object `<resource>:<row-id>`
|
||||
|
||||
`Resource` is one namespace shared by every plugin, so a bare row id (`4471`) lets two plugins' rows
|
||||
share one grant. Name the object `shift:4471`, with the same `<resource>` word as your permissions.
|
||||
Nothing checks this. The README's per-row example now does, and checks the `edit` permit, not the
|
||||
`editors` relation, so an owner passes.
|
||||
|
||||
## 0.4.0
|
||||
|
||||
**Breaking.** Set `apiVersion: "0.4.0"`. The app shell no longer bounds the content column, so a page
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Node 24 runs TypeScript directly (type stripping) — no build step. Pinned exact tag.
|
||||
FROM node:26.13.0-alpine3.24
|
||||
FROM node:26.13.1-alpine3.24
|
||||
|
||||
# Above WORKDIR so dev's `.:/app` bind mount can't shadow them; a volume at /app/node_modules
|
||||
# instead leaves a root-owned dir in the checkout (the daemon creates mount destinations as root).
|
||||
|
||||
@@ -249,7 +249,7 @@ Keto relation tuples: `Permission:<name>#granted@user:<id>`, or `@Group:<name>#m
|
||||
| **User** | Kratos | who you are | `user:0198f2c1-…` |
|
||||
| **Group** | Keto | who — a reusable set | `Group:support` |
|
||||
| **Permission** | Keto | what you may do | `Permission:scheduling:read` |
|
||||
| **Resource** | Keto | which specific row | `Resource:shift-4471` |
|
||||
| **Resource** | Keto | which specific row | `Resource:shift:4471` |
|
||||
|
||||
Keto's whole model is one primitive — `namespace:object#relation@subject` — so those four
|
||||
namespaces are *ours*, declared in `ory/keto/namespaces.keto.ts`; Keto resolves them, transitively
|
||||
@@ -359,6 +359,15 @@ The `Resource` namespace covers what a coarse permission cannot express: *this*
|
||||
*this* person. A `Resource` carries Keto `permits` (`view`, `edit`, `delete`, nesting as `owner` ⊇
|
||||
`editor` ⊇ `viewer`) and never appears in the JWT.
|
||||
|
||||
> **Warning: name the object `<resource>:<row-id>`, never the bare row id.** `Resource` is one
|
||||
> namespace shared by every plugin, and Keto stores the object as an opaque string. Two plugins that
|
||||
> each have a row `4471` and both write `object: "4471"` share one grant: whoever may edit shift
|
||||
> 4471 may edit invoice 4471. Prefix every object with the same `<resource>` word your permissions
|
||||
> use (`shift:4471`, `invoice:4471`). Nothing checks this, at boot or at runtime. Check a *permit*
|
||||
> (`view`, `edit`, `delete`), not a stored relation (`owners`, `editors`, `viewers`), so an owner
|
||||
> passes an `edit` check. A plugin that needs relations `Resource` can't express adds its own class
|
||||
> to `ory/keto/namespaces.keto.ts`.
|
||||
|
||||
**A per-row grant never widens a coarse gate** — the route's `permission` is checked before the
|
||||
handler runs. Gate the route on something they hold, then narrow inside the handler:
|
||||
|
||||
@@ -366,7 +375,7 @@ handler runs. Gate the route on something they hold, then narrow inside the hand
|
||||
{ method: "POST", path: "/shifts/:id", permission: READ, handler: editShift }
|
||||
|
||||
async function editShift(ctx) {
|
||||
if (!(await check(keto, ctx, { namespace: "Resource", object: ctx.params.id, relation: "editors" })))
|
||||
if (!(await check(keto, ctx, { namespace: "Resource", object: `shift:${ctx.params.id}`, relation: "edit" })))
|
||||
throw new GuardError(403, "not an editor of this shift");
|
||||
…
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ services:
|
||||
# backs it (PLUGIN_SETTING_SCHEDULING_UPSTREAM above points here). Stand-in for the customer's real service —
|
||||
# stdlib-only, in-memory, no auth. Prod points PLUGIN_SETTING_SCHEDULING_UPSTREAM at the real backend instead.
|
||||
shifts-upstream:
|
||||
image: node:26.13.0-alpine3.24
|
||||
image: node:26.13.1-alpine3.24
|
||||
command: node /srv/server.ts
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
|
||||
@@ -600,3 +600,39 @@ Inherited architect, would restructure first:
|
||||
- Locality: `src/http/app.ts:202` `Host`: 19 fields, and a new request capability touches four files
|
||||
- Shape, Self-sufficiency: `examples/plugins/auth-admin/admin-shared.ts:107` `FieldConfig`: the type for a core partial's option shape lives in an example plugin
|
||||
- Locality: `src/auth/login.ts:48` `readPermissions`: a second copy of the Keto paging loop that nothing says the barrel boundary forces
|
||||
|
||||
## 2026-11-16T23:56:01Z, PR #247 at 7e8bdd9
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Junior A | 7.5 | 6.5 | 7 | 6.5 | 7 |
|
||||
| Mid A | 8 | 7 | 7 | 7 | 7.5 |
|
||||
| Maintainability senior | 7.5 | 6 | 7 | 7 | 7 |
|
||||
| Inherited architect | 7 | 7 | 6.5 | 7 | 7 |
|
||||
| Mean | 7.50 | 6.63 | 6.88 | 6.88 | 7.13 |
|
||||
|
||||
Junior A, hardest first:
|
||||
|
||||
- Locality, Shape, Overall: `src/http/app.ts:67` `createApp`: about 130 lines of closures that refer to each other, `switchBase` reads `builtinRoutes` declared later
|
||||
- Locality: `src/http/app.ts:263` `prepareRequest`: chrome is memoized lazily twice, and an untyped `shared` bag feeds `buildContext`
|
||||
- Self-sufficiency: `src/auth/routes.ts:58` `flowFailure`: six branches keyed on Kratos statuses that nothing in the file explains
|
||||
- Locality: `src/server.ts:25` `delete process.env["PLUGIN_DB_SECRET"]`: a load-bearing order rule in a top-level script
|
||||
|
||||
Mid A, hardest first:
|
||||
|
||||
- Locality, Shape, Overall: `src/http/app.ts:67` `createApp`: about 130 lines, 20 option fields, route table and `switchBase` refer to each other
|
||||
- Locality: `src/http/app.ts:263` `prepareRequest`: implicit stage order, three ways to get a context
|
||||
- Self-sufficiency: `src/auth/routes.ts:58` `flowFailure`: the Kratos status meanings are unexplained
|
||||
|
||||
Maintainability senior, hardest first:
|
||||
|
||||
- Locality, Shape, Overall: `src/http/app.ts:67` `createApp`: about 130 lines, a dozen closures calling each other
|
||||
- Locality: `src/i18n/locale.ts:81` `chosenLocale`: recovers "was a locale requested" from `localeHref("/") === "/"`, so the name hides the mechanism
|
||||
- Locality: `views/partials/data-table.ejs:74` include: EJS locals leak from page to partial, defended by explicit null options
|
||||
- Self-sufficiency: `examples/plugins/auth-admin/admin-groups.ts:434` `groupsDelete`: its comment ends with a pointer to `todo.md`
|
||||
|
||||
Inherited architect, would restructure first:
|
||||
|
||||
- Navigation, Shape, Overall: `src/auth/bootstrap.ts:1` `src/auth`: 20 files over four concerns, and `bootstrap.ts` belongs to none of them
|
||||
- Shape: `public/css/styles.css:81` dark and light palette mapping: the same token list written three times
|
||||
- Locality: `src/http/app.ts:202` `Host`: restates the options and locals a third time, so a new capability touches several files
|
||||
|
||||
@@ -209,6 +209,18 @@ Hence `oauth2-clients`, not `clients`. Users are the host's, and plugins share t
|
||||
that collision-freedom is a convention rather than structural; the alternative penalizes the
|
||||
sharing case.
|
||||
|
||||
## The `Resource` namespace is shared by all plugins, and an object is `<resource>:<row-id>`
|
||||
|
||||
2026-11-17, the maintainer. Goal 7. Valid while no plugin needs a relation `Resource` can't express.
|
||||
|
||||
Ory's examples use one namespace per domain (`Shift`, `Document`). Splitting here would make an
|
||||
operator edit `ory/keto/namespaces.keto.ts` for every plugin, so a drop-in stops being drop-in, and
|
||||
a missing namespace fails on the first request rather than at boot. It also breaks the contract
|
||||
(a minor) for a tier no shipped code uses. One namespace with the kind in the object follows the
|
||||
`<resource>` rule above and `Permission:<resource>:<action>`. The cost is that nothing enforces
|
||||
the prefix, so a bare row id lets two plugins share a grant; the README warns of it. A plugin that
|
||||
needs its own relations adds a class to the OPL file, which already works. Revisit when one does.
|
||||
|
||||
## Declaring a permission stays optional
|
||||
|
||||
2026-08-05, the maintainer. Goal 7. Valid while plugins may share a permission.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Playwright runner — browsers preinstalled, pinned to match @playwright/test in e2e-tests/.
|
||||
# Built/run via e2e-tests/compose.visual.yml; targets the `web` service over the network.
|
||||
FROM mcr.microsoft.com/playwright:v1.65.0-noble
|
||||
FROM mcr.microsoft.com/playwright:v1.65.1-noble
|
||||
|
||||
WORKDIR /e2e-tests
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ services:
|
||||
|
||||
# The reference plugin's upstream (examples/shifts-upstream) so /scheduling/shifts shows real rows.
|
||||
shifts-upstream:
|
||||
image: node:26.13.0-alpine3.24
|
||||
image: node:26.13.1-alpine3.24
|
||||
command: ["node", "/server.ts"]
|
||||
volumes:
|
||||
- ./examples/shifts-upstream/server.ts:/server.ts:ro
|
||||
@@ -66,7 +66,7 @@ services:
|
||||
# Mock OIDC provider for the SSO login test — stdlib Node, auto-approves, signs an id_token Kratos
|
||||
# verifies via its jwks. Reachable as the same host (mock-oidc:9000) by both the browser and Kratos.
|
||||
mock-oidc:
|
||||
image: node:26.13.0-alpine3.24
|
||||
image: node:26.13.1-alpine3.24
|
||||
command: ["node", "/mock-oidc.ts"]
|
||||
environment:
|
||||
ISSUER: http://mock-oidc:9000
|
||||
@@ -92,7 +92,7 @@ services:
|
||||
|
||||
# Same-origin gateway: Kratos-owned paths → kratos, everything else → web (e2e-tests/proxy.ts).
|
||||
proxy:
|
||||
image: node:26.13.0-alpine3.24
|
||||
image: node:26.13.1-alpine3.24
|
||||
command: ["node", "/proxy.ts"]
|
||||
depends_on:
|
||||
web:
|
||||
|
||||
Generated
+12
-12
@@ -6,19 +6,19 @@
|
||||
"": {
|
||||
"name": "plainpages-e2e",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.65.0",
|
||||
"@playwright/test": "1.65.1",
|
||||
"@types/node": "26.6.6",
|
||||
"typescript": "7.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.65.0",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.0.tgz",
|
||||
"integrity": "sha512-iGURLGuKDLakSEl7Pgfv8h7f+XLT+V861Wfhz0zlEl5nyFuKUopdkFBPKqTllTUp06aOwPuH8iuUEb3yp3MpbQ==",
|
||||
"version": "1.65.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz",
|
||||
"integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.65.0"
|
||||
"playwright": "1.65.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
@@ -378,13 +378,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.65.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.0.tgz",
|
||||
"integrity": "sha512-F3AMWcR44qMBt4kq+6Kb6mX7bjGXshktKFOPULd7reED6ZJWevjbNRqysP7q+AATE9kdPEZBibex1BYsvpVoeA==",
|
||||
"version": "1.65.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz",
|
||||
"integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.65.0"
|
||||
"playwright-core": "1.65.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
@@ -394,9 +394,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.65.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.0.tgz",
|
||||
"integrity": "sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==",
|
||||
"version": "1.65.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz",
|
||||
"integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.65.0",
|
||||
"@playwright/test": "1.65.1",
|
||||
"@types/node": "26.6.6",
|
||||
"typescript": "7.0.2"
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ class Permission implements Namespace {
|
||||
// A fine-grained, relationship-checked resource — README's third "may I?" tier, the rare
|
||||
// live Keto check (e.g. sharing/delegation). Permits nest: owner ⊇ editor ⊇ viewer.
|
||||
// Grants accept a user directly or any member of a group.
|
||||
// Every plugin shares this namespace, so an object is `<resource>:<row-id>` (`shift:4471`):
|
||||
// a bare row id lets two plugins' rows share one grant. Nothing enforces that.
|
||||
class Resource implements Namespace {
|
||||
related: {
|
||||
owners: (User | SubjectSet<Group, "members">)[]
|
||||
|
||||
Generated
+8
-8
@@ -6,13 +6,13 @@
|
||||
"": {
|
||||
"name": "plainpages",
|
||||
"dependencies": {
|
||||
"@larvit/log": "2.5.0",
|
||||
"@larvit/log": "2.6.1",
|
||||
"ejs": "7.0.2",
|
||||
"lucide-static": "1.70.0",
|
||||
"postgres": "4.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mdn/browser-compat-data": "8.1.8",
|
||||
"@mdn/browser-compat-data": "8.1.9",
|
||||
"@types/ejs": "3.1.5",
|
||||
"@types/node": "26.6.6",
|
||||
"acorn": "8.19.0",
|
||||
@@ -23,18 +23,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@larvit/log": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@larvit/log/-/log-2.5.0.tgz",
|
||||
"integrity": "sha512-xky7OVFDw4Ftf60Syn0eKT47xSepbjcghiwIS5NCyawZc/TVR0YWnDrWubc1sO0/MC2m2j0HdxirsZj0APf05A==",
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@larvit/log/-/log-2.6.1.tgz",
|
||||
"integrity": "sha512-+AKHV37gxmB21G56bpzScVe5Em0jYr18vzEM42lAV17aNYy9SpZhUCzyqk0eE8HE4nbC51TTut1v+nDuzkQbKQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@mdn/browser-compat-data": {
|
||||
"version": "8.1.8",
|
||||
"resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-8.1.8.tgz",
|
||||
"integrity": "sha512-+RK7inkLeZ70kr9Mo+Y81JjZMpQIt0Sx40tHHU0hXGDSdf9YvlawH+4WlUpP3SE8rFLmjqGiTzL+qPPPnncWDw==",
|
||||
"version": "8.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-8.1.9.tgz",
|
||||
"integrity": "sha512-7d8D9yzVS4ugLbt4clzc5DKU8dq85K0lRebjzpP43GxSr7vYKmczgfuEU+0beimjl5YmnHkcErtolg5t5ttb0A==",
|
||||
"dev": true,
|
||||
"license": "CC0-1.0"
|
||||
},
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@
|
||||
"test": "node --test \"src/**/*.test.ts\" \"plugins/**/*.test.ts\" \"examples/**/*.test.ts\" \"registry-cleanup/**/*.test.ts\" \"release-tooling/**/*.test.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@larvit/log": "2.5.0",
|
||||
"@larvit/log": "2.6.1",
|
||||
"ejs": "7.0.2",
|
||||
"lucide-static": "1.70.0",
|
||||
"postgres": "4.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mdn/browser-compat-data": "8.1.8",
|
||||
"@mdn/browser-compat-data": "8.1.9",
|
||||
"@types/ejs": "3.1.5",
|
||||
"@types/node": "26.6.6",
|
||||
"acorn": "8.19.0",
|
||||
|
||||
+2
-1
@@ -41,7 +41,8 @@ export function can(ctx: RequestContext, permission: string): boolean {
|
||||
}
|
||||
|
||||
// Live Keto relationship check at the point of action. The subject is the current user;
|
||||
// anonymous ⇒ false (fail-closed, no Keto call).
|
||||
// anonymous ⇒ false (fail-closed, no Keto call). In the shared `Resource` namespace the object
|
||||
// is `<resource>:<row-id>`, never a bare id (README → Fine-grained, per-row access).
|
||||
export async function check(
|
||||
keto: KetoClient,
|
||||
ctx: RequestContext,
|
||||
|
||||
@@ -268,14 +268,14 @@ test("session re-mint runs only for an expired token with all three Ory clients
|
||||
});
|
||||
|
||||
test("guards map to responses: requireSession → /login, a failed can/check → 403, success runs the handler", async (t) => {
|
||||
const keto = { check: async (tuple: { object: string }) => tuple.object === "open" } as unknown as Parameters<typeof check>[0];
|
||||
const keto = { check: async (tuple: { object: string }) => tuple.object === "doc:open" } as unknown as Parameters<typeof check>[0];
|
||||
const guarded: Plugin = {
|
||||
apiVersion: "1.0.0",
|
||||
id: "guarded",
|
||||
routes: [
|
||||
{ handler: (ctx) => ({ html: `hi ${requireSession(ctx).email}` }), method: "GET", path: "/me" },
|
||||
{ handler: (ctx) => { if (!can(ctx, "admin")) throw new GuardError(403, "no"); return { html: "ok" }; }, method: "GET", path: "/admin-only" },
|
||||
{ handler: async (ctx) => { if (!(await check(keto, ctx, { namespace: "Resource", object: ctx.params.id ?? "", relation: "view" }))) throw new GuardError(403, "no"); return { html: "seen" }; }, method: "GET", path: "/doc/:id" },
|
||||
{ handler: async (ctx) => { if (!(await check(keto, ctx, { namespace: "Resource", object: `doc:${ctx.params.id ?? ""}`, relation: "view" }))) throw new GuardError(403, "no"); return { html: "seen" }; }, method: "GET", path: "/doc/:id" },
|
||||
{ handler: () => ({ html: "gated" }), method: "GET", path: "/gated", permission: "secret:read" }, // declarative route gate
|
||||
{ handler: () => ({ html: "mine" }), method: "GET", path: "/mine", session: true }, // declarative session gate
|
||||
],
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
|
||||
`Bar = 1`
|
||||
|
||||
`Next ID = 73`
|
||||
`Next ID = 74`
|
||||
|
||||
## Items
|
||||
|
||||
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 19 | 0.6.0 | | question | **Run the documented Docker commands on macOS and fix whatever misbehaves.** | 2 | 2 | 1 | 3 | 3 | 1 by 3 | 3.3 |
|
||||
| 16 | 0.6.0 | | question | **Decide whether the single Keto `Resource` namespace splits into per-domain namespaces.** | 3 | 2 | 3 | 6 | 6 | 7 by 2 | 0.5 |
|
||||
| 65 | 0.6.0 | | | **Export `KetoError` from `@plainpages/plugin-api`, so a plugin can tell a Keto failure apart with `instanceof`.** | 1 | 2 | 1 | 2 | 1 | 7 by 3, 1 by 1 | 6.7 |
|
||||
| 72 | 0.6.0 | | | **Delete a group's grants and parent memberships when its last member leaves, by group delete or by removing the member, so re-creating the name restores none.** | 2 | 2 | 2 | 4 | 3 | 2 by 4 | 4.2 |
|
||||
| 67 | 0.6.0 | | | **Group `src/auth`'s modules into one subfolder per concern, with `bootstrap.ts` staying at `src/auth/bootstrap.ts`.** | 3 | 1 | 2 | 4 | 6 | code health by 4 | 4.0 |
|
||||
| 14 | 0.6.0 | | | **Drop a double-clicked duplicate submit, with no client-side JavaScript.** | 4 | 2 | 3 | 7 | 7 | 2 by 7, 1 by 4 | 1.4 |
|
||||
| 67 | 0.6.0 | | | **Group `src/auth`'s modules into one subfolder per concern, with `bootstrap.ts` staying at `src/auth/bootstrap.ts`.** | 3 | 1 | 2 | 4 | 6 | code health by 4 | 1.0 |
|
||||
| 19 | 0.7.0 | | question | **Run the documented Docker commands on macOS and fix whatever misbehaves.** | 2 | 2 | 1 | 3 | 3 | 1 by 3 | 3.3 |
|
||||
| 73 | 0.7.0 | | owner | **Reach the comprehension floor: make the request pipeline in `src/http/app.ts` and the locale and EJS-locals plumbing readable one unit at a time, so every dimension mean reaches 7.0.** | 3 | 1 | 2 | 4 | 7 | code health by 7 | 0.9 |
|
||||
|
||||
## Renamed
|
||||
|
||||
@@ -26,16 +26,6 @@
|
||||
|
||||
## Details
|
||||
|
||||
### 19. Run the documented Docker commands on macOS and fix whatever misbehaves.
|
||||
|
||||
Needs a Mac. Two suspects, both from `--user "$(id -u):$(id -g)"`: a macOS `id -g` is `20`, which is
|
||||
`dialout` inside the noble image, and Docker Desktop remaps bind-mount ownership in its VM.
|
||||
|
||||
### 16. Decide whether the single Keto `Resource` namespace splits into per-domain namespaces.
|
||||
|
||||
Ory's own examples model `Shift`, `Document` and so on. One global `Resource` bucket is the
|
||||
project's "no catch-all names" rule applied to namespaces.
|
||||
|
||||
### 65. Export `KetoError` from `@plainpages/plugin-api`, so a plugin can tell a Keto failure apart with `instanceof`.
|
||||
|
||||
`src/plugin-host/plugin-api.ts` ~L47-48 exports `KratosError` and `HydraError`, but not `KetoError`
|
||||
@@ -44,6 +34,12 @@ surface, so this adds to the plugin API: it ships in a minor, and `HOST_API_VERS
|
||||
`0.6.0` when 0.6.0 is tagged (AGENTS.md → Rules). Adding is safe for installed plugins; removing it
|
||||
later would take a major.
|
||||
|
||||
Touches:
|
||||
|
||||
- `src/plugin-host/plugin-api.ts`: the `export { KratosError }` and `export { HydraError }` lines (small)
|
||||
- `src/plugin-host/plugin.ts`: `HOST_API_VERSION` (small)
|
||||
- `src/plugin-host/plugin-api.test.ts`: the barrel's export test (small)
|
||||
|
||||
### 72. Delete a group's grants and parent memberships when its last member leaves, by group delete or by removing the member, so re-creating the name restores none.
|
||||
|
||||
In `examples/plugins/auth-admin/admin-groups.ts` a group exists exactly while it has a
|
||||
@@ -66,6 +62,29 @@ admin example removes a deleted group from the groups it was nested in", which t
|
||||
left with no members no longer exists as a group. `lostToSelf`, in this file, is a place the seats
|
||||
found hard; if the change touches it, make it easier to read.
|
||||
|
||||
Touches:
|
||||
|
||||
- `examples/plugins/auth-admin/admin-groups.ts`: `groupsDelete`, `groupsRemoveMember`, `lostToSelf` (small)
|
||||
- `examples/plugins/auth-admin/admin-groups.test.ts`
|
||||
|
||||
### 14. Drop a double-clicked duplicate submit, with no client-side JavaScript.
|
||||
|
||||
A second identical POST is expected from a non-technical user, and today creates two
|
||||
users, mints two recovery codes, or registers two OAuth2 clients. It must not break a legitimately
|
||||
repeatable action. Sketch: a CSS-only affordance so the second click has nothing to hit, plus the
|
||||
host recognising a duplicate (same session, route and payload within a short window), logging and
|
||||
dropping it. Open: what identifies "the same submission" (a one-time token minted into each form
|
||||
beats hashing the payload), the window, where the record lives given the host is stateless, and how
|
||||
a plugin declares a route repeatable.
|
||||
|
||||
Touches:
|
||||
|
||||
- `src/http/app.ts`: `answerPluginRoute`, `answerBuiltinRoute`, `prepareRequest`, `requestCsrf`
|
||||
- `src/plugin-host/plugin.ts`: `Route` (small)
|
||||
- `src/auth/csrf.ts`
|
||||
- `public/css/styles.css`: lines 323-340 (small)
|
||||
- `README.md`: `### Routes & handlers`
|
||||
|
||||
### 67. Group `src/auth`'s modules into one subfolder per concern, with `bootstrap.ts` staying at `src/auth/bootstrap.ts`.
|
||||
|
||||
`src/auth` holds 19 modules over several concerns: the per-request session path (`jwt*`, `jwks`,
|
||||
@@ -77,12 +96,87 @@ name, and update the folder list in `docs/decisions.md` → "`src/` is grouped b
|
||||
barrel, so only `src/plugin-host/plugin-api.ts`'s paths change for them. Update the README file
|
||||
map. Make `src/auth` easier to navigate, a place the seats found hard.
|
||||
|
||||
### 14. Drop a double-clicked duplicate submit, with no client-side JavaScript.
|
||||
Touches:
|
||||
|
||||
A second identical POST is expected from a non-technical user, and today creates two
|
||||
users, mints two recovery codes, or registers two OAuth2 clients. It must not break a legitimately
|
||||
repeatable action. Sketch: a CSS-only affordance so the second click has nothing to hit, plus the
|
||||
host recognising a duplicate (same session, route and payload within a short window), logging and
|
||||
dropping it. Open: what identifies "the same submission" (a one-time token minted into each form
|
||||
beats hashing the payload), the window, where the record lives given the host is stateless, and how
|
||||
a plugin declares a route repeatable.
|
||||
- `src/auth/csrf.ts`
|
||||
- `src/auth/csrf.test.ts`
|
||||
- `src/auth/denylist.ts`
|
||||
- `src/auth/denylist.test.ts`
|
||||
- `src/auth/fetch-timeout.ts`
|
||||
- `src/auth/fetch-timeout.test.ts`
|
||||
- `src/auth/flow-view.ts`
|
||||
- `src/auth/flow-view.test.ts`
|
||||
- `src/auth/gate.ts`
|
||||
- `src/auth/gate.test.ts`
|
||||
- `src/auth/gen-jwks.ts`
|
||||
- `src/auth/gen-jwks.test.ts`
|
||||
- `src/auth/guards.ts`
|
||||
- `src/auth/guards.test.ts`
|
||||
- `src/auth/hydra-admin.ts`
|
||||
- `src/auth/hydra-admin.test.ts`
|
||||
- `src/auth/jwks.ts`
|
||||
- `src/auth/jwks.test.ts`
|
||||
- `src/auth/jwt-middleware.ts`
|
||||
- `src/auth/jwt-middleware.test.ts`
|
||||
- `src/auth/jwt.ts`
|
||||
- `src/auth/jwt.test.ts`
|
||||
- `src/auth/keto-client.ts`
|
||||
- `src/auth/keto-client.test.ts`
|
||||
- `src/auth/kratos-admin.ts`
|
||||
- `src/auth/kratos-admin.test.ts`
|
||||
- `src/auth/kratos-public.ts`
|
||||
- `src/auth/kratos-public.test.ts`
|
||||
- `src/auth/link-header.ts`
|
||||
- `src/auth/link-header.test.ts`
|
||||
- `src/auth/login.ts`
|
||||
- `src/auth/login.test.ts`
|
||||
- `src/auth/oauth-consent.ts`
|
||||
- `src/auth/oauth-consent.test.ts`
|
||||
- `src/auth/oauth-login.ts`
|
||||
- `src/auth/oauth-login.test.ts`
|
||||
- `src/auth/routes.ts`
|
||||
- `src/auth/routes.test.ts`
|
||||
- `src/auth/bootstrap.ts`: import lines (small)
|
||||
- `src/auth/bootstrap.test.ts`: import lines (small)
|
||||
- `src/plugin-host/plugin-api.ts`: the `../auth/` export lines (small)
|
||||
- `src/plugin-host/plugin.ts`: the `Gate` import (small)
|
||||
- `src/plugin-host/plugin.test.ts`: the `AUTH_FLOWS` import (small)
|
||||
- `src/plugin-host/discovery.ts`: the `gate.ts` import (small)
|
||||
- `src/plugin-host/system.ts`: the three client-type imports (small)
|
||||
- `src/http/app.ts`: the `../auth/` import lines (small)
|
||||
- `src/http/app.test.ts`: import lines (small)
|
||||
- `src/http/app-admin.test.ts`: import lines (small)
|
||||
- `src/http/app-auth.test.ts`: import lines (small)
|
||||
- `src/http/app-i18n.test.ts`: import lines (small)
|
||||
- `src/http/app-plugins.test.ts`: import lines (small)
|
||||
- `src/http/builtin-route.ts`: the `Gate` import (small)
|
||||
- `src/ui/chrome.ts`: the `gate.ts` import (small)
|
||||
- `src/ui/nav.ts`: the `gate.ts` import (small)
|
||||
- `src/test-tooling/app-harness.ts`: import lines (small)
|
||||
- `src/server.ts`: the `./auth/` import lines (small)
|
||||
- `src/function-limits.test.ts`: the `src/auth/` keys (small)
|
||||
- `src/postgres.test.ts`: the `src/auth/bootstrap.ts` path (small, only if bootstrap's path changes)
|
||||
- `README.md`: `## Project layout`, `## Users, groups & permissions` (small), `## Building blocks` (small), `### Instant revoke: the optional denylist` (small), `### OAuth2 provider (Hydra)` (small), `## JWT signing key & rotation` (small), `### Scheduled rotation` (small), `### Emergency rotation (key compromise)` (small)
|
||||
- `package.json`: the `gen-jwks` script (small)
|
||||
- `compose.yml`: the `src/auth/bootstrap.ts` comment and command (small)
|
||||
|
||||
### 19. Run the documented Docker commands on macOS and fix whatever misbehaves.
|
||||
|
||||
Needs a Mac. Two suspects, both from `--user "$(id -u):$(id -g)"`: a macOS `id -g` is `20`, which is
|
||||
`dialout` inside the noble image, and Docker Desktop remaps bind-mount ownership in its VM.
|
||||
|
||||
### 73. Reach the comprehension floor: make the request pipeline in `src/http/app.ts` and the locale and EJS-locals plumbing readable one unit at a time, so every dimension mean reaches 7.0.
|
||||
|
||||
The scoring run on PR #247 at 7e8bdd9 gave means Navigation 7.50, Locality 6.63, Shape 6.88, Self-sufficiency 6.88, Overall 7.13. Locality is the lowest. Item 67 covers the `src/auth` folder, so this item leaves it out.
|
||||
|
||||
Places the seats named, to make easier to read:
|
||||
- `src/http/app.ts:67` `createApp`: about 130 lines of closures that refer to each other, and `switchBase` reads `builtinRoutes`, which is declared later; all four seats named it.
|
||||
- `src/http/app.ts:263` `prepareRequest` and `src/http/context.ts:97` `buildContext`: chrome is memoized lazily in both, and an untyped `shared` bag feeds the context, so a new context field touches about five declarations.
|
||||
- `src/http/app.ts:202` `Host`: restates the options and locals a third time.
|
||||
- `src/i18n/locale.ts:81` `chosenLocale`: recovers "was a locale requested" from `localeHref("/") === "/"`, so its name hides the mechanism.
|
||||
- `views/partials/data-table.ejs:74`, `views/partials/menu.ejs:22` and `views/partials/filter-bar.ejs:26`: EJS locals leak into includes, defended by explicit null options.
|
||||
- `src/server.ts:25` `delete process.env["PLUGIN_DB_SECRET"]`: a load-bearing order rule in a top-level script.
|
||||
- `public/css/styles.css:81`: the dark and light token mapping is written three times.
|
||||
- `src/auth/routes.ts:58` `flowFailure`: Kratos statuses that no comment in the file explains.
|
||||
|
||||
Aim: a reader of one unit should not need the other units open beside it. Re-run the scoring run when it ships.
|
||||
|
||||
Reference in New Issue
Block a user