@everystack/server 0.4.37 → 0.4.38
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/CHANGELOG.md +27 -0
- package/package.json +11 -3
- package/src/cache-control.ts +36 -0
- package/src/index.ts +7 -1
- package/src/kvs-metrics.ts +153 -0
- package/src/kvs.ts +326 -29
- package/src/plugin.ts +7 -1
- package/src/provision.ts +97 -1
- package/src/purge-graph.ts +91 -0
- package/src/purge-log.ts +63 -0
- package/src/purge.ts +337 -0
- package/src/role-chain.ts +26 -0
package/src/role-chain.ts
CHANGED
|
@@ -168,6 +168,32 @@ export function generateReaderRoleSQL(options: ReaderRoleOptions = {}): string {
|
|
|
168
168
|
].join('\n') + '\n';
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
/**
|
|
172
|
+
* The reserved role `lifecycle: true` models compile grants and policies to, and that owns their
|
|
173
|
+
* SECURITY DEFINER functions. Equal to LIFECYCLE_OWNER_ROLE in @everystack/model (this package
|
|
174
|
+
* keeps no dependency on it).
|
|
175
|
+
*/
|
|
176
|
+
export const LIFECYCLE_ROLE = 'everystack_lifecycle';
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Generate idempotent DDL for the reserved lifecycle role: create it if absent, then re-assert
|
|
180
|
+
* its attributes so a hand-made role is brought into line.
|
|
181
|
+
*
|
|
182
|
+
* - NOLOGIN — no one connects as it. It is a function owner and a grantee, not an identity.
|
|
183
|
+
* - NOINHERIT — it never ambiently gains another role's privileges.
|
|
184
|
+
* - NOBYPASSRLS — its reads and writes go through the policies the compiler writes for it.
|
|
185
|
+
*
|
|
186
|
+
* It grants the role NOTHING and grants it TO no one. Membership is SET ROLE, and SET ROLE to it
|
|
187
|
+
* passes the lifecycle guard, so no tool hands membership out here (db:provision reports members).
|
|
188
|
+
*/
|
|
189
|
+
export function generateLifecycleRoleSQL(role: string = LIFECYCLE_ROLE): string {
|
|
190
|
+
assertIdent(role, 'lifecycle role');
|
|
191
|
+
return [
|
|
192
|
+
`DO $$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '${role}') THEN CREATE ROLE ${role} NOLOGIN NOINHERIT NOBYPASSRLS; END IF; END $$;`,
|
|
193
|
+
`ALTER ROLE ${role} WITH NOLOGIN NOINHERIT NOBYPASSRLS;`,
|
|
194
|
+
].join('\n') + '\n';
|
|
195
|
+
}
|
|
196
|
+
|
|
171
197
|
export interface ReaderGrantOptions {
|
|
172
198
|
/** The SELECT-only login the grants are made TO. Default 'reader'. */
|
|
173
199
|
readerRole?: string;
|