feat(GRO-566): add SKIP_OOBE env var to bypass setup wizard
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -11,6 +11,12 @@ AUTH_DISABLED=false
|
|||||||
OIDC_ISSUER=https://authentik.example.com
|
OIDC_ISSUER=https://authentik.example.com
|
||||||
OIDC_AUDIENCE=groombook
|
OIDC_AUDIENCE=groombook
|
||||||
|
|
||||||
|
# ── Setup Wizard ─────────────────────────────────────────────────────────────
|
||||||
|
# When SKIP_OOBE=true, the setup wizard is bypassed regardless of whether a
|
||||||
|
# super user exists in the database. Useful in dev/test environments where the
|
||||||
|
# database has data but the setup wizard would otherwise block access.
|
||||||
|
SKIP_OOBE=false
|
||||||
|
|
||||||
# ── API ───────────────────────────────────────────────────────────────────────
|
# ── API ───────────────────────────────────────────────────────────────────────
|
||||||
PORT=3000
|
PORT=3000
|
||||||
CORS_ORIGIN=http://localhost:8080
|
CORS_ORIGIN=http://localhost:8080
|
||||||
|
|||||||
@@ -418,6 +418,48 @@ describe("GET /setup/status — OOBE bootstrap logic", () => {
|
|||||||
expect(body.showAuthProviderStep).toBe(false); // DB config already exists
|
expect(body.showAuthProviderStep).toBe(false); // DB config already exists
|
||||||
expect(body.authConfigExists).toBe(true);
|
expect(body.authConfigExists).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("SKIP_OOBE=true bypasses setup check regardless of DB state", async () => {
|
||||||
|
dbStaffRows = []; // no super user
|
||||||
|
dbAuthConfigRows = [];
|
||||||
|
process.env.SKIP_OOBE = "true";
|
||||||
|
|
||||||
|
const app = makeApp();
|
||||||
|
const { status, body } = await getStatus(app);
|
||||||
|
|
||||||
|
expect(status).toBe(200);
|
||||||
|
expect(body.needsSetup).toBe(false);
|
||||||
|
expect(body.showAuthProviderStep).toBe(false);
|
||||||
|
expect(body.authConfigExists).toBe(false);
|
||||||
|
expect(body.authEnvVarsSet).toBe(false);
|
||||||
|
expect(body.skipped).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("SKIP_OOBE=1 also bypasses setup check", async () => {
|
||||||
|
dbStaffRows = [];
|
||||||
|
dbAuthConfigRows = [];
|
||||||
|
process.env.SKIP_OOBE = "1";
|
||||||
|
|
||||||
|
const app = makeApp();
|
||||||
|
const { status, body } = await getStatus(app);
|
||||||
|
|
||||||
|
expect(status).toBe(200);
|
||||||
|
expect(body.needsSetup).toBe(false);
|
||||||
|
expect(body.skipped).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("SKIP_OOBE=yes also bypasses setup check", async () => {
|
||||||
|
dbStaffRows = [];
|
||||||
|
dbAuthConfigRows = [];
|
||||||
|
process.env.SKIP_OOBE = "yes";
|
||||||
|
|
||||||
|
const app = makeApp();
|
||||||
|
const { status, body } = await getStatus(app);
|
||||||
|
|
||||||
|
expect(status).toBe(200);
|
||||||
|
expect(body.needsSetup).toBe(false);
|
||||||
|
expect(body.skipped).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("POST /setup/auth-provider — OOBE bootstrap", () => {
|
describe("POST /setup/auth-provider — OOBE bootstrap", () => {
|
||||||
|
|||||||
@@ -9,6 +9,17 @@ export const setupRouter = new Hono<AppEnv>();
|
|||||||
// GET /api/setup/status — public (no auth), returns whether setup is needed
|
// GET /api/setup/status — public (no auth), returns whether setup is needed
|
||||||
// and whether the auth provider bootstrap step should be shown
|
// and whether the auth provider bootstrap step should be shown
|
||||||
setupRouter.get("/status", async (c) => {
|
setupRouter.get("/status", async (c) => {
|
||||||
|
const skipOobe = ["true", "1", "yes"].includes((process.env.SKIP_OOBE || "").toLowerCase());
|
||||||
|
if (skipOobe) {
|
||||||
|
return c.json({
|
||||||
|
needsSetup: false,
|
||||||
|
showAuthProviderStep: false,
|
||||||
|
authConfigExists: false,
|
||||||
|
authEnvVarsSet: false,
|
||||||
|
skipped: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const db = getDb();
|
const db = getDb();
|
||||||
|
|
||||||
// Check if any super user exists
|
// Check if any super user exists
|
||||||
|
|||||||
Reference in New Issue
Block a user