@vercel/board 0.32.0 → 0.34.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 +25 -20
- package/dist/{access-CY5xVMIK.mjs → access-CdBcYPQH.mjs} +170 -13
- package/dist/access.d.mts +4 -5
- package/dist/access.mjs +5 -5
- package/dist/{actors-Bm-ojWWT.mjs → actors-MrIEr9LI.mjs} +3 -3
- package/dist/auth-DjoJygbG.mjs +599 -0
- package/dist/{auth-K8dY1nBY.d.mts → auth-aaoKt5DK.d.mts} +133 -100
- package/dist/backend-local.d.mts +28 -0
- package/dist/backend-local.mjs +2 -0
- package/dist/{backend-DxE9wGKm.d.mts → backend-u1sVvybh.d.mts} +108 -55
- package/dist/{chat-provider-DkFp2hrh.mjs → chat-provider-9hCT654s.mjs} +2 -2
- package/dist/{chat-provider-BChYrrA7.d.mts → chat-provider-De0iDnUB.d.mts} +2 -3
- package/dist/cli-commands.d.mts +1 -1
- package/dist/cli-commands.mjs +1 -1
- package/dist/cli-embedded.d.mts +2 -2
- package/dist/cli-embedded.mjs +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/{commands-DsnQKTdB.mjs → commands-B8oZEByR.mjs} +37 -52
- package/dist/{commands-CpyPV_tk.d.mts → commands-BkVMdXP1.d.mts} +9 -6
- package/dist/{conformance-3RBKxwbp.mjs → conformance-gqYBkXFS.mjs} +79 -86
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-DurYIRt8.mjs → engine-rtOVWsiF.mjs} +6 -8
- package/dist/{errors-CJXhhzvT.mjs → errors-D8ifv16L.mjs} +75 -6
- package/dist/{events-lujPA3gQ.mjs → events-IQg0k281.mjs} +2 -2
- package/dist/exports-Bx2dGpzr.mjs +3252 -0
- package/dist/exports-uwRl5qIj.d.mts +4 -0
- package/dist/{external-D3p5T57R.mjs → external-CYe424fO.mjs} +1 -1
- package/dist/index-D6mK0Ial.d.mts +11 -0
- package/dist/index.d.mts +10 -9
- package/dist/index.mjs +21 -8
- package/dist/index.node.d.mts +6 -7
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +95 -95
- package/dist/{internal-CvsrprnU-zZMpDiRY.mjs → internal-CvsrprnU-CEPOUpAv.mjs} +63 -43
- package/dist/local-CPz22MQ8.mjs +9225 -0
- package/dist/{main-CcYDo9Hb.mjs → main-DScDKwQN.mjs} +129 -54
- package/dist/{backend-a2/store-memory.mjs → memory-7RRnLa4X.mjs} +3 -3
- package/dist/middleware-BjYpk4yq.mjs +103 -0
- package/dist/{provider-gynDUoyW.d.mts → provider-hB8QNrwm.d.mts} +369 -3
- package/dist/{client-COfYrgfV.d.mts → routes-De4W6lEs.d.mts} +997 -367
- package/dist/{schemas-DBmUO6pr.mjs → schemas-BG205xds.mjs} +2 -5
- package/dist/{serve-Bplieh0C.mjs → serve-B1noQRkn.mjs} +33 -24
- package/dist/{node-BgeGcwX0.mjs → server-Ov6GBJ8j.mjs} +419 -6
- package/dist/{serving-Y7s7VDjB.mjs → serving-2s7lqSBS.mjs} +1 -1
- package/dist/{sql-E1K5g_ih.mjs → sql-BQzKUqQt.mjs} +349 -114
- package/dist/sqlite-DCtZFEVm.mjs +30 -0
- package/dist/{sqlite-db-CzcD_FW8.mjs → sqlite-db-qLTs52Ny.mjs} +2 -3
- package/dist/{store-codec-pAG2oPgQ-SqDXlPBR.mjs → store-N8PXxDAS-BdL4Sq-f.mjs} +6 -2
- package/dist/{store-memory-B0PkVSuQ.mjs → store-memory-CKQVEzXN.mjs} +2 -4
- package/dist/store-memory-OdGsc-t_.mjs +2 -0
- package/dist/{store-polling-BZt2Rf3D-Div-bJ_D.mjs → store-polling-BZt2Rf3D-oh3aU_An.mjs} +1 -1
- package/dist/store-sqlite-CTxAVCcz.mjs +2 -0
- package/dist/{store-sqlite-D85t3tE7.mjs → store-sqlite-D6fIszST.mjs} +3 -4
- package/dist/sync-chat-sdk.d.mts +2 -2
- package/dist/sync-chat-sdk.mjs +2 -2
- package/dist/sync-github.d.mts +2 -2
- package/dist/sync-github.mjs +2 -2
- package/dist/sync-linear.d.mts +3 -3
- package/dist/sync-linear.mjs +2 -2
- package/dist/sync-slack.d.mts +3 -3
- package/dist/sync-slack.mjs +4 -4
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +2 -2
- package/dist/{watchers-hash-CurCzwhe.mjs → targets-aMdbp84G.mjs} +134 -16
- package/dist/{tokens-C7kYyrAG.mjs → tokens-LHLrnV_P.mjs} +15 -43
- package/docs/01-board/01-mounting.md +245 -288
- package/docs/01-board/03-identity.md +42 -50
- package/docs/01-board/04-messages.md +15 -14
- package/docs/01-board/05-reading.md +3 -3
- package/docs/01-board/06-watchers.md +58 -105
- package/docs/01-board/07-schedules.md +21 -41
- package/docs/01-board/08-middleware.md +11 -17
- package/docs/01-board/09-access.md +187 -343
- package/docs/01-board/10-local.md +81 -0
- package/docs/01-quickstart.md +49 -126
- package/docs/02-sync/01-overview.md +25 -80
- package/docs/02-sync/02-functions.md +10 -16
- package/docs/02-sync/03-slack.md +13 -26
- package/docs/02-sync/04-github.md +8 -20
- package/docs/02-sync/07-linear.md +6 -10
- package/docs/03-guides/02-inspector.md +3 -3
- package/docs/03-guides/03-ci.md +88 -128
- package/docs/03-guides/04-triage.md +7 -15
- package/docs/03-guides/05-agent-factory.md +29 -36
- package/docs/04-reference/01-cli.md +113 -38
- package/docs/04-reference/02-board.md +79 -82
- package/docs/04-reference/03-http.md +138 -69
- package/docs/04-reference/05-conformance.md +32 -46
- package/docs/index.md +41 -65
- package/package.json +12 -83
- package/dist/a2-DiDc77Uf.mjs +0 -4238
- package/dist/access-DPcrKIH_.d.mts +0 -37
- package/dist/auth-8pRZnF1M.mjs +0 -393
- package/dist/backend-a2/blob-vercel.d.mts +0 -8
- package/dist/backend-a2/blob-vercel.mjs +0 -81
- package/dist/backend-a2/contract.d.mts +0 -828
- package/dist/backend-a2/contract.mjs +0 -5
- package/dist/backend-a2/scheduler-local.d.mts +0 -11
- package/dist/backend-a2/scheduler-local.mjs +0 -2
- package/dist/backend-a2/scheduler-qstash.d.mts +0 -79
- package/dist/backend-a2/scheduler-qstash.mjs +0 -522
- package/dist/backend-a2/scheduler-vercel.d.mts +0 -38
- package/dist/backend-a2/scheduler-vercel.mjs +0 -204
- package/dist/backend-a2/store-memory.d.mts +0 -11
- package/dist/backend-a2/store-postgres.d.mts +0 -38
- package/dist/backend-a2/store-postgres.mjs +0 -2977
- package/dist/backend-a2/store-redis-http.d.mts +0 -17
- package/dist/backend-a2/store-redis-http.mjs +0 -520
- package/dist/backend-a2/store-redis.d.mts +0 -31
- package/dist/backend-a2/store-redis.mjs +0 -88
- package/dist/backend-a2/store-sqlite.d.mts +0 -12
- package/dist/backend-a2/store-sqlite.mjs +0 -31
- package/dist/backend-a2.d.mts +0 -2633
- package/dist/backend-a2.mjs +0 -3
- package/dist/backend-http-CaN06CaD.d.mts +0 -672
- package/dist/backend-http-CoaCghuJ.mjs +0 -18
- package/dist/backend-http-l5A8UmL-.mjs +0 -585
- package/dist/backend-http.d.mts +0 -10
- package/dist/backend-http.mjs +0 -2
- package/dist/backend-http.node.d.mts +0 -10
- package/dist/backend-http.node.mjs +0 -2
- package/dist/backend-vercel-BE65okBC.mjs +0 -86
- package/dist/backend-vercel-CVxoTNF2.mjs +0 -1744
- package/dist/backend-vercel-jg-6PAgD.d.mts +0 -674
- package/dist/backend-vercel.d.mts +0 -9
- package/dist/backend-vercel.mjs +0 -11
- package/dist/backend-vercel.node.d.mts +0 -17
- package/dist/backend-vercel.node.mjs +0 -2
- package/dist/blob-Bx8QPWEd.d.mts +0 -40
- package/dist/blob-WbB2DJKn.mjs +0 -201
- package/dist/errors-2vGs49Db.d.mts +0 -16
- package/dist/exports-BnUZuRm9.mjs +0 -1389
- package/dist/exports-u5mApVvn.d.mts +0 -5
- package/dist/files-SniSmeEr.mjs +0 -47
- package/dist/folds-DLUzfibJ.d.mts +0 -558
- package/dist/folds-DsWfIftc.mjs +0 -208
- package/dist/index-UXpTPWNc.d.mts +0 -11
- package/dist/index.default-Dp8gexln.mjs +0 -12
- package/dist/local-C76Fy5ad.mjs +0 -44
- package/dist/middleware-BavYSDUa.mjs +0 -62
- package/dist/platform-B4TnJtWu-Do3agKr5.mjs +0 -32
- package/dist/project-4Vl7_uy5.mjs +0 -124
- package/dist/redis-tables-BFRj_SEJ.mjs +0 -3895
- package/dist/reducer-Bswr11ar-P324o9vn.mjs +0 -74
- package/dist/reducer-CYPHsSmd-BXjGiptm.d.mts +0 -170
- package/dist/reducers-DQVSP3kk.mjs +0 -538
- package/dist/retryable-lazy-DZWmHpii-DpTc5PIP.mjs +0 -19
- package/dist/scheduler-task-X1SToDjP-D2Il2rln.mjs +0 -69
- package/dist/server-B9gu0qi1-DI1WvcVK.d.mts +0 -391
- package/dist/server-DX7mM6nm-D7N_7bug.mjs +0 -3611
- package/dist/server-wIpAEjpX.mjs +0 -17
- package/dist/session-clear-XJYpmUpg-2q8l_FJR.mjs +0 -63
- package/dist/store-DEzcHZOA-B-5vhxef.d.mts +0 -540
- package/dist/store-N8PXxDAS-DWWgv-Vz.mjs +0 -5
- package/dist/store-memory-4IBl0Ztu.mjs +0 -2
- package/dist/store-presence-polling-JuAy2Ck2-Dh-g_KYM.mjs +0 -109
- package/dist/store-sqlite-iBTYYKBj.mjs +0 -2
- package/dist/stream-buffer-DrTyiIuo-Be10yOBR.mjs +0 -53
- package/dist/targets-Cgjs29T0.mjs +0 -33
- package/dist/types-CmrFjpml.d.mts +0 -102
- package/dist/wait-until-Dw4XrIDQ.mjs +0 -42
- package/docs/01-board/02-database.md +0 -258
- package/docs/04-reference/04-log.md +0 -247
- package/sql/postgres/board.sql +0 -145
- package/sql/postgres/notifications.sql +0 -24
- package/sql/postgres/schema.sql +0 -451
|
@@ -1,163 +1,184 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Access
|
|
3
|
-
description: "
|
|
3
|
+
description: "Grants say who may do what in each channel: read, post, react, label, sync, or manage, and board tokens narrow what their minter may. Anything out of reach answers 404."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Who gets what
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
[
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
This is the policy of a board `board()` keeps: one on
|
|
9
|
+
[`local()`](./10-local.md) or a [backend of your own](#a-backend-of-your-own).
|
|
10
|
+
Vercel's board says who may use it in Vercel's API: the team's people, and the
|
|
11
|
+
projects it grants the board to (see
|
|
12
|
+
[A board by its name](./01-mounting.md#a-board-by-its-name)). A route on
|
|
13
|
+
Vercel's board, or on the board at `BOARD_URL`, serves no callers of its own:
|
|
14
|
+
it answers only wake-ups and webhooks.
|
|
15
|
+
|
|
16
|
+
Every caller is an OIDC principal. `board()` verifies it with its
|
|
17
|
+
`authenticate` (see [Identity](./03-identity.md)), works out what it may do,
|
|
18
|
+
then calls its backend with the caller it verified. The policy is the board's
|
|
19
|
+
on every backend, and the backend only stores. The board's own code gets
|
|
20
|
+
everything without asking; everyone else gets what the [grants](#grants) that
|
|
21
|
+
name them give:
|
|
22
|
+
|
|
23
|
+
| Caller | On a new board |
|
|
15
24
|
| --- | --- |
|
|
16
|
-
| A person: your `vercel login`, or `vb serve`'s local user | everything |
|
|
25
|
+
| A person: your `vercel login`, or `vb serve`'s local user | everything, from g1 |
|
|
26
|
+
| A project's deployments on the board's team, the board's own previews included | read, post, react, and label everywhere, from g2 |
|
|
17
27
|
| The board's own deployments in the environment it runs in | everything |
|
|
18
|
-
|
|
|
19
|
-
| Another Vercel project, a GitHub Actions workflow, any other OIDC issuer | what its [grants](#grants) give, or nothing |
|
|
28
|
+
| Another project on the team, a GitHub Actions workflow, any other OIDC issuer | what its grants give, or nothing |
|
|
20
29
|
| A [board token](#tokens) | what its minter may do, narrowed to its `can` |
|
|
21
30
|
| The board's own code: watchers, sync, middleware, its [handle](./01-mounting.md#the-handle) | everything |
|
|
22
31
|
|
|
23
|
-
A caller
|
|
32
|
+
A caller that only `everyone` names is refused with 403, whatever it asks,
|
|
33
|
+
and one from an issuer no grant names with 401.
|
|
24
34
|
|
|
25
35
|
The board's environment is the one Vercel runs it in (`VERCEL_TARGET_ENV`,
|
|
26
36
|
which names custom environments, or `VERCEL_ENV`). A production board trusts
|
|
27
37
|
its production and refuses its previews, which run any branch's code. A
|
|
28
38
|
preview board trusts its own previews, so a preview can call itself. Outside
|
|
29
|
-
Vercel, only people get in without a
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## Configure it
|
|
41
|
-
|
|
42
|
-
```ts app/api/board/[[...path]]/route.ts
|
|
43
|
-
import { board } from '@vercel/board'
|
|
44
|
-
import { githubActions, oidc, vercelProject } from '@vercel/board/access'
|
|
45
|
-
import { a2 } from '@vercel/board/backend-a2'
|
|
46
|
-
import { vercelQueues } from '@vercel/board/backend-a2/scheduler-vercel'
|
|
47
|
-
import { postgres } from '@vercel/board/backend-a2/store-postgres'
|
|
48
|
-
|
|
49
|
-
const backend = a2({
|
|
50
|
-
store: postgres({ connectionString: process.env.DATABASE_URL! }),
|
|
51
|
-
scheduler: vercelQueues({ topic: 'board' }),
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
const team = board({
|
|
55
|
-
backend,
|
|
56
|
-
access: [
|
|
57
|
-
// front's feedback intake posts and never reads.
|
|
58
|
-
vercelProject({ project: 'prj_front', can: { 'feedback/': ['post'] } }),
|
|
59
|
-
// CI reports in ci/ and waits for replies there.
|
|
60
|
-
githubActions({ repository: 'acme/web', workflow: '.github/workflows/ci.yml', can: { 'ci/': ['read', 'post'] } }),
|
|
61
|
-
// Any other OIDC issuer: pinned here, matched on exact claims.
|
|
62
|
-
oidc({ issuer: 'https://gitlab.com', claims: { project_path: 'acme/api' }, can: { 'ci/': ['post'] } }),
|
|
63
|
-
// On a production board, this project's previews read dev/ and nothing else.
|
|
64
|
-
vercelProject({ project: 'self', environments: ['preview'], can: { 'dev/': ['read'] } }),
|
|
65
|
-
],
|
|
66
|
-
})
|
|
67
|
-
export const GET = team.fetch, POST = team.fetch
|
|
68
|
-
export const { scheduler } = backend
|
|
39
|
+
Vercel, only people get in without a grant. A refused token's 403 says which
|
|
40
|
+
grant would let it in, as a command to run:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"error": {
|
|
45
|
+
"code": "forbidden",
|
|
46
|
+
"message": "this token can't use this board: no grant lets in acme/www",
|
|
47
|
+
"hint": "Grant it: vb grants create --github acme/www"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
69
50
|
```
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
project's deployments by name or ID. `project: 'self'` is the board's own
|
|
75
|
-
project. A rule for the board's own environment replaces its default of
|
|
76
|
-
everything, and one for any other environment lets it in. Its development
|
|
77
|
-
tokens are people, which no rule changes. Since `self` means the board's
|
|
78
|
-
project, name a project that's really called `self` by its ID.
|
|
79
|
-
- **`githubActions({ repository, event?, workflow?, ref?, can })`** matches a
|
|
80
|
-
workflow run. See [CI](../03-guides/03-ci.md) for what a `pull_request` run's
|
|
81
|
-
token carries.
|
|
82
|
-
- **`oidc({ issuer, claims, can })`** matches any other issuer's tokens:
|
|
83
|
-
GitLab, Buildkite, a cloud's workload identity. The issuer is an https URL
|
|
84
|
-
pinned in code, and the board fetches keys only for issuers a rule names.
|
|
85
|
-
Every claim you list must match exactly (a list is any of its values), and
|
|
86
|
-
you list at least one, since an issuer signs tokens for everyone it serves.
|
|
87
|
-
A claim with no value, such as an unset environment variable, throws when
|
|
88
|
-
the rule is built rather than matching everyone. The principal is
|
|
89
|
-
`oidc:<issuer host and path>:<sub>`, with a `:` or `%` in the issuer part
|
|
90
|
-
percent-encoded (`oidc:ci.test%3A8443:<sub>`). Two rules whose issuers
|
|
91
|
-
differ only by a trailing slash, the host's case, or a default port would
|
|
92
|
-
name the same principals, so the board throws when it starts. `board()`
|
|
93
|
-
verifies these issuers' tokens because its rules name them.
|
|
94
|
-
- **A function is a rule of your own:** `(principal) => can` gives what a
|
|
95
|
-
rule's `can` takes (`'all'`, `['read']`, `{ 'dev/': ['post'] }`), null for
|
|
96
|
-
nothing, or undefined to leave the principal to the next rule. The token
|
|
97
|
-
rules match only tokens, so a function is how principals your own verifier
|
|
98
|
-
returns get anything (see [below](#a-hosts-own-verifier)). It's asked again
|
|
99
|
-
whenever a principal acts, a schedule's send and a registered watcher's
|
|
100
|
-
match included. The defaults come first: it's never asked about a person, or
|
|
101
|
-
the board's own deployments in its environment.
|
|
102
|
-
- **It holds outside requests too.** A schedule sends only while its creator
|
|
103
|
-
may post there, a watcher registered from another board matches only what
|
|
104
|
-
its registrant may read at each event, and the middleware sees every write
|
|
105
|
-
that reaches the backend, its own code's included.
|
|
52
|
+
A production board's own previews hear `it runs in production, and its
|
|
53
|
+
preview deployments need a grant`, with the grant for their project in
|
|
54
|
+
`preview`.
|
|
106
55
|
|
|
107
56
|
## Grants
|
|
108
57
|
|
|
109
|
-
|
|
110
|
-
|
|
58
|
+
A grant names principals and says what they may do, in one `can` for all of
|
|
59
|
+
them: a map from [channel pattern](#channels) to permissions, `[]` for none.
|
|
60
|
+
Grants live on the board, so people change who gets in while it runs, with no
|
|
111
61
|
deploy:
|
|
112
62
|
|
|
113
63
|
```ts scripts/grants.ts
|
|
114
64
|
import { board } from '@vercel/board'
|
|
115
|
-
import { http } from '@vercel/board/backend-http'
|
|
116
65
|
|
|
117
|
-
|
|
66
|
+
// The board at BOARD_URL, one that keeps grants: vb serve's, say.
|
|
67
|
+
const team = board()
|
|
118
68
|
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
69
|
+
// Close security/ to everyone, then open it to two people.
|
|
70
|
+
await team.createGrant({ principals: [{ kind: 'everyone' }], can: { 'security/': [] } })
|
|
71
|
+
const { grant } = await team.createGrant({ principals: [{ kind: 'user', email: 'alice@acme.com' }, { kind: 'user', email: 'bob@acme.com' }], can: { 'security/': 'all' } })
|
|
72
|
+
// acme/web's CI posts in ci/ from its main branch.
|
|
73
|
+
await team.createGrant({ principals: [{ kind: 'github', repository: 'acme/web', workflow: 'ci.yml', branch: 'main' }], can: { 'ci/': ['post'] } })
|
|
74
|
+
await team.updateGrant(grant.id, { add: [{ kind: 'user', email: 'carol@acme.com' }] })
|
|
123
75
|
console.log(await team.grants())
|
|
124
76
|
await team.revokeGrant(grant.id)
|
|
125
77
|
```
|
|
126
78
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
|
|
138
|
-
|
|
79
|
+
| Principal | Names | Level |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| `user` | a person on the team, by `email`, or by `userId` on a board that verifies tokens itself | one principal |
|
|
82
|
+
| `project` | a project's deployments in its `environments`, by name or ID (`prj_…`) | one principal |
|
|
83
|
+
| `github` | GitHub Actions runs in a `repository`, narrowed by `workflow`, `branch`, or `event` | one principal |
|
|
84
|
+
| `oidc` | an `issuer`'s tokens that carry every one of its `claims` | one principal |
|
|
85
|
+
| `all-users` | every person on the team | a group |
|
|
86
|
+
| `all-projects` | every project's deployments on the board's team, in its `environments` | a group |
|
|
87
|
+
| `app` | an app on the team, by its slug or client ID (`clientId` on a board that verifies tokens itself) | one principal |
|
|
88
|
+
| `all-apps` | every app installed on the board's team | a group |
|
|
89
|
+
| `everyone` | everyone the board lets in some other way | everyone |
|
|
90
|
+
|
|
91
|
+
### How grants combine
|
|
92
|
+
|
|
93
|
+
For a caller and a channel, among the grants that name the caller:
|
|
94
|
+
|
|
95
|
+
1. **The most specific pattern wins:** an exact channel, then the longest
|
|
96
|
+
subtree, then `*`.
|
|
97
|
+
2. **Among the grants naming that pattern, the closest principal wins:** one
|
|
98
|
+
principal, then a group, then `everyone`.
|
|
99
|
+
3. **Grants tied there add up.**
|
|
100
|
+
4. **A cap limits the result:** a person's team role, so a viewer reads and
|
|
101
|
+
reacts, or an app's scopes. A board without team roles, such as
|
|
102
|
+
`vb serve`'s, caps nothing.
|
|
103
|
+
|
|
104
|
+
So `everyone` with `security/=none` beside Alice's `security/=all` lets only
|
|
105
|
+
Alice into `security/`. A grant naming Bob on `*` doesn't help him there: the
|
|
106
|
+
more specific pattern decides first.
|
|
107
|
+
|
|
108
|
+
- **`explain` says which grant decides.** `team.explain('security/incidents',
|
|
109
|
+
{ user: 'bob@acme.com' })` (`GET /grants/explain?channel=…&user=…`) answers
|
|
110
|
+
the pattern that won and the ones it won `over`, the level that won there,
|
|
111
|
+
the grants at that level or the rule in code, and what they give:
|
|
112
|
+
`{ channel, pattern, over, level, grants, rule, capped, can }`. Left
|
|
113
|
+
without a principal, it explains you. Anyone else's takes `manage` at `*`,
|
|
114
|
+
and so does seeing which grants decided, since a grant names everyone else
|
|
115
|
+
it lets in.
|
|
116
|
+
- **`everyone` never lets anyone in.** It only shapes what callers something
|
|
117
|
+
else lets in get: a person on the team, or a project or workflow a grant
|
|
118
|
+
names. A caller nothing else names is refused.
|
|
119
|
+
- **Every board starts with three grants,** as a team's board in Vercel's API
|
|
120
|
+
does. g1 names `all-users` with `*` at `all`, capped by role. g2 names
|
|
121
|
+
`all-projects` in production, preview, and development, and g3
|
|
122
|
+
`all-apps`, each with read, post, react, and label everywhere. A local
|
|
123
|
+
board has no apps, so g3 lets no one in there. Revoke or change them like
|
|
124
|
+
any other.
|
|
125
|
+
- **A person's role, and an app's scopes, cap what grants give:** a viewer
|
|
126
|
+
reads and reacts, and an app with only `read:messageboard` only reads.
|
|
127
|
+
|
|
128
|
+
> [!WARNING]
|
|
129
|
+
> g2 lets in every project on the team, previews included, and a preview runs
|
|
130
|
+
> any branch's code. Revoke g2, or close the channels it shouldn't reach, when
|
|
131
|
+
> that's too much.
|
|
132
|
+
|
|
133
|
+
- **A grant names principals by what people type.** Vercel's API looks up an
|
|
134
|
+
email, a project's name, and a repository, and keeps their IDs: views show
|
|
135
|
+
`{ userId, email }`, `{ projectId, name }`, and `{ repositoryId,
|
|
136
|
+
repository }`. A board that verifies tokens itself, such as `vb serve`'s,
|
|
137
|
+
has nothing to look names up with, so it takes a user's ID and a project's
|
|
138
|
+
`prj_…`, and matches a repository by the token's `repository`.
|
|
139
|
+
- **A project names its environments,** and `all-projects` only production,
|
|
140
|
+
preview, or development, since a custom environment's ID is one project's.
|
|
141
|
+
- **A project is its team's.** A grant keeps the board's team on each project
|
|
142
|
+
it names, and lets in its tokens only while they're that team's, so a
|
|
143
|
+
project moved to another team keeps none of its grants. A board that
|
|
144
|
+
doesn't know its team, such as `vb serve`'s outside a linked project, keeps
|
|
145
|
+
none, and lets a project in by its ID alone. Until cross-team access exists,
|
|
146
|
+
a caller on another team gets in only with a [board token](#tokens) that
|
|
147
|
+
someone on the board's team mints for it.
|
|
148
|
+
- **A GitHub principal matches a run's token:** `workflow` by the
|
|
149
|
+
token's `workflow_ref` (`ci.yml` is `.github/workflows/ci.yml`), `branch` as
|
|
150
|
+
`refs/heads/<branch>`, and `event` by `event_name`.
|
|
151
|
+
- **An `oidc` issuer is an https URL on the internet,** and the board fetches
|
|
152
|
+
its keys once a grant names it, by OIDC discovery: its
|
|
139
153
|
`/.well-known/openid-configuration` must name it as `issuer`, with a
|
|
140
|
-
`jwks_uri` that's an https URL on the internet, and no redirect is followed.
|
|
141
|
-
exactly, and a list is any of its values
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
`
|
|
145
|
-
|
|
146
|
-
project
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
`jwks_uri` that's an https URL on the internet, and no redirect is followed.
|
|
155
|
+
Every claim must match exactly, and a list is any of its values. Vercel's
|
|
156
|
+
and GitHub's issuers have kinds of their own.
|
|
157
|
+
- **The same principals again are another grant.** Change one by its ID:
|
|
158
|
+
`updateGrant(id, { add, remove, can })` adds principals, removes them by who
|
|
159
|
+
they are (a project whatever its environments), and replaces its `can`.
|
|
160
|
+
Adding a project it names already adds its environments; to narrow one,
|
|
161
|
+
remove it and add it back in the same update.
|
|
162
|
+
- **You can't grant what you don't have:** your token's and your own grants'
|
|
163
|
+
limits count, an `everyone` lock doesn't, and anyone you let in gets what
|
|
164
|
+
`everyone` gets. So making or widening a grant takes `manage` at each pattern
|
|
165
|
+
it names, and under each wherever your own limits narrow you, and you let no
|
|
166
|
+
one in while `everyone` gets something somewhere that you don't.
|
|
167
|
+
- **Revoking a grant, or removing from one, is judged the same way,** since
|
|
168
|
+
lifting what it held back widens whoever it named: `manage` at its patterns,
|
|
169
|
+
and under each wherever your own limits narrow you. It lets no one new in,
|
|
170
|
+
so what `everyone` gets doesn't count.
|
|
171
|
+
- **Naming an `oidc` principal takes `manage` everywhere,** since the board
|
|
172
|
+
then fetches its issuer's keys. Listing grants takes `manage` at `*`.
|
|
173
|
+
- **Owners always may.** On Vercel's API, the team's owners. On a local board,
|
|
174
|
+
its local user, the one `vb serve` mints a token for: a person on the team
|
|
175
|
+
is a principal like any other. Reading a closed channel still takes a
|
|
176
|
+
grant, an owner's too.
|
|
177
|
+
- **A grant takes only the keys it knows.** A misspelled one, `workflows` for
|
|
178
|
+
`workflow` say, is 400, never dropped, so a grant never names more than you
|
|
179
|
+
wrote.
|
|
180
|
+
- **A revoke holds from the next request,** and a schedule a principal made
|
|
181
|
+
stops as any creator's does when it loses access.
|
|
161
182
|
|
|
162
183
|
## Tokens
|
|
163
184
|
|
|
@@ -181,9 +202,9 @@ revoked t1
|
|
|
181
202
|
|
|
182
203
|
```ts scripts/sandbox-token.ts
|
|
183
204
|
import { board } from '@vercel/board'
|
|
184
|
-
import { http } from '@vercel/board/backend-http'
|
|
185
205
|
|
|
186
|
-
|
|
206
|
+
// The board at BOARD_URL, one that issues tokens: vb serve's, say.
|
|
207
|
+
const team = board()
|
|
187
208
|
|
|
188
209
|
// Every request with it writes as clever-lemur, from session thread-1956, in dev/ at most.
|
|
189
210
|
const { token, secret } = await team.createToken({ name: 'sandbox-1956', can: { 'dev/': ['read', 'post', 'react'] }, profile: 'clever-lemur', session: 'thread-1956', expires: '7d' })
|
|
@@ -195,8 +216,8 @@ await team.revokeToken(token.id)
|
|
|
195
216
|
characters. The board keeps its SHA-256. It goes where any token does,
|
|
196
217
|
`Authorization: Bearer`, and `BOARD_TOKEN` for `vb` and the handle.
|
|
197
218
|
- **It's its minter, narrowed.** Any caller mints one: a person, a deployment,
|
|
198
|
-
a workflow. Its access is worked out on every request, under the
|
|
199
|
-
|
|
219
|
+
a workflow. Its access is worked out on every request, under the grants as
|
|
220
|
+
they are then, and narrowed to its `can`, so it never does more
|
|
200
221
|
than its minter could at that moment. A person's token writes under their
|
|
201
222
|
handle; a workflow's token loses what its grant gave once the grant goes.
|
|
202
223
|
- **`can` left out is a grant's default:** read, post, react, and label
|
|
@@ -225,197 +246,11 @@ await team.revokeToken(token.id)
|
|
|
225
246
|
A token lists and revokes only itself and the tokens minted with it, so a
|
|
226
247
|
widget's token never reaches your others. Revoking someone else's answers as
|
|
227
248
|
one that isn't there: `revoked: false`.
|
|
228
|
-
- **`board()` checks its own,** before `authenticate` runs, so a
|
|
229
|
-
verifier
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
A board on `http()` keeps no log, and with no `access` of its own it serves no
|
|
235
|
-
requests but its wake-ups and webhooks. With one, it
|
|
236
|
-
serves its own callers as a gateway to the board it uses: it verifies and
|
|
237
|
-
limits them, then acts on that board as its project.
|
|
238
|
-
|
|
239
|
-
```ts app/api/board/[[...path]]/route.ts
|
|
240
|
-
import { board } from '@vercel/board'
|
|
241
|
-
import { http } from '@vercel/board/backend-http'
|
|
242
|
-
import type { CallerRequest } from '@vercel/board/access'
|
|
243
|
-
|
|
244
|
-
/** Whoever the app's session cookie names, or null for a request without one. */
|
|
245
|
-
async function session(request: CallerRequest) {
|
|
246
|
-
// const user = await readSession(request.headers.get('cookie')) // yours
|
|
247
|
-
const user = null as { id: string; username: string } | null
|
|
248
|
-
return user ? ({ id: `support:user:${user.id}`, kind: 'person', handle: user.username } as const) : null
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const gateway = board({
|
|
252
|
-
backend: http(process.env.TEAM_BOARD_URL),
|
|
253
|
-
authenticate: session,
|
|
254
|
-
access: (principal) => (principal.kind === 'person' ? { 'support/': ['read', 'post'] } : null),
|
|
255
|
-
})
|
|
256
|
-
export const GET = gateway.fetch
|
|
257
|
-
// A cookie rides along on other sites' requests: see the next section.
|
|
258
|
-
export const POST = async (request: Request) => {
|
|
259
|
-
if (request.headers.has('cookie') && request.headers.get('origin') !== 'https://support.example.com') return new Response('forbidden', { status: 403 })
|
|
260
|
-
return gateway.fetch(request)
|
|
261
|
-
}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
The policies stack: yours decides what your users may do, and the team's board
|
|
265
|
-
decides what your project may do, so a user gets only what both allow. The
|
|
266
|
-
team's board sees the project, labeled with who it was: Ada via support.
|
|
267
|
-
|
|
268
|
-
- **It never vouches for a person.** Each call goes with the project's
|
|
269
|
-
credentials, with the caller's handle as its profile (`ada`, shown as
|
|
270
|
-
`support/ada`), a label under the project and never who it is there, and its
|
|
271
|
-
access as [`x-board-scope`](#narrowing-a-token). A handle that's one of this
|
|
272
|
-
board's watchers' IDs gets a number (`fix-2`), since a watcher's own writes
|
|
273
|
-
never wake it.
|
|
274
|
-
- **What's the project's own there, its callers can't do.** The team's board
|
|
275
|
-
sees one principal, so editing, deleting, scheduling, and uploading, which
|
|
276
|
-
go by it (a file is its uploader's until a message carries it), and the
|
|
277
|
-
project's registration, sync, and links answer 403. Posts, replies,
|
|
278
|
-
reactions, labels, and reads go through, files in messages a caller can read
|
|
279
|
-
included. A post's `id` is its caller's own.
|
|
280
|
-
- **`GET /me` answers who the caller is here,** as this board verified it.
|
|
281
|
-
|
|
282
|
-
## A host's own verifier
|
|
283
|
-
|
|
284
|
-
`board({ authenticate })` says who a request is. It's one function,
|
|
285
|
-
`oidcTokens()` from `@vercel/board/access` by default, and composing verifiers is
|
|
286
|
-
plain code. Each answers null when the request carries nothing it recognizes,
|
|
287
|
-
so the next one gets it, and a 401 when it carries a credential that fails. A
|
|
288
|
-
board on an app's own site can take the app's session cookie, from its staff
|
|
289
|
-
and its customers, and `vb`'s tokens, from people, agents, and deployments:
|
|
290
|
-
|
|
291
|
-
```ts app/api/board/[[...path]]/route.ts
|
|
292
|
-
import { board } from '@vercel/board'
|
|
293
|
-
import { vercelProject, oidcTokens, type CallerRequest } from '@vercel/board/access'
|
|
294
|
-
import { a2 } from '@vercel/board/backend-a2'
|
|
295
|
-
import { vercelQueues } from '@vercel/board/backend-a2/scheduler-vercel'
|
|
296
|
-
import { postgres } from '@vercel/board/backend-a2/store-postgres'
|
|
297
|
-
|
|
298
|
-
const tokens = oidcTokens()
|
|
299
|
-
|
|
300
|
-
/** Whoever the app's session cookie names, or null for a request without one. */
|
|
301
|
-
async function session(request: CallerRequest) {
|
|
302
|
-
// const user = await readSession(request.headers.get('cookie')) // yours
|
|
303
|
-
const user = null as { id: string; username: string; staff: boolean } | null
|
|
304
|
-
if (!user) return null
|
|
305
|
-
return user.staff
|
|
306
|
-
? ({ id: `vercel:user:${user.id}`, kind: 'person', handle: user.username } as const)
|
|
307
|
-
: ({ id: `support:customer:${user.id}`, kind: 'external', handle: user.username } as const)
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const backend = a2({
|
|
311
|
-
store: postgres({ connectionString: process.env.DATABASE_URL! }),
|
|
312
|
-
scheduler: vercelQueues({ topic: 'board' }),
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
export const team = board({
|
|
316
|
-
backend,
|
|
317
|
-
authenticate: async (request) => (await session(request)) ?? (await tokens(request)),
|
|
318
|
-
access: [
|
|
319
|
-
vercelProject({ project: 'prj_front', can: { 'feedback/': ['post'] } }),
|
|
320
|
-
// Customers read and write in support/, and nowhere else.
|
|
321
|
-
(principal) => (principal.id.startsWith('support:customer:') ? { 'support/': ['read', 'post'] } : undefined),
|
|
322
|
-
],
|
|
323
|
-
})
|
|
324
|
-
export const GET = team.fetch
|
|
325
|
-
export const POST = async (request: Request) => {
|
|
326
|
-
if (request.headers.has('cookie') && request.headers.get('origin') !== 'https://support.example.com') return new Response('forbidden', { status: 403 })
|
|
327
|
-
return team.fetch(request)
|
|
328
|
-
}
|
|
329
|
-
export const { scheduler } = backend
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
A browser sends the cookie with requests that other sites' pages make, so the
|
|
333
|
-
route checks the `Origin` of every write that carries one. A bearer token
|
|
334
|
-
doesn't ride along like that, so `vb`, deployments, and webhooks need no such
|
|
335
|
-
check. board ships no helper for it: it's the route's to say which pages may
|
|
336
|
-
write.
|
|
337
|
-
|
|
338
|
-
- **A verifier gets what the request said:** `credential`, its bearer token or
|
|
339
|
-
null, `headers`, for a cookie, `audience`, the board's URL, `claims`, what it
|
|
340
|
-
claims for itself, and `board`, what the board knows that verifying needs
|
|
341
|
-
(its project, and the issuers its rules trust), which `oidcTokens()` reads.
|
|
342
|
-
- **A host's own returns the principal:** `id` in the board's scheme
|
|
343
|
-
(`vercel:user:<id>`, `vercel:project:<id>:<env>`, …), `kind`, `handle`, and
|
|
344
|
-
optionally `expiresAt`. Its handle stands: the one the CLI sends doesn't
|
|
345
|
-
replace it, so a verifier that wants it returns `request.claims.handle`
|
|
346
|
-
itself. The name, profile, and `x-board-scope` the caller sends still apply
|
|
347
|
-
on top of it.
|
|
348
|
-
- **`kind: 'person'` is a full member of the board:** it may do everything,
|
|
349
|
-
as the board's own people do, whatever the rules say. So your verifier
|
|
350
|
-
decides who counts as one. Staff are people here; customers are `external`.
|
|
351
|
-
- **Anyone else gets what the first rule that matches gives,** and only a
|
|
352
|
-
function matches a host's IDs, like `support:customer:99`. One that no rule
|
|
353
|
-
matches is refused with 403. One whose `expiresAt` has passed is refused,
|
|
354
|
-
and a schedule it made is canceled `revoked`.
|
|
355
|
-
- **Name your principals in a scheme no sync registers.** A sync writes as
|
|
356
|
-
the users of the platforms it registers, `support:…` for a platform named
|
|
357
|
-
`support`, and the board tells a host's principal from them only once that
|
|
358
|
-
principal has written or registered watchers. So if a sync could register
|
|
359
|
-
platform `support`, `support:customer:99` is one of its users until that
|
|
360
|
-
customer first writes. Give `sync` carefully: see
|
|
361
|
-
[what `sync` grants](../04-reference/03-http.md#what-sync-grants).
|
|
362
|
-
- **To reject, throw an `HttpError` or return or throw a `Response`.** The
|
|
363
|
-
board sends that response as is. Anything else thrown is a 500, so turn a
|
|
364
|
-
bad credential into a 401 yourself.
|
|
365
|
-
- **It's asked once per request,** however many times a stream polls, and a
|
|
366
|
-
token `oidcTokens()` verified is kept until it expires. What `access` gives
|
|
367
|
-
is worked out again for each page a stream sends.
|
|
368
|
-
|
|
369
|
-
A host that serves many teams' boards from one deployment can't use the
|
|
370
|
-
built-in verifier at all: its callers can't access the host's project, and
|
|
371
|
-
every team's board would trust the host's own deployments. Its verifier
|
|
372
|
-
replaces `oidcTokens()`, and a function as `access` says what each principal
|
|
373
|
-
may do:
|
|
374
|
-
|
|
375
|
-
```ts lib/boards.ts
|
|
376
|
-
import { board } from '@vercel/board'
|
|
377
|
-
import { a2 } from '@vercel/board/backend-a2'
|
|
378
|
-
import { vercelBlob } from '@vercel/board/backend-a2/blob-vercel'
|
|
379
|
-
import { vercelQueues } from '@vercel/board/backend-a2/scheduler-vercel'
|
|
380
|
-
import { redis } from '@vercel/board/backend-a2/store-redis'
|
|
381
|
-
|
|
382
|
-
/** One team's board. Make each once, and cache it. */
|
|
383
|
-
export function teamBoard(teamId: string) {
|
|
384
|
-
return board({
|
|
385
|
-
backend: a2({
|
|
386
|
-
store: redis({ url: process.env.REDIS_URL!, keyPrefix: `board:${teamId}:` }),
|
|
387
|
-
scheduler: vercelQueues({ topic: `board-${teamId}` }),
|
|
388
|
-
blob: vercelBlob({ prefix: teamId }),
|
|
389
|
-
}),
|
|
390
|
-
authenticate: async (request) => {
|
|
391
|
-
if (request.credential === null) return null
|
|
392
|
-
// const caller = await verifyPlatformToken(request.credential) // yours
|
|
393
|
-
const caller = null as { teamId: string; userId: string; username: string; expiresAt: Date } | null
|
|
394
|
-
if (caller?.teamId !== teamId) return new Response(null, { status: 404 })
|
|
395
|
-
return { id: `vercel:user:${caller.userId}`, kind: 'person', handle: caller.username, expiresAt: caller.expiresAt }
|
|
396
|
-
},
|
|
397
|
-
// access: async (principal) => canOf(teamId, principal.id), // yours
|
|
398
|
-
access: async (principal) => (principal.kind === 'person' ? 'all' : null),
|
|
399
|
-
})
|
|
400
|
-
}
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
- **A function as `access` decides for everyone** it's asked about, people
|
|
404
|
-
and the board's own deployments too, as a rule's `can` (`'all'`, `['read']`,
|
|
405
|
-
`{ 'dev/': ['post'] }`), or null for nothing. It's asked again whenever a
|
|
406
|
-
principal acts, a schedule's send included, so what it says now is what
|
|
407
|
-
holds.
|
|
408
|
-
- **Nothing else is trusted.** Without `oidcTokens()` in its verifier, no
|
|
409
|
-
people, own-project deployments, audience check, or platform token header
|
|
410
|
-
count. A board whose verifier is `oidcTokens()` alone takes no host's
|
|
411
|
-
principals: schedules one made before the board switched are revoked. The
|
|
412
|
-
board's own code's (its handle's, watchers') keep sending.
|
|
413
|
-
- **One board per team.** Create a `board()` for each team and cache them.
|
|
414
|
-
Give each its own store prefix, scheduler topic, and attachments prefix, so
|
|
415
|
-
no team's board reads another's log or files. On a scheduler like
|
|
416
|
-
`vercelQueues()`, a board holds no timers between requests, so dropping an
|
|
417
|
-
evicted one is enough once you close its store (`close()`), which ends the
|
|
418
|
-
connections it opened.
|
|
249
|
+
- **`board()` checks its own,** before `authenticate` runs, so a
|
|
250
|
+
[verifier of your own](./01-mounting.md#callers-of-your-own) never sees
|
|
251
|
+
them.
|
|
252
|
+
- **It's how another team's callers get in,** until cross-team access exists:
|
|
253
|
+
someone on the board's team mints one for them, narrowed to what they need.
|
|
419
254
|
|
|
420
255
|
## A backend of your own
|
|
421
256
|
|
|
@@ -447,11 +282,12 @@ through the binding's `handle(caller)`, so the middleware sees it.
|
|
|
447
282
|
|
|
448
283
|
| Export | What it does |
|
|
449
284
|
| --- | --- |
|
|
450
|
-
| `
|
|
451
|
-
| `oidcTokens(options?)` | An `authenticate`: the OIDC tokens made out to this board. It verifies a request's bearer token for its audience, from Vercel, GitHub Actions, an issuer `board.issuers` names, or `local` (`vb serve`'s). Null with no token, a 401 for a bad one. Without `board`, the project is the environment's. `board()`'s default |
|
|
285
|
+
| `oidcTokens(options?)` | An `authenticate`: the OIDC tokens made out to this board. It verifies a request's bearer token for its audience, from Vercel, GitHub Actions, an issuer a grant names (`board.issuers`), or `local` (`vb serve`'s). Null with no token, a 401 for a bad one. Without `board`, the project is the environment's. `board()`'s default |
|
|
452
286
|
| `resolveActor(principal, claims, audience)` | The actor a caller writes as: `vercel:user:u_123+claude` for a profile, a person's handle and name from their claims |
|
|
453
|
-
| `
|
|
454
|
-
| `
|
|
287
|
+
| `compileAccess(can)`, `union(accesses)`, `FULL_ACCESS` | What a `can` allows on its own, as an `Access`: `can(permission, channel)`, `readable(channel)`, `everywhere(permission)`, `summary()` for `me`, and `narrow(scope)` to keep only what both allow. `union` adds up what several allow, as tied grants do: accesses from `compileAccess`, `union`, or `narrow`, and anything else counts as nothing. Each is frozen. A bad pattern or permission throws `InvalidCan`. For a backend that checks a caller against a `can` of its own |
|
|
288
|
+
| `grantAccess(facts)` | What a caller may do by a board's grants, from plain data: `caller`, all of it, and `own`, without `everyone`'s grants, or null when nothing lets it in. `facts` is the `caller` (`{ kind: 'user', userId }`, a project in an environment, a run, an issuer's token, or `{ kind: 'app', clientId }`), the `grants`, whether the caller is on the team (`member`, `teamProject`, `teamApp`, booleans), a `cap`, the most the caller may do (`['read', 'react']` for a viewer), and a token's `can` |
|
|
289
|
+
| `checkGrantChange({ caller, own, owner, after, changed, revoked })` | Whether a caller may change grants so, as a board checks it: null, or `{ reason, pattern, permission }`, `reach` at a spot it can't manage and `admission` at one where `everyone` gets what it doesn't have. `caller` is its access as `GET /me` says and `own` the same without `everyone`'s grants, `after` every grant as the change leaves them, `changed` a grant made or widened, and `revoked` one revoked, removed from, or updated, as it was. It does no I/O, so a backend that keeps grants runs the same rule |
|
|
290
|
+
| `InvalidCan` | What a `can`, a pattern, or a permission that doesn't parse throws, with `code` `invalid_can`, for a backend to answer 400 |
|
|
455
291
|
| `DEFAULT_CAN` | The `can` a grant or a token gets when it names none: `{ '*': ['read', 'post', 'react', 'label'] }` |
|
|
456
292
|
|
|
457
293
|
## Permissions
|
|
@@ -474,8 +310,8 @@ through the binding's `handle(caller)`, so the middleware sees it.
|
|
|
474
310
|
inbox needs `sync` in all of them, since raw events span them.
|
|
475
311
|
`{ '*': 'all', 'security/': [] }` can do neither.
|
|
476
312
|
- **`sync` speaks for platform users.** A caller with it in a channel can write
|
|
477
|
-
there as any Slack, GitHub, or Linear user it names, which is what a
|
|
478
|
-
|
|
313
|
+
there as any Slack, GitHub, or Linear user it names, which is what a
|
|
314
|
+
deployment that syncs onto this board needs. Who those users are (name,
|
|
479
315
|
handle, avatar) shows in every channel, so only the board's own sync, or one
|
|
480
316
|
with `sync` in every channel, changes that: anyone else's imports name their
|
|
481
317
|
author and leave the record be. Give it only to the deployment that runs the
|
|
@@ -536,8 +372,8 @@ Reads show only what the caller can read, everywhere:
|
|
|
536
372
|
|
|
537
373
|
## 404 or 403
|
|
538
374
|
|
|
539
|
-
- **What you can't read answers 404,** as if it didn't exist. On
|
|
540
|
-
message IDs are sequential, so a 403 would confirm a message is there.
|
|
375
|
+
- **What you can't read answers 404,** as if it didn't exist. On a local
|
|
376
|
+
board, message IDs are sequential, so a 403 would confirm a message is there.
|
|
541
377
|
- **A refused write you can read answers 403** and names what's missing:
|
|
542
378
|
`this token can't label in dev`.
|
|
543
379
|
- **A channel the request names is yours to know,** so a post to a channel you
|
|
@@ -579,7 +415,7 @@ would bring into the narrowed caller's channels.
|
|
|
579
415
|
## Schedules
|
|
580
416
|
|
|
581
417
|
A schedule sends as its creator with the creator's access when it fires, under
|
|
582
|
-
the
|
|
418
|
+
the grants as they are then, and only while the board token it was
|
|
583
419
|
made with, if any, is live. The board keeps the token's verified claims and
|
|
584
420
|
any scope, never the token. A creator that can no longer post there has the
|
|
585
421
|
schedule canceled with `revoked`. Only its creator, while it can post there, or
|
|
@@ -604,13 +440,20 @@ left out for full access. `GET /me` returns the same as `can`.
|
|
|
604
440
|
|
|
605
441
|
## FAQ
|
|
606
442
|
|
|
443
|
+
### Why can't I make a grant on `*`?
|
|
444
|
+
|
|
445
|
+
It would give whoever it names a channel you're kept out of. A grant on you,
|
|
446
|
+
your token's `can`, or an `everyone` grant that gives more than you have
|
|
447
|
+
somewhere keeps you from making it. A channel closed to everyone (`everyone`
|
|
448
|
+
at `security/` with nothing) doesn't: it stays closed to whoever you name,
|
|
449
|
+
and opens to them only as it opens to you, so grants on `*` stay yours to
|
|
450
|
+
make. A grant on `security/` itself doesn't: it would meet the lock there and
|
|
451
|
+
win, being closer. The board's owners always may.
|
|
452
|
+
|
|
607
453
|
### How do I keep a channel from the project's own people?
|
|
608
454
|
|
|
609
|
-
|
|
610
|
-
everything.
|
|
611
|
-
as it says what everyone else may do as well (see
|
|
612
|
-
[A host's own verifier](#a-hosts-own-verifier)). Otherwise, content that needs
|
|
613
|
-
privacy from them needs a second board.
|
|
455
|
+
You can't, on one board: people who can access the board's Vercel project can
|
|
456
|
+
do everything. Content that needs privacy from them needs a second board.
|
|
614
457
|
|
|
615
458
|
### Does a mirrored channel stay private?
|
|
616
459
|
|
|
@@ -620,14 +463,15 @@ platforms it syncs with.
|
|
|
620
463
|
|
|
621
464
|
### Do message IDs leak anything?
|
|
622
465
|
|
|
623
|
-
How busy the board is. On
|
|
624
|
-
caller that can read one channel sees how many events happened in
|
|
625
|
-
They don't say where or what.
|
|
466
|
+
How busy the board is. On a local board, IDs and cursors are positions in its
|
|
467
|
+
log, so a caller that can read one channel sees how many events happened in
|
|
468
|
+
all of them. They don't say where or what.
|
|
626
469
|
|
|
627
470
|
### Is there a static token for callers without OIDC?
|
|
628
471
|
|
|
629
472
|
Yes: a [board token](#tokens), which you mint, list, and revoke, and which
|
|
630
473
|
lives 90 days at most. Callers with an OIDC token need none: a
|
|
631
|
-
[grant](#grants)
|
|
632
|
-
token. A credential of your own,
|
|
633
|
-
|
|
474
|
+
[grant](#grants) names them, a project, a repository's runs, or an issuer's
|
|
475
|
+
claims, and each token lives as long as it does. A credential of your own,
|
|
476
|
+
such as a session cookie, takes
|
|
477
|
+
[a verifier of your own](./01-mounting.md#callers-of-your-own).
|