@coffre/cli 0.1.1 → 0.1.2

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 CHANGED
@@ -4,11 +4,14 @@ The `coffre` command: secrets in your shell, and a new deployment.
4
4
 
5
5
  ```sh
6
6
  npx @coffre/cli init --workers my-coffre # or --node
7
+ npx @coffre/cli setup # its database logins, migrations and keys
7
8
  coffre login https://secrets.acme.example
8
9
  coffre run market/prod -- node server.js
9
10
  ```
10
11
 
11
- It bundles everything it runs, so it installs with no dependencies.
12
+ It bundles everything it runs, so it installs with no dependencies:
13
+ `setup` brings its own Postgres driver and coffre's migrations, at the
14
+ CLI's version.
12
15
 
13
16
  Part of [coffre](https://github.com/erwinkn/coffre), a secrets manager you
14
17
  deploy as a small project of your own. Its eight `@coffre/*` packages are
@@ -0,0 +1,74 @@
1
+ //#region ../core/dist/access.js
2
+ /**
3
+ * Who may do what: seven permissions and the six roles that bundle them.
4
+ *
5
+ * Deliberately constants and not tables or a policy language. A grant names
6
+ * one role for one member on one place, and a check is a lookup in this file,
7
+ * so authorisation stays something you can read end to end.
8
+ */
9
+ const PERMISSIONS = [
10
+ "secret.read",
11
+ "secret.write",
12
+ "secret.archive",
13
+ "audit.read",
14
+ "environment.manage",
15
+ "grant.manage",
16
+ "project.manage"
17
+ ];
18
+ /**
19
+ * Permissions that only make sense on a project. Granting
20
+ * `environment.manage` on one environment would be incoherent: what it
21
+ * authorises is creating that environment's siblings.
22
+ */
23
+ const PROJECT_ONLY_PERMISSIONS = [
24
+ "environment.manage",
25
+ "grant.manage",
26
+ "project.manage"
27
+ ];
28
+ const ROLES = {
29
+ viewer: {
30
+ name: "Viewer",
31
+ description: "Read secret values.",
32
+ permissions: ["secret.read"]
33
+ },
34
+ developer: {
35
+ name: "Developer",
36
+ description: "Read and write secrets.",
37
+ permissions: ["secret.read", "secret.write"]
38
+ },
39
+ maintainer: {
40
+ name: "Maintainer",
41
+ description: "Read, write and retire secrets, and manage environments.",
42
+ permissions: [
43
+ "secret.read",
44
+ "secret.write",
45
+ "secret.archive",
46
+ "environment.manage"
47
+ ]
48
+ },
49
+ "access-manager": {
50
+ name: "Access manager",
51
+ description: "Manage who has access. Cannot read secret values.",
52
+ permissions: ["grant.manage"]
53
+ },
54
+ auditor: {
55
+ name: "Auditor",
56
+ description: "Read the audit log. Cannot read secret values.",
57
+ permissions: ["audit.read"]
58
+ },
59
+ owner: {
60
+ name: "Owner",
61
+ description: "Everything, including reading secret values.",
62
+ permissions: [...PERMISSIONS]
63
+ }
64
+ };
65
+ const ROLE_NAMES = Object.keys(ROLES);
66
+ function isRole(value) {
67
+ return Object.hasOwn(ROLES, value);
68
+ }
69
+ /** Roles that hold a project-only permission can only be granted on a project. */
70
+ function assignableToEnvironment(role) {
71
+ return !ROLES[role].permissions.some((permission) => PROJECT_ONLY_PERMISSIONS.includes(permission));
72
+ }
73
+ //#endregion
74
+ export { isRole as i, ROLE_NAMES as n, assignableToEnvironment as r, ROLES as t };