@stacksjs/defaults 0.75.602 → 0.75.604
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.
|
@@ -129,12 +129,47 @@ Three things to get right, each of which is silent when wrong:
|
|
|
129
129
|
- **A token cannot grant more than it holds.** `CreateTokenAction` refuses a
|
|
130
130
|
caller's token that asks for scopes it lacks (`scopesBeyond`). An override
|
|
131
131
|
must keep that, and should not default missing scopes to `*`.
|
|
132
|
-
- **
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
- **Pick the owner by who the credential acts for.** A token a person holds
|
|
133
|
+
to act as themselves (a CLI login, an "API token" on their account) is owned
|
|
134
|
+
by the user, and a password change rightly ends it: `findToken` refuses any
|
|
135
|
+
user token issued before the owner's last password change. A credential
|
|
136
|
+
that acts for a THING and sits unattended in another system (a project's
|
|
137
|
+
read key in a dashboard's server, an upload token in a CI secret) must not
|
|
138
|
+
be user-owned, or it stops the day its creator changes their password or
|
|
139
|
+
leaves. Give it a non-user owner:
|
|
136
140
|
|
|
137
|
-
|
|
141
|
+
```ts
|
|
142
|
+
// The owner is any table with a numeric id. `tokenable_id` is an integer, so
|
|
143
|
+
// when the thing itself has a string id, add a one-to-one model with an
|
|
144
|
+
// integer id (a "principal") and let that row own the tokens.
|
|
145
|
+
const { plainTextToken } = await createToken(principal.id, 'Read key', ['project:read'], {
|
|
146
|
+
tokenableType: 'project_principals',
|
|
147
|
+
expiresAt,
|
|
148
|
+
withRefreshToken: false,
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
const live = await findToken(presented)
|
|
152
|
+
const isProjectKey = live?.subjectType === 'project_principals' && live.scopes.includes('project:read')
|
|
153
|
+
const mine = await tokens(principal.id, 'project_principals')
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The framework resolves only `users` tokens to a user, so a token with
|
|
157
|
+
another owner can never pass `Auth.getUserFromToken` or the `auth`
|
|
158
|
+
middleware: it is nobody's session, with no sweep needed. Revoke its tokens
|
|
159
|
+
when the thing is deleted (`revokeTokenById` for each of `tokens(id, type)`),
|
|
160
|
+
since nothing cascades from your table into the token table. A non-user
|
|
161
|
+
token is not stamped as used: `updatedAt` moves only when a user token is
|
|
162
|
+
resolved, so do not show a "last used" for one.
|
|
163
|
+
|
|
164
|
+
- **Migrating an existing plain-text key.** The stored value is the SHA-256 of
|
|
165
|
+
the bearer (hex). Writing that digest as a token row makes the same key a
|
|
166
|
+
live framework token, so whatever holds it keeps working with nothing
|
|
167
|
+
reissued. Postgres can do it in the migration
|
|
168
|
+
(`encode(sha256(convert_to(old_key, 'UTF8')), 'hex')`), SQLite cannot and
|
|
169
|
+
needs a one-off script before the column is dropped. Stamps are written as
|
|
170
|
+
`sqlDateTime` writes them: the ISO form without its trailing `Z`.
|
|
171
|
+
|
|
172
|
+
A password change revokes the account's own tokens, API tokens included.
|
|
138
173
|
- `Auth.once(credentials: AuthCredentials): Promise<boolean>` - one-time auth without token
|
|
139
174
|
- `Auth.requestUserTokenWithClient(credentials, clientId, clientSecret): Promise<{ token } | null>` authenticates both a legacy OAuth client and an end user password, then issues a user token. It is not the client credentials grant.
|
|
140
175
|
- `Auth.requestToken(...)` is the deprecated compatibility alias for that same legacy exchange. New delegated integrations use the authorization-code provider.
|
|
@@ -257,9 +257,12 @@ await request.authorize('update', post) // throws a 403
|
|
|
257
257
|
key, deploy token, agent token) is a personal access token with named
|
|
258
258
|
scopes: `createToken(id, name, ['posts:read'], { expiresAt, withRefreshToken: false })`,
|
|
259
259
|
listed with `tokens`, checked with `findToken`, ended with `revokeTokenById`.
|
|
260
|
-
Never add a key column or generate and compare a secret yourself.
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
Never add a key column or generate and compare a secret yourself. A
|
|
261
|
+
credential that acts for a thing rather than a person (a project's read
|
|
262
|
+
key, a CI upload token) is owned by that thing via `tokenableType`, not by
|
|
263
|
+
a user, so a password change does not end it. Once a user token narrower
|
|
264
|
+
than `*` exists, "signed in" has to mean a token holding `*`. See "API keys
|
|
265
|
+
and machine credentials" in `stacks-auth`.
|
|
263
266
|
- **Gotcha:** an ability with no gate and no policy method is denied. Don't
|
|
264
267
|
loosen the default row-scoping policy to make an example work. Declare an
|
|
265
268
|
owner instead (see RECIPES.md).
|
package/ide/vscode/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"publisher": "Stacks",
|
|
3
3
|
"name": "vscode-stacks",
|
|
4
4
|
"displayName": "Stacks",
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.604",
|
|
6
6
|
"description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/defaults",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.604",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@iconify-json/f7": "^1.2.2",
|
|
47
47
|
"@iconify-json/hugeicons": "^1.2.35",
|
|
48
|
-
"@stacksjs/mobile": "0.75.
|
|
48
|
+
"@stacksjs/mobile": "0.75.604",
|
|
49
49
|
"@stacksjs/sanitizer": "^0.2.889",
|
|
50
50
|
"@stacksjs/stx": "^0.2.889",
|
|
51
|
-
"@stacksjs/strings": "0.75.
|
|
51
|
+
"@stacksjs/strings": "0.75.604",
|
|
52
52
|
"@xterm/addon-fit": "^0.11.0",
|
|
53
53
|
"@xterm/xterm": "^6.0.0",
|
|
54
54
|
"ts-qr-codes": "^0.1.8",
|
|
55
|
-
"@stacksjs/support": "0.75.
|
|
56
|
-
"@stacksjs/browser": "0.75.
|
|
55
|
+
"@stacksjs/support": "0.75.604",
|
|
56
|
+
"@stacksjs/browser": "0.75.604"
|
|
57
57
|
}
|
|
58
58
|
}
|