;
};
/** Ensures that Firestore is shutdown at command termination
*
* This prevents Firestore from holding the command on execution completion or failure.
*/
-export const guard =
+export const fsShutdownGuard =
(cb: (args: P) => Promise) =>
async (args: P) => {
try {
await cb(args);
} finally {
- void terminate(FIRESTORE);
+ if (bootstrapFirestore) void terminate(bootstrapFirestore);
+ if (firestore) void terminate(firestore);
}
};
diff --git a/src/plugins/google/login.ts b/src/plugins/google/login.ts
index 089654a..93c2c07 100644
--- a/src/plugins/google/login.ts
+++ b/src/plugins/google/login.ts
@@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with @p0
import { OIDC_HEADERS } from "../../common/auth/oidc";
import { withRedirectServer } from "../../common/auth/server";
import { urlEncode, validateResponse } from "../../common/fetch";
-import { config } from "../../drivers/env";
+import { getTenantConfig } from "../../drivers/config";
import { print2 } from "../../drivers/stdio";
import { AuthorizeRequest, TokenResponse } from "../../types/oidc";
import open from "open";
@@ -28,10 +28,11 @@ const GOOGLE_OIDC_REDIRECT_URL = `http://127.0.0.1:${GOOGLE_OIDC_REDIRECT_PORT}`
const PKCE_LENGTH = 128;
const requestAuth = async () => {
+ const tenantConfig = getTenantConfig();
const pkceChallenge = (await import("pkce-challenge")).default as any;
const pkce = await pkceChallenge(PKCE_LENGTH);
const authBody: AuthorizeRequest = {
- client_id: config.google.clientId,
+ client_id: tenantConfig.google.clientId,
code_challenge: pkce.code_challenge,
code_challenge_method: "S256",
redirect_uri: GOOGLE_OIDC_REDIRECT_URL,
@@ -51,9 +52,10 @@ const requestToken = async (
code: string,
pkce: { code_challenge: string; code_verifier: string }
) => {
+ const tenantConfig = getTenantConfig();
const body = {
- client_id: config.google.clientId,
- client_secret: config.google.clientSecret,
+ client_id: tenantConfig.google.clientId,
+ client_secret: tenantConfig.google.clientSecret,
code,
code_verifier: pkce.code_verifier,
grant_type: "authorization_code",
diff --git a/src/types/org.ts b/src/types/org.ts
index 02868a2..86481db 100644
--- a/src/types/org.ts
+++ b/src/types/org.ts
@@ -8,6 +8,9 @@ This file is part of @p0security/cli
You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see .
**/
+import { bootstrapConfig } from "../drivers/env";
+
+export type Config = typeof bootstrapConfig;
type BaseOrgData = {
clientId: string;
@@ -21,6 +24,7 @@ type BaseOrgData = {
| "oidc-pkce"
| "okta";
tenantId: string;
+ config: Config;
};
/** Publicly readable organization data */
diff --git a/src/util.ts b/src/util.ts
index 68dfd3e..3b4f51c 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -8,14 +8,16 @@ This file is part of @p0security/cli
You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see .
**/
-import { config } from "./drivers/env";
+import { bootstrapConfig } from "./drivers/env";
import child_process from "node:child_process";
import os from "node:os";
import path from "node:path";
export const P0_PATH = path.join(
os.homedir(),
- config.environment === "production" ? ".p0" : `.p0-${config.environment}`
+ bootstrapConfig.environment === "production"
+ ? ".p0"
+ : `.p0-${bootstrapConfig.environment}`
);
/** Waits the specified delay (in ms)