@happyvertical/smrt-users 0.69.0 → 0.70.0
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.
- package/README.md +7 -0
- package/agents/oauth-authorization.md +13 -3
- package/agents/permissions.md +10 -0
- package/dist/chunks/{TerminalAuthService-Bf90h-rh.js → TerminalAuthService-BCem_pDy.js} +46 -29
- package/dist/chunks/TerminalAuthService-BCem_pDy.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -8
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/postgres-settings.d.ts +26 -0
- package/dist/postgres-settings.d.ts.map +1 -0
- package/dist/postgres-settings.js +18 -0
- package/dist/postgres-settings.js.map +1 -0
- package/dist/services/OAuthAuthorizationService.d.ts +27 -1
- package/dist/services/OAuthAuthorizationService.d.ts.map +1 -1
- package/dist/services/OperationPermissionService.d.ts +7 -2
- package/dist/services/OperationPermissionService.d.ts.map +1 -1
- package/dist/services/SessionPermissionContext.d.ts +2 -8
- package/dist/services/SessionPermissionContext.d.ts.map +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +8 -7
- package/dist/smrt-knowledge.okf.md +3 -2
- package/dist/sveltekit/oauth-handlers.d.ts +1 -1
- package/dist/sveltekit/oauth-handlers.d.ts.map +1 -1
- package/dist/sveltekit.js +9 -3
- package/dist/sveltekit.js.map +1 -1
- package/package.json +13 -9
- package/dist/chunks/TerminalAuthService-Bf90h-rh.js.map +0 -1
package/README.md
CHANGED
|
@@ -1995,6 +1995,13 @@ const context = await authorization.validateAccessTokenClaims(payload);
|
|
|
1995
1995
|
if (!context) throw new Error('Authorization is no longer active.');
|
|
1996
1996
|
```
|
|
1997
1997
|
|
|
1998
|
+
Consent grants the requested scopes the user holds (requested ∩ held), refuses
|
|
1999
|
+
with `access_denied` when none remain, and the stored grant, tokens and token
|
|
2000
|
+
response `scope` carry only that subset; refresh never widens it. Pass
|
|
2001
|
+
`refuseUnheldScopes: true` to `SmrtOAuthAuthorizationService.create` for
|
|
2002
|
+
all-or-nothing consent. An authorization request with no `scope` is now refused
|
|
2003
|
+
with `access_denied`. `consentScopes(request, sessionId)` previews the set.
|
|
2004
|
+
|
|
1998
2005
|
The SvelteKit export `createOAuthHandlers` supplies optional session-aware
|
|
1999
2006
|
consent and account-grant routes. `listGrants(sessionId)` and
|
|
2000
2007
|
`revokeGrant(sessionId, grantId)` confine account management to the signed-in
|
|
@@ -8,11 +8,20 @@ connection; public catalog roles must not read them.
|
|
|
8
8
|
|
|
9
9
|
`SmrtOAuthAuthorizationService.create({ db, scopePermissions })` supplies the
|
|
10
10
|
session boundary. `approve(server, parsedRequest, sessionId)` loads the existing
|
|
11
|
-
session again, checks its active user and tenant membership,
|
|
12
|
-
|
|
11
|
+
session again, checks its active user and tenant membership, and records
|
|
12
|
+
consent for the requested scopes whose configured permissions the session holds
|
|
13
|
+
(requested ∩ held, #5110). The stored grant, the SDK code, the token response
|
|
14
|
+
`scope` (RFC 6749 section 3.3) and both tokens carry only that subset, passed by
|
|
15
|
+
approving `{ ...request, scopes: granted }`; the SDK refresh path refuses any
|
|
16
|
+
scope beyond the grant (`invalid_scope`); a role that lost a mapped permission
|
|
17
|
+
gets the whole refresh refused (no partial clamp), so refresh never widens. A
|
|
18
|
+
request with no `scope` parameter now yields `access_denied` (it used to store
|
|
19
|
+
an empty grant). No held scope: `access_denied`. `refuseUnheldScopes: true`
|
|
20
|
+
restores all-or-nothing consent. `consentScopes()` and the `authorize` handler
|
|
21
|
+
report the narrowed `scopes` (and `requestedScopes` when different). Existing magic-link,
|
|
13
22
|
password and OIDC sessions work without a separate identity mapping. Parent
|
|
14
23
|
session validity and session permission ceilings are enforced by SessionService.
|
|
15
|
-
|
|
24
|
+
Unmapped scopes are never granted. An empty permission mapping explicitly permits a
|
|
16
25
|
scope for any valid session. OAuth does not grant super-admin bypass.
|
|
17
26
|
|
|
18
27
|
Pass `service.identity` to the SDK server. It revalidates the stored consent on
|
|
@@ -122,6 +131,7 @@ pnpm --filter @happyvertical/smrt-users typecheck
|
|
|
122
131
|
| Consent/grant ownership | Own grant can list/revoke | Other subject, tenant, scope deny; no session bearer in projection | Owner A/B × grant A/B | Live session + consent reads; atomic cascade | Integration |
|
|
123
132
|
| Live identity and ceiling | Current permission allows | Inactive user/membership, changed session ceiling, destroyed session | Active vs revoked context | SessionService and current RBAC | Integration |
|
|
124
133
|
| Code/live revoke cascade | Valid code exchanges | Membership loss before exchange; refresh revoke kills access | Original subject/tenant | SDK revalidateConsent callback | Integration |
|
|
134
|
+
| Scope narrowing (#5110) | Held subset in grant, token `scope`, consent data; full holder gets all; strict option refuses | Nothing held `access_denied`; refresh expansion `invalid_scope`; revoked grant | Role holding fewer permissions than requested | SDK `approve` with narrowed request | Integration |
|
|
125
135
|
| Consent snapshot / tenant | Original mapped scope | Later permission mapping expansion; inactive tenant | Owner × current tenant | Stored upper bound plus live permission checks | Integration |
|
|
126
136
|
| Layered session / expiry | Parent and child valid | Parent destroyed or child expired | Person session on device parent | Existing session controls | Integration |
|
|
127
137
|
| Consent route | Same-origin explicit approval | Missing/foreign Origin, denial, revoked session | Browser session / untrusted POST | Fetch request and SDK parsing | Route + DB |
|
package/agents/permissions.md
CHANGED
|
@@ -127,6 +127,16 @@ through REST, MCP, CLI's create handler and assistant manifest dispatch on SQLit
|
|
|
127
127
|
Use onDeny: 'return', checkOperationPermission or hasOperationPermission only
|
|
128
128
|
when the caller handles a structured/boolean denial.
|
|
129
129
|
|
|
130
|
+
Inside a runtime REST request acting for a host-resolved principal
|
|
131
|
+
(`getRequestPrincipal()` from core, #5195), `checkOperationPermission` and
|
|
132
|
+
its siblings are capped by that principal: a slug it lacks is denied
|
|
133
|
+
whichever branch would grant it (system context, super-admin bypass, live
|
|
134
|
+
role, explicit `permissionSet`). For the principal's own user and tenant its
|
|
135
|
+
permissions stand in for resolution (an explicit set is intersected); for
|
|
136
|
+
another subject a transaction-scoped request denies with `subject_mismatch`
|
|
137
|
+
and any other request resolves that subject live, still capped. Outside such
|
|
138
|
+
a request the gate is unchanged. Test: `src/__tests__/rest-request-scope.test.ts`.
|
|
139
|
+
|
|
130
140
|
Generated SvelteKit write routes (POST/PUT/PATCH/DELETE CRUD and mutating
|
|
131
141
|
custom actions) enforce the same `collection.action` slug (custom actions use
|
|
132
142
|
`collection.<method>`; actions hosted on a collection class use the item collection, which the catalog now emits) after authentication: the slug must be in the request's
|