Skip to content

Commit 82adc50

Browse files
committed
test(service-storage): pin the #24366 fake engine to the engine contract; docs: storage refuses a gated session
The new pin's fake engine opens findOne with assertEngineFindOnePredicate and update with assertEngineUpdateDispatch, as check:engine-double-contract requires, and the pinned ledger records it. The authentication docs now say that the storage routes refuse a gated session whatever else the request carries. Claude-Session: https://claude.ai/code/session_01Nk17Z26X5DB59iQztDBADH Co-authored-by: Claude <noreply@anthropic.com>
1 parent 42713d2 commit 82adc50

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎content/docs/permissions/authentication.mdx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,11 @@ often before the account-level lock engages.
610610
> enrollment is refused with the same `403 MFA_REQUIRED` and message on every
611611
> face that admits keys. `PASSWORD_EXPIRED` and `PASSWORD_RESET_REQUIRED` hold
612612
> *password sign-in* only, so the owner's API keys keep working. The refusal is
613-
> not a revocation: the same key works again the moment its owner enrolls. A
614-
> request is judged by the credential that admitted it, so a session cookie
615-
> sent beside an API key never answers for the key. The auth endpoints (sign-in, change-password, two-factor enrollment
613+
> not a revocation: the same key works again the moment its owner enrolls. By
614+
> default a request is judged by the credential that admitted it, so a session
615+
> cookie sent beside an API key never answers for the key. The storage routes
616+
> are the exception: there a gated session is refused whatever else the
617+
> request carries. The auth endpoints (sign-in, change-password, two-factor enrollment
616618
> and sign-out among them) and a short allow-list kept with that decision
617619
> (health and discovery among them) still pass, so the user can remediate. Platform administration is not part of that exemption: the
618620
> platform-admin actions refuse a gated session with the same `403`, a platform

‎packages/services/service-storage/src/storage-routes.family-gate-credential.pin.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { promises as fs } from 'node:fs';
3838
import { join } from 'node:path';
3939
import { tmpdir } from 'node:os';
4040
import { ObjectKernel, hashApiKey } from '@objectstack/core';
41+
import { assertEngineFindOnePredicate, assertEngineUpdateDispatch } from '@objectstack/objectql';
4142
import type { IHttpRequest, IHttpResponse, RouteHandler } from '@objectstack/spec/contracts';
4243
import { LocalStorageAdapter } from './local-storage-adapter.js';
4344
import { mountStorageRoutes } from './mount-storage-routes.js';
@@ -115,10 +116,14 @@ function services(sessionReads: { n: number }) {
115116
return typeof q?.limit === 'number' ? rows.slice(0, q.limit) : rows;
116117
},
117118
async findOne(object: string, q: any = {}) {
119+
assertEngineFindOnePredicate(object, q);
118120
return (tables[object] ?? []).find((row) => matches(row, q?.where)) ?? null;
119121
},
120122
async insert(_object: string, row: any) { return row; },
121-
async update(_object: string, row: any) { return row; },
123+
async update(_object: string, patch: any, q: any = {}) {
124+
assertEngineUpdateDispatch(patch, q);
125+
return patch;
126+
},
122127
};
123128
const sessions: Record<string, Gate | undefined> = { [HELD_USER]: PASSWORD_EXPIRED, [OK_USER]: undefined };
124129
return {

‎scripts/engine-double-contract.pinned.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4591,6 +4591,16 @@
45914591
"verb": "update",
45924592
"pinned": 1
45934593
},
4594+
{
4595+
"file": "packages/services/service-storage/src/storage-routes.family-gate-credential.pin.test.ts",
4596+
"verb": "findOne",
4597+
"pinned": 1
4598+
},
4599+
{
4600+
"file": "packages/services/service-storage/src/storage-routes.family-gate-credential.pin.test.ts",
4601+
"verb": "update",
4602+
"pinned": 1
4603+
},
45944604
{
45954605
"file": "packages/services/service-storage/src/storage-routes.metadata-outage.test.ts",
45964606
"verb": "delete",

0 commit comments

Comments
 (0)