Reviewed-on: https://forgejo.dunemask.dev///elysium/cairo/pulls/2 Co-authored-by: Dunemask <dunemask@gmail.com> Co-committed-by: Dunemask <dunemask@gmail.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import DefaultRolePolicies from "./vix/AppPolicies";
|
|
|
|
const REQUIRED_ENV: string[] = [
|
|
"CAIRO_POSTGRES_URI", // Used for postgres connections
|
|
"CAIRO_KEYPAIR_KEY", // Used for encrypting and decrypting keypair keys
|
|
];
|
|
|
|
const decodeEnvar = <T extends string | undefined>(e: T) => (!!e ? Buffer.from(e, "base64").toString("utf8") : e) as T;
|
|
export function assertRequiredEnvars() {
|
|
for (const envar of Object.values(REQUIRED_ENV)) if (!process.env[envar]) throw Error(`Envar ${envar} is required!`);
|
|
}
|
|
const ENV = process.env as { [key in (typeof REQUIRED_ENV)[number]]: string } & Record<string, string | null>;
|
|
|
|
export default {
|
|
Server: {
|
|
basePath: "/cairo/",
|
|
projectSlug: "$cairo",
|
|
projectName: "$cairo",
|
|
rootPassword: process.env.CAIRO_ROOT_PASSWORD,
|
|
},
|
|
RolePolicy: {
|
|
Root: {
|
|
id: "ck1ro7ekp000203zu5gn3d9cr",
|
|
name: "Root",
|
|
policies: DefaultRolePolicies.Root,
|
|
},
|
|
Admin: {
|
|
id: "ck1ro7bm0000103z5h45sswqs",
|
|
name: "Admin",
|
|
policies: DefaultRolePolicies.Admin,
|
|
},
|
|
User: {
|
|
id: "ck1ro7g3e000303z52ee63nqs",
|
|
name: "User",
|
|
policies: DefaultRolePolicies.User,
|
|
},
|
|
},
|
|
SigningOptions: {
|
|
HashRounds: 14,
|
|
Version: "0.0.1-alpha",
|
|
Issuer: process.env.CAIRO_HOSTNAME ?? "https://cairo.dunemask.net",
|
|
Keys: {
|
|
KeyPair: decodeEnvar(ENV.CAIRO_KEYPAIR_KEY),
|
|
},
|
|
Subjects: {
|
|
User: "user",
|
|
Cargo: "cargo",
|
|
Runner: "runner",
|
|
Pod: "pod",
|
|
},
|
|
},
|
|
};
|