@mediamonks/canopy-cli 0.7.50 → 0.7.52
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/dist/{dev-BQ77vmCk.mjs → dev-BnzJ8a1u.mjs} +5 -4
- package/dist/dev-DSI3e4qP.mjs +2 -0
- package/dist/{dev-worker-BP-HGHYb.mjs → dev-worker-DBBN0F6X.mjs} +15 -33
- package/dist/docs/access-tokens.md +145 -0
- package/dist/docs/calling-projects.md +9 -0
- package/dist/docs/ci.md +8 -0
- package/dist/docs/cli-dev.md +1 -1
- package/dist/docs/cli-files.md +57 -0
- package/dist/docs/cli.md +2 -0
- package/dist/docs/developers-architecture.md +20 -4
- package/dist/docs/index.json +20 -0
- package/dist/docs/outside-sign-in.md +79 -0
- package/dist/docs/overview-faq.md +4 -3
- package/dist/docs/platform-client-access.md +6 -0
- package/dist/docs/platform-credentials.md +76 -0
- package/dist/docs/platform-members-and-access.md +31 -6
- package/dist/docs/platform-project-data.md +11 -1
- package/dist/docs/sdk-auth.md +71 -21
- package/dist/docs/sdk-files.md +148 -3
- package/dist/docs/sdk-projects.md +2 -1
- package/dist/docs/sdk.md +17 -10
- package/dist/docs/staging.md +8 -0
- package/dist/docs/troubleshooting.md +20 -0
- package/dist/{docs-Cd6VzYts.mjs → docs-Od4duFhd.mjs} +1 -1
- package/dist/{feedback-BkrdL92o.mjs → feedback-XEIHbeor.mjs} +1 -1
- package/dist/files-B7toJRlj.mjs +69 -0
- package/dist/index.mjs +14 -12
- package/dist/{local-C6ggy2PQ.mjs → local-R-INkPbU.mjs} +17 -6
- package/dist/{mcp-Bt9Z9kdf.mjs → mcp-misDO7O8.mjs} +1 -1
- package/dist/{package-Sir3152_.mjs → package-DBdEKZ6u.mjs} +1 -1
- package/dist/{project-template-DHWdVc6E.mjs → project-template-Bas1UN2O.mjs} +1 -0
- package/dist/project-template-Dti_Mmnb.mjs +2 -0
- package/dist/{projects-Z8ufQIBc.mjs → projects-BEBYhy6k.mjs} +1 -1
- package/dist/skill/canopy/SKILL.md +9 -1
- package/dist/{skill-Bxc5E-wu.mjs → skill-3RZw4vSI.mjs} +1 -1
- package/dist/{src-DzU89gZN.mjs → src-UBUAqzqH.mjs} +442 -43
- package/dist/templates/worker/worker/index.ts +4 -0
- package/dist/{upgrade-DOpeMSWD.mjs → upgrade-Dy4XV7iP.mjs} +1 -1
- package/package.json +2 -2
- package/dist/dev-Z3bI5hgh.mjs +0 -2
- package/dist/project-template-ChFb7A_H.mjs +0 -2
|
@@ -2,7 +2,7 @@ import { c as projectDirArgs, d as resolveProject, m as tryReadCanopyJson, r as
|
|
|
2
2
|
import { a as apiRequest, m as withContext, t as ApiError } from "./api-DmJrIsE7.mjs";
|
|
3
3
|
import { r as reportErrors, t as formatDateTime } from "./ui-Ddw4d2Nn.mjs";
|
|
4
4
|
import { r as readMigrationFiles } from "./migrations-BReMlGWP.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-UBUAqzqH.mjs";
|
|
6
6
|
import { a as parseAppRoleFlag } from "./roles-CUFRTp_R.mjs";
|
|
7
7
|
import { n as writeDevServerRecord } from "./dev-server-file-Dk9pk4AR.mjs";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
@@ -107,7 +107,7 @@ async function workerPlugin(flags, slug, workerAttest, remoteUser, roles) {
|
|
|
107
107
|
console.log(`note: canopy.json points "worker" at ${entry}, which does not exist — skipping.`);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-
|
|
110
|
+
const { missingSecretNames, readDevVars, workerDevPlugin } = await import("./dev-worker-DBBN0F6X.mjs");
|
|
111
111
|
const secrets = readDevVars(flags.dir);
|
|
112
112
|
const email = siteConfig().email;
|
|
113
113
|
const found = await remoteUser?.() ?? (email ? {
|
|
@@ -262,6 +262,7 @@ async function bridgeToSandbox(sandbox, req, res) {
|
|
|
262
262
|
const headers = new Headers();
|
|
263
263
|
if (req.headers["content-type"]) headers.set("content-type", req.headers["content-type"]);
|
|
264
264
|
if (req.headers["accept"]) headers.set("accept", req.headers["accept"]);
|
|
265
|
+
if (body.length > 0) headers.set("content-length", String(body.length));
|
|
265
266
|
const attest = req.headers[WORKER_ATTEST_HEADER];
|
|
266
267
|
if (typeof attest === "string") headers.set(WORKER_ATTEST_HEADER, attest);
|
|
267
268
|
const response = await sandbox.handle(new Request(`http://canopy.local${req.url ?? ""}`, {
|
|
@@ -325,7 +326,7 @@ async function devRemote(flags, slug) {
|
|
|
325
326
|
async function devLocal(flags, slug) {
|
|
326
327
|
let dump;
|
|
327
328
|
if (flags.pull) {
|
|
328
|
-
const { fetchProjectDump } = await import("./local-
|
|
329
|
+
const { fetchProjectDump } = await import("./local-R-INkPbU.mjs");
|
|
329
330
|
console.log(`Pulling a fresh export of ${slug}${flags.staging ? " [staging]" : ""}…`);
|
|
330
331
|
dump = await fetchProjectDump(slug, flags.staging ? "staging" : "live");
|
|
331
332
|
}
|
|
@@ -342,7 +343,7 @@ async function devLocal(flags, slug) {
|
|
|
342
343
|
}
|
|
343
344
|
const workerAttest = randomBytes(24).toString("base64url");
|
|
344
345
|
const devRoles = await resolveDevRoles(slug, flags.asRoles);
|
|
345
|
-
const { createSandbox } = await import("./local-
|
|
346
|
+
const { createSandbox } = await import("./local-R-INkPbU.mjs");
|
|
346
347
|
const sandbox = await createSandbox({
|
|
347
348
|
slug,
|
|
348
349
|
persistDir: join(flags.dir, ".canopy", "local"),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as
|
|
1
|
+
import { a as readPersonCaller, i as CALLER_HEADER, n as redactCanopyCredentials, o as readUser, r as stampWorkerHeaders, t as WORKER_ATTEST_HEADER } from "./src-UBUAqzqH.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { relative, resolve, sep } from "node:path";
|
|
4
4
|
//#region src/dev-worker.ts
|
|
@@ -189,23 +189,13 @@ function createDevBlob(canopyFetch, prefix) {
|
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
/** Gateway-stamped identity, honored in dev too so a request can pose as one. */
|
|
192
|
+
/**
|
|
193
|
+
* Gateway-stamped identity, honored in dev too so a request can pose as one.
|
|
194
|
+
* Decoded by the shared caller protocol (@mediamonks/canopy-data-plane,
|
|
195
|
+
* credential-model); the developer stands in when nothing is stamped.
|
|
196
|
+
*/
|
|
199
197
|
function userFromHeaders(headers, fallback) {
|
|
200
|
-
|
|
201
|
-
if (!sub) return fallback;
|
|
202
|
-
const roles = rolesFromHeaders(headers);
|
|
203
|
-
return {
|
|
204
|
-
sub,
|
|
205
|
-
email: (headers.get("x-canopy-user-email") ?? "").trim(),
|
|
206
|
-
name: (headers.get("x-canopy-user-name") ?? "").trim(),
|
|
207
|
-
...roles && { roles }
|
|
208
|
-
};
|
|
198
|
+
return readUser(headers) ?? fallback;
|
|
209
199
|
}
|
|
210
200
|
/**
|
|
211
201
|
* The caller in dev: stamped caller headers when a request poses as one
|
|
@@ -213,28 +203,20 @@ function userFromHeaders(headers, fallback) {
|
|
|
213
203
|
* the developer, since no company login fronts a local server.
|
|
214
204
|
*/
|
|
215
205
|
function callerFromHeaders(headers, fallback) {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return {
|
|
222
|
-
kind,
|
|
223
|
-
id,
|
|
224
|
-
email: (headers.get("x-canopy-identity-email") ?? "").trim(),
|
|
225
|
-
name: (headers.get("x-canopy-identity-name") ?? "").trim(),
|
|
226
|
-
agent,
|
|
227
|
-
...roles && { roles }
|
|
228
|
-
};
|
|
229
|
-
}
|
|
206
|
+
const person = readPersonCaller(headers);
|
|
207
|
+
if (person) return {
|
|
208
|
+
...person,
|
|
209
|
+
token: null
|
|
210
|
+
};
|
|
230
211
|
const user = userFromHeaders(headers, fallback);
|
|
231
212
|
return user ? {
|
|
232
213
|
kind: "monk",
|
|
233
214
|
id: user.sub,
|
|
234
215
|
email: user.email,
|
|
235
216
|
name: user.name,
|
|
236
|
-
agent,
|
|
237
|
-
...user.roles && { roles: user.roles }
|
|
217
|
+
agent: headers.get(CALLER_HEADER) === "agent",
|
|
218
|
+
...user.roles && { roles: user.roles },
|
|
219
|
+
token: null
|
|
238
220
|
} : null;
|
|
239
221
|
}
|
|
240
222
|
/**
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Calling from apps and scripts
|
|
3
|
+
description: Let a desktop app, plugin, CI job or script call your project's backend with an access token.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
A project's `/api` routes normally open only to someone signed in with a
|
|
7
|
+
browser. An access token lets other software in: a design-tool plugin on a
|
|
8
|
+
designer's laptop, a CI job that pushes a report, a script that pulls
|
|
9
|
+
results. It works only on one project's `/api` routes, never on its pages.
|
|
10
|
+
|
|
11
|
+
There are two kinds:
|
|
12
|
+
|
|
13
|
+
| | Personal token | Project key |
|
|
14
|
+
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
15
|
+
| For | a desktop app or plugin used by one person | a CI job, script or service |
|
|
16
|
+
| Acts as | the person who made it | itself, with no person behind it |
|
|
17
|
+
| Who makes it | any Monk who can open the project | the owner, managers and site admins |
|
|
18
|
+
| Stops working | when it expires (90 days at most), when its person loses access to the project, or after 30 days without them signing in to Canopy | when it expires (if you gave it a date), or after 90 days without a call |
|
|
19
|
+
| How many | 10 per person on each channel | 20 on each channel |
|
|
20
|
+
|
|
21
|
+
Both stop when they're revoked, when the project is deleted, and when the
|
|
22
|
+
owner turns access tokens off.
|
|
23
|
+
|
|
24
|
+
## 1. Turn access tokens on
|
|
25
|
+
|
|
26
|
+
The project's owner turns them on under **Settings → Access → Access
|
|
27
|
+
tokens**. They are off by default. Turning them off later stops every token
|
|
28
|
+
on the project at once; turning them back on revives the ones that haven't
|
|
29
|
+
expired.
|
|
30
|
+
|
|
31
|
+
## 2. Make a token
|
|
32
|
+
|
|
33
|
+
- **A personal token:** on your **Account** page (click your avatar), choose
|
|
34
|
+
**New token**. If you can open the project's settings, **New personal
|
|
35
|
+
token** under **Settings → Access** does the same.
|
|
36
|
+
- **A project key:** on the project's **Settings → Access**, choose **New
|
|
37
|
+
project key**.
|
|
38
|
+
|
|
39
|
+
People outside Monks and client-password visitors can't make tokens.
|
|
40
|
+
|
|
41
|
+
Give it a name you'll recognise later, pick the channel (live or staging) and
|
|
42
|
+
how long it lasts. A personal token lasts 30 days unless you pick another
|
|
43
|
+
length, up to 90. A project key lasts until you revoke it unless you give it a
|
|
44
|
+
date. The token is shown once. Copy it into the app's keychain
|
|
45
|
+
or your CI's secret store, never into a file in your repository.
|
|
46
|
+
|
|
47
|
+
You can limit a token further:
|
|
48
|
+
|
|
49
|
+
- **Routes:** only paths under the prefixes you give (up to 10), like `/api/hooks`. A
|
|
50
|
+
prefix covers whole path segments, so `/api/hooks` doesn't open
|
|
51
|
+
`/api/hooksmith`.
|
|
52
|
+
- **Methods:** only the HTTP methods you pick. `GET` only means other methods
|
|
53
|
+
are refused; a `GET` route that changes data still runs.
|
|
54
|
+
- **Scopes:** your project's own permissions (step 4).
|
|
55
|
+
|
|
56
|
+
Canopy refuses anything outside the routes and methods before your backend
|
|
57
|
+
runs. Give every project key a route limit if you can.
|
|
58
|
+
|
|
59
|
+
## 3. Call the project
|
|
60
|
+
|
|
61
|
+
Send the token as a bearer token to the project's own address:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
curl -X POST https://my-project.canopy.website/api/hooks/build \
|
|
65
|
+
-H "Authorization: Bearer $CANOPY_KEY" \
|
|
66
|
+
-H "content-type: application/json" \
|
|
67
|
+
-d '{"status":"passed"}'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
A refused token gets a JSON answer, never a sign-in page:
|
|
71
|
+
|
|
72
|
+
| Error | Why |
|
|
73
|
+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
|
74
|
+
| `token_invalid` | unknown or revoked, or made for another project or channel |
|
|
75
|
+
| `token_expired` | past its date, or a project key unused for 90 days |
|
|
76
|
+
| `token_disabled` | the owner turned access tokens off |
|
|
77
|
+
| `token_access_lost` | its person can no longer open the project, or hasn't signed in to Canopy for 30 days |
|
|
78
|
+
| `token_path_not_allowed`, `token_method_not_allowed` | outside the token's routes or methods |
|
|
79
|
+
| `project_paused`, `project_moved` | the project is paused, or moved (the answer's `moved_to` says where) |
|
|
80
|
+
| `no_backend` | the project has no backend on that channel |
|
|
81
|
+
| `token_check_unavailable` | Canopy couldn't check the token just now; try again |
|
|
82
|
+
|
|
83
|
+
A personal token keeps working as long as its person signs in to Canopy at
|
|
84
|
+
least once a month, in a browser or with `canopy login`. If someone only ever uses the plugin, the
|
|
85
|
+
`token_access_lost` answer tells them to sign in again.
|
|
86
|
+
|
|
87
|
+
## 4. Check it in your backend
|
|
88
|
+
|
|
89
|
+
Your backend sees who called on [`env.CALLER`](https://docs.canopy.website/sdk/auth#in-a-backend-worker),
|
|
90
|
+
and the token on `env.CALLER.token`:
|
|
91
|
+
|
|
92
|
+
- A personal token's caller is the person, with their app roles, exactly
|
|
93
|
+
as in their browser, plus `token`.
|
|
94
|
+
- A project key's caller has `kind: "key"`, the key's `id` and `name`, no
|
|
95
|
+
roles, and `env.USER` is `null`.
|
|
96
|
+
- Every other request has `token: null`.
|
|
97
|
+
|
|
98
|
+
Scopes are your project's own words for what a token may do. Add them under
|
|
99
|
+
**Settings → Access → Token scopes** (for example `reports:write`), pick
|
|
100
|
+
them when making a token, and check them in your backend with `requireScope`:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { requireScope, ScopeError } from "@mediamonks/canopy";
|
|
104
|
+
|
|
105
|
+
app.post("/api/hooks/build", async (c) => {
|
|
106
|
+
try {
|
|
107
|
+
requireScope(c.env.CALLER, "reports:write");
|
|
108
|
+
} catch (err) {
|
|
109
|
+
if (err instanceof ScopeError) return c.json({ error: err.message }, 403);
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
// …
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`requireScope` lets a browser visitor through: scopes narrow what a token may
|
|
117
|
+
do, not what its person may do. A token passes only when it carries the
|
|
118
|
+
scope. A route that never calls `requireScope` gives a token everything its
|
|
119
|
+
caller could do, so check scopes on every route a token shouldn't reach
|
|
120
|
+
freely.
|
|
121
|
+
|
|
122
|
+
During a token call, your backend's own Canopy calls (`auth.user()`, data,
|
|
123
|
+
files) act as the project, not as the token's person. Use `env.CALLER` to
|
|
124
|
+
know who called.
|
|
125
|
+
|
|
126
|
+
A backend deployed before access tokens existed doesn't see `env.CALLER.token`
|
|
127
|
+
or project keys. Run `canopy deploy` once to pick them up.
|
|
128
|
+
|
|
129
|
+
## Trying it locally
|
|
130
|
+
|
|
131
|
+
`canopy dev` has no token check: the developer is always the caller, and
|
|
132
|
+
`env.CALLER.token` is `null`, so `requireScope` lets every request through. To
|
|
133
|
+
try a token for real, deploy to the [staging channel](https://docs.canopy.website/guides/staging) and make a
|
|
134
|
+
staging token for it.
|
|
135
|
+
|
|
136
|
+
## See and revoke tokens
|
|
137
|
+
|
|
138
|
+
- Your own personal tokens are on your Account page, on every project.
|
|
139
|
+
- The owner and managers see every token on the project under **Settings →
|
|
140
|
+
Access**, with who made it, when it was last used and when it ends.
|
|
141
|
+
- Revoking one stops it within a few seconds.
|
|
142
|
+
- Signing out everywhere ends all your personal tokens. Project keys you made
|
|
143
|
+
keep working, because they belong to the project.
|
|
144
|
+
|
|
145
|
+
Read [Members & access](https://docs.canopy.website/platform/members-and-access) for who can do what.
|
|
@@ -48,6 +48,15 @@ const assets = await res.json();
|
|
|
48
48
|
and a body as usual. It calls the live channel unless you pass `{ channel: "staging" }`.
|
|
49
49
|
The other project needs no entry on your [outbound hosts](https://docs.canopy.website/platform/egress).
|
|
50
50
|
|
|
51
|
+
To keep a staged backend off the other project's live data, call the channel
|
|
52
|
+
you are on yourself. `env.CANOPY_CHANNEL` tells you which one that is:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const res = await canopy.projects.fetch("asset-library", "/api/assets", {
|
|
56
|
+
channel: env.CANOPY_CHANNEL, // "live" or "staging"
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
51
60
|
You get the other project's response back as it is. When Canopy refuses the
|
|
52
61
|
call, you get a JSON error instead:
|
|
53
62
|
|
package/dist/docs/ci.md
CHANGED
|
@@ -135,3 +135,11 @@ wins over the linked repository when both are there.
|
|
|
135
135
|
working when they leave.
|
|
136
136
|
- A token that goes 90 days without a deploy stops working.
|
|
137
137
|
- Turning CI deploys off does not stop a deploy token. Revoke it for that.
|
|
138
|
+
|
|
139
|
+
## CI jobs that call your project
|
|
140
|
+
|
|
141
|
+
A deploy token only deploys. For a CI job that sends data to your project
|
|
142
|
+
while it runs, like test results or a build report, give it a
|
|
143
|
+
[project key](https://docs.canopy.website/guides/access-tokens) and have it call your project's own
|
|
144
|
+
`/api` routes. [Which credential do I need?](https://docs.canopy.website/platform/credentials) compares
|
|
145
|
+
them all.
|
package/dist/docs/cli-dev.md
CHANGED
|
@@ -40,7 +40,7 @@ With the lock in place, `--local` runs on an embedded SQLite engine instead —
|
|
|
40
40
|
|
|
41
41
|
**Your backend worker.** If `canopy.json` names a `worker` entry (the worker scaffold does), `canopy dev` serves it too: requests to `/api/*` go to your worker, everything else to the SPA — the same split the platform makes once you deploy. There's no build step; save the file and the next request runs the new code.
|
|
42
42
|
|
|
43
|
-
Your worker gets the same `env` it gets in production: `env.CANOPY.fetch` for the SDK, `env.DB` and `env.BLOB` for raw database and file access, `env.CALLER` and `env.USER` for whoever is calling, `env.PROJECT_SLUG
|
|
43
|
+
Your worker gets the same `env` it gets in production: `env.CANOPY.fetch` for the SDK, `env.DB` and `env.BLOB` for raw database and file access, `env.CALLER` and `env.USER` for whoever is calling, `env.PROJECT_SLUG`, and `env.CANOPY_CHANNEL` (`"staging"` with `--staging`, otherwise `"live"`). They all follow the mode you're in — live project data by default, your sandbox under `--local`. Three differences worth knowing: `env.CALLER` and `env.USER` are you (the account you logged in with), since there's no company login in front of a local server; there's no [access token](https://docs.canopy.website/guides/access-tokens) check, so `env.CALLER.token` is always `null` and `requireScope` lets every request through; and a write through `env.DB` reports no row count locally.
|
|
44
44
|
|
|
45
45
|
To tick a schedule by hand, post its name to the same path the platform uses:
|
|
46
46
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: canopy files
|
|
3
|
+
description: Show or set what the app's own pages may do with the project's files.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`canopy files` works with the project's file storage, the files your app keeps
|
|
7
|
+
with [`canopy.blob`](https://docs.canopy.website/sdk/files). Today it has one subcommand, `access`.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
canopy files access [--project <slug>]
|
|
13
|
+
canopy files access full|readonly|off [--project <slug>]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The project comes from `canopy.json` in the current directory, or from
|
|
17
|
+
`--project <slug>`. The global `--profile <site>` / `CANOPY_PROFILE` picks the
|
|
18
|
+
site.
|
|
19
|
+
|
|
20
|
+
### canopy files access
|
|
21
|
+
|
|
22
|
+
Without a level, it prints the project's browser file access and what it
|
|
23
|
+
means. With a level, it sets it and prints the result:
|
|
24
|
+
|
|
25
|
+
- `full` — pages can list, download, upload and delete files. The default.
|
|
26
|
+
- `readonly` — pages can list and download files and make download links;
|
|
27
|
+
uploads and deletes from a page are refused.
|
|
28
|
+
- `off` — pages cannot touch files at all.
|
|
29
|
+
|
|
30
|
+
Your worker, the CLI and the dashboard keep full access at every level, and
|
|
31
|
+
download links the worker makes keep working. The level is separate from the
|
|
32
|
+
database's (`canopy db access`) and applies to the live and staging channels
|
|
33
|
+
alike. A change signs out visitors who came in with the
|
|
34
|
+
[client password](https://docs.canopy.website/platform/client-access), so they pick up the new level when
|
|
35
|
+
they sign in again. You need to be an editor on the project to read or change
|
|
36
|
+
it.
|
|
37
|
+
|
|
38
|
+
When client access is on and the level isn't `off`, the output warns that
|
|
39
|
+
visitors who know the password can reach the files too.
|
|
40
|
+
|
|
41
|
+
An unknown level exits non-zero and names the accepted ones.
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# See the current level
|
|
47
|
+
canopy files access
|
|
48
|
+
|
|
49
|
+
# Make files read-only for pages, before moving uploads into the worker
|
|
50
|
+
canopy files access readonly
|
|
51
|
+
|
|
52
|
+
# Only the worker (and the links it hands out) may touch files
|
|
53
|
+
canopy files access off --project people-dashboard
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The SDK side, including the worker-issued link pattern, is in
|
|
57
|
+
[Files](https://docs.canopy.website/sdk/files#who-can-call-this-from-the-browser).
|
package/dist/docs/cli.md
CHANGED
|
@@ -58,6 +58,8 @@ has a full page per command.
|
|
|
58
58
|
- `canopy db snapshots` — list stored snapshots.
|
|
59
59
|
- `canopy db restore [file]` — replace ALL project data from a `.sql` file or
|
|
60
60
|
`--snapshot <key>`. `--yes` skips the confirmation. **Destructive.**
|
|
61
|
+
- `canopy files access [full|readonly|off]` — what the app's own pages may do
|
|
62
|
+
with its files. See [canopy files](https://docs.canopy.website/cli/files).
|
|
61
63
|
- `canopy usage` — AI spend and storage for the project (same data as the
|
|
62
64
|
dashboard Usage tab). `--project <slug>` / `--json` for agents.
|
|
63
65
|
- `canopy ai models` — the AI models and `auto/*` aliases this site offers,
|
|
@@ -16,7 +16,7 @@ project has one, dispatches `/api/*` to your backend worker.
|
|
|
16
16
|
|
|
17
17
|
```mermaid
|
|
18
18
|
flowchart TD
|
|
19
|
-
B[Browser] --> G["Gateway<br/>auth wall:
|
|
19
|
+
B[Browser or app] --> G["Gateway<br/>auth wall: sign-in, client password<br/>or access token on /api"]
|
|
20
20
|
G -->|"most paths"| A["Static assets<br/>deployed build, SPA fallback"]
|
|
21
21
|
G -->|"/api/*"| W["Backend worker<br/>(optional, canopy.json 'worker')"]
|
|
22
22
|
G -->|"/_api/data/v1/*"| P["Platform data plane<br/>auth · db · blob · ai"]
|
|
@@ -28,9 +28,20 @@ flowchart TD
|
|
|
28
28
|
|
|
29
29
|
Authentication is a platform property — your app cannot opt out, and must not
|
|
30
30
|
build its own. A visitor without a valid session is redirected into the
|
|
31
|
-
OneLogin sign-in flow
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
OneLogin sign-in flow. Other ways in, each one the project turns on:
|
|
32
|
+
|
|
33
|
+
- people outside Monks who were [invited by email](https://docs.canopy.website/guides/outside-sign-in)
|
|
34
|
+
sign in with a link or code;
|
|
35
|
+
- on projects with [client access](https://docs.canopy.website/platform/client-access), outsiders get a
|
|
36
|
+
password page and a scope-limited `external` session;
|
|
37
|
+
- an AI agent opens the app on its person's behalf with
|
|
38
|
+
[`canopy browse`](https://docs.canopy.website/guides/agent-browsing);
|
|
39
|
+
- software that isn't a browser calls `/api/*` with an
|
|
40
|
+
[access token](https://docs.canopy.website/guides/access-tokens), and
|
|
41
|
+
[another project's backend](https://docs.canopy.website/guides/calling-projects) calls it with a call
|
|
42
|
+
token Canopy signs.
|
|
43
|
+
|
|
44
|
+
Only after that does any project code or asset get served. Your app just asks
|
|
34
45
|
`canopy.auth.user()` who came through the door
|
|
35
46
|
(see the [SDK reference](https://docs.canopy.website/sdk)).
|
|
36
47
|
|
|
@@ -90,6 +101,11 @@ else is still static serving. A few things to know:
|
|
|
90
101
|
ask the platform instead: `await canopy.auth.user()` through the `CANOPY`
|
|
91
102
|
binding (below) answers for every visitor.
|
|
92
103
|
|
|
104
|
+
- **The backend knows its channel.** `c.env.CANOPY_CHANNEL` is `"live"` or
|
|
105
|
+
`"staging"`: which [channel](https://docs.canopy.website/guides/staging) this copy of the backend
|
|
106
|
+
serves. It is set on every request and in scheduled runs, so there's no
|
|
107
|
+
need to read it from the hostname.
|
|
108
|
+
|
|
93
109
|
- **Platform access goes through the same SDK**, via the `CANOPY` service
|
|
94
110
|
binding — same budgets, same data isolation as the browser:
|
|
95
111
|
|
package/dist/docs/index.json
CHANGED
|
@@ -57,11 +57,21 @@
|
|
|
57
57
|
"title": "Roles and permissions",
|
|
58
58
|
"summary": "Give people different powers inside your app with app roles, and check them where it counts."
|
|
59
59
|
},
|
|
60
|
+
{
|
|
61
|
+
"slug": "outside-sign-in",
|
|
62
|
+
"title": "Sharing a project with people outside Monks",
|
|
63
|
+
"summary": "Invite a client contact by email and they get their own sign-in to your project. No shared password, and you can take one person's access away on its own."
|
|
64
|
+
},
|
|
60
65
|
{
|
|
61
66
|
"slug": "calling-projects",
|
|
62
67
|
"title": "Calling another project",
|
|
63
68
|
"summary": "Let one project's backend call another project's API, and tell who is calling."
|
|
64
69
|
},
|
|
70
|
+
{
|
|
71
|
+
"slug": "access-tokens",
|
|
72
|
+
"title": "Calling from apps and scripts",
|
|
73
|
+
"summary": "Let a desktop app, plugin, CI job or script call your project's backend with an access token."
|
|
74
|
+
},
|
|
65
75
|
{
|
|
66
76
|
"slug": "data",
|
|
67
77
|
"title": "Working with project data",
|
|
@@ -169,6 +179,11 @@
|
|
|
169
179
|
"title": "Members & access",
|
|
170
180
|
"summary": "Everything on Canopy sits behind Monks sign-in. Editors manage a project, managers also run its members list, viewers open it, and your app can hand out its own roles on top."
|
|
171
181
|
},
|
|
182
|
+
{
|
|
183
|
+
"slug": "platform-credentials",
|
|
184
|
+
"title": "Which credential do I need?",
|
|
185
|
+
"summary": "Every way in to Canopy and to your project, and which one fits the job — sign-ins, dev tokens, deploy tokens, access tokens and agent tokens."
|
|
186
|
+
},
|
|
172
187
|
{
|
|
173
188
|
"slug": "platform-feedback",
|
|
174
189
|
"title": "Feedback & bug reports",
|
|
@@ -336,6 +351,11 @@
|
|
|
336
351
|
"title": "canopy db",
|
|
337
352
|
"summary": "Pull, snapshot, list, restore, and migrate a project's database from the terminal."
|
|
338
353
|
},
|
|
354
|
+
{
|
|
355
|
+
"slug": "cli-files",
|
|
356
|
+
"title": "canopy files",
|
|
357
|
+
"summary": "Show or set what the app's own pages may do with the project's files."
|
|
358
|
+
},
|
|
339
359
|
{
|
|
340
360
|
"slug": "cli-logs",
|
|
341
361
|
"title": "canopy logs",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Sharing a project with people outside Monks
|
|
3
|
+
description: Invite a client contact by email and they get their own sign-in to your project. No shared password, and you can take one person's access away on its own.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Anyone who manages a project's members can add someone from outside Monks by
|
|
7
|
+
their email address. They get an invitation email, sign in with that address,
|
|
8
|
+
and from then on open your app as themselves. Each person has their own
|
|
9
|
+
sign-in, so you can see who is who, give one person an app role, and remove
|
|
10
|
+
one person without touching anyone else.
|
|
11
|
+
|
|
12
|
+
> **Note:** This has to be switched on for the site. If the Members card doesn't mention outside invitations,
|
|
13
|
+
> ask the platform team.
|
|
14
|
+
|
|
15
|
+
## Inviting someone
|
|
16
|
+
|
|
17
|
+
On the project's **Settings** tab, in the **Members** card, type the person's
|
|
18
|
+
full email address and add them. People outside Monks are always added as
|
|
19
|
+
**viewers**: they can open the app and nothing that manages it. You can give
|
|
20
|
+
them [app roles](https://docs.canopy.website/guides/roles) like anyone else.
|
|
21
|
+
|
|
22
|
+
The owner, managers and platform admins can invite outsiders. Each invitation
|
|
23
|
+
is recorded under the person who sent it.
|
|
24
|
+
|
|
25
|
+
They get an email naming the project and who added them, with a link to it.
|
|
26
|
+
If the email didn't go out, the Members card says so and lets you send it
|
|
27
|
+
again. The card marks outside members and invitations so you can tell them
|
|
28
|
+
apart from colleagues.
|
|
29
|
+
|
|
30
|
+
## What they see
|
|
31
|
+
|
|
32
|
+
When they open the project's link, the sign-in page offers **Not at Monks?
|
|
33
|
+
Sign in with email**. They type their address and get an email with a link and
|
|
34
|
+
a 6-digit code. Either one signs them in:
|
|
35
|
+
|
|
36
|
+
- the **link** works on any device, after they click **Continue**;
|
|
37
|
+
- the **code** works in the browser where they asked for it.
|
|
38
|
+
|
|
39
|
+
Both expire after 15 minutes and work once. The first time, they're asked for
|
|
40
|
+
their name.
|
|
41
|
+
|
|
42
|
+
Once in, they use your app like any viewer. They can't open the Canopy
|
|
43
|
+
dashboard, use the CLI, file feedback through the widget, or open any other
|
|
44
|
+
project unless it was shared with them too. If they follow a link to a project
|
|
45
|
+
that isn't shared with them, they see a page saying so, with nothing about
|
|
46
|
+
that project on it.
|
|
47
|
+
|
|
48
|
+
Only people who were invited to that project get a sign-in email. Anyone else
|
|
49
|
+
who types an address sees the same "check your email" page and nothing is sent.
|
|
50
|
+
|
|
51
|
+
## How long a sign-in lasts
|
|
52
|
+
|
|
53
|
+
A sign-in lasts 7 days from the last time they used it, and at most 30 days in
|
|
54
|
+
total. It survives closing the browser and restarting the computer. After that
|
|
55
|
+
they sign in with email again. Signing out (`auth.logout()` in your app, or the
|
|
56
|
+
sign-out link) ends it on that browser only.
|
|
57
|
+
|
|
58
|
+
## In your code
|
|
59
|
+
|
|
60
|
+
To your app, an outside member is an `external` caller with a real email and an
|
|
61
|
+
id that stays the same every time they sign in. `auth.user()` and
|
|
62
|
+
`env.CALLER` both carry them; `env.USER` stays `null`, as it is for everyone
|
|
63
|
+
outside Monks. They get the project's default app role plus any you assigned.
|
|
64
|
+
See [Auth](https://docs.canopy.website/sdk/auth).
|
|
65
|
+
|
|
66
|
+
## Removing someone
|
|
67
|
+
|
|
68
|
+
Remove them from the **Members** card like anyone else. Their access to the
|
|
69
|
+
project ends on their next page load. A platform admin can also sign an outside
|
|
70
|
+
account out everywhere, or remove it from every project at once, from the
|
|
71
|
+
admin **Users** page.
|
|
72
|
+
|
|
73
|
+
## Compared with client passwords
|
|
74
|
+
|
|
75
|
+
A [client password](https://docs.canopy.website/platform/client-access) is one shared secret for one
|
|
76
|
+
project, good for a quick preview. Outside members are better when the same
|
|
77
|
+
people come back, use several of your tools, or need their own roles. A project
|
|
78
|
+
can use both: an outside member of a password-protected project gets in with
|
|
79
|
+
their own sign-in and doesn't need the password.
|
|
@@ -88,9 +88,10 @@ whether your app is a good fit.
|
|
|
88
88
|
|
|
89
89
|
## Can it deploy automatically when we change the code?
|
|
90
90
|
|
|
91
|
-
Yes.
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
Yes. On GitHub, link the repository once with `canopy repo link`, and every
|
|
92
|
+
push to its main branch ships a new version, with no secret to manage. Other
|
|
93
|
+
CI systems use a deploy token, which can only deploy that one project — it
|
|
94
|
+
can't touch your data. See the [CI guide](https://docs.canopy.website/guides/ci).
|
|
94
95
|
|
|
95
96
|
## What if my project outgrows Canopy?
|
|
96
97
|
|
|
@@ -42,6 +42,11 @@ access off entirely, remove the password from the same card, or switch the
|
|
|
42
42
|
mode back to Monks only; either way, visitors are back to Monks-only
|
|
43
43
|
immediately, unlocked browsers included.
|
|
44
44
|
|
|
45
|
+
If the same people keep coming back, or need their own app roles, invite them
|
|
46
|
+
by email instead: each gets their own sign-in, and you can remove one person
|
|
47
|
+
without changing anything for the rest. See
|
|
48
|
+
[Sharing a project with people outside Monks](https://docs.canopy.website/guides/outside-sign-in).
|
|
49
|
+
|
|
45
50
|
> **Warning:** A shared password is deliberately lightweight protection — right for work-in-progress previews,
|
|
46
51
|
> wrong for anything sensitive. Anyone who has it can view the app and share it further, so rotate
|
|
47
52
|
> it when a review round ends.
|
|
@@ -71,4 +76,5 @@ name them `private_…` so only the worker can reach them, or set browser
|
|
|
71
76
|
access to read only or off. See
|
|
72
77
|
[Who can call this from the browser](https://docs.canopy.website/sdk/database#who-can-call-this-from-the-browser).
|
|
73
78
|
|
|
79
|
+
- [Sharing with people outside Monks](https://docs.canopy.website/guides/outside-sign-in) — Invite client contacts by email so each gets their own sign-in.
|
|
74
80
|
- [Members & access](https://docs.canopy.website/platform/members-and-access) — Who can view and who can manage a project, and how to tighten it.
|