mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 10:07:19 +01:00
Loki has run on AccountKit since 2026-11-01. The runtime mounts the shared sign-in (`bitbaum-signin`, SIGNIN_*) from env, and the compat layer can start it, but Loki's sign-in and sign-up pages had no button for it. The deploy check also expected only "email-password" on this runtime, so OrangeCat could vanish from /api/auth/providers without failing a deploy. - getEnabledAuthProviders().signin is AccountKit's signinBroker(env), on the AccountKit runtime only. Sign-in and sign-up show "Continue with Google, Apple, GitHub, X or Facebook" (AccountKit's own label) next to OrangeCat, started through next-auth/react like OrangeCat. - scripts/expected-auth-providers.ts expects, on AccountKit, the password form plus every OIDC client AccountKit mounts (oidcClients): orangecat with ORANGECAT_OAUTH_*, bitbaum-signin with SIGNIN_*. On Auth.js it behaves as before. - deploy-hetzner.sh reads the box's OIDC env for it from /opt/fleet/env and the app .env, a non-empty app line winning as in launch.sh. The issuers and client ids are passed as they are; each secret is passed only as "set". - scripts/test/deploy-expected-providers.ts covers both runtimes and the button. Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9 Co-authored-by: Claude <noreply@anthropic.com>
84 lines
2.7 KiB
TypeScript
84 lines
2.7 KiB
TypeScript
// The deploy's provider check (scripts/expected-auth-providers.ts) expects what
|
|
// the runtime actually mounts, and the sign-in pages show the shared sign-in
|
|
// exactly when AccountKit mounts it.
|
|
// Run: npx tsx scripts/test/deploy-expected-providers.ts
|
|
import { expectedAuthProviders } from "../expected-auth-providers";
|
|
import { getEnabledAuthProviders, PAUSED_PROVIDERS, sharedSigninLabel } from "@/lib/auth-providers";
|
|
|
|
let pass = 0,
|
|
fail = 0;
|
|
function ok(name: string, cond: boolean) {
|
|
if (cond) {
|
|
pass++;
|
|
console.log(` ✓ ${name}`);
|
|
} else {
|
|
fail++;
|
|
console.log(` ✗ ${name}`);
|
|
}
|
|
}
|
|
|
|
const ORANGECAT = {
|
|
ORANGECAT_OAUTH_ISSUER: "https://orangecat.ch",
|
|
ORANGECAT_OAUTH_CLIENT_ID: "loki",
|
|
ORANGECAT_OAUTH_CLIENT_SECRET: "set",
|
|
};
|
|
const SIGNIN = {
|
|
SIGNIN_ISSUER: "https://signin.example.test",
|
|
SIGNIN_CLIENT_ID: "loki",
|
|
SIGNIN_CLIENT_SECRET: "set",
|
|
};
|
|
const same = (a: string[], b: string[]) => a.join(" ") === b.join(" ");
|
|
|
|
ok(
|
|
"Auth.js: the unpaused social providers and the password form",
|
|
same(expectedAuthProviders({}), [
|
|
...(["github", "google", "x"] as const)
|
|
.filter((p) => !PAUSED_PROVIDERS[p])
|
|
.map((p) => (p === "x" ? "x-1a" : p)),
|
|
"email-password",
|
|
]),
|
|
);
|
|
ok(
|
|
"AccountKit, no OIDC env: the password form only",
|
|
same(expectedAuthProviders({ AUTH_RUNTIME: "accountkit" }), ["email-password"]),
|
|
);
|
|
ok(
|
|
"AccountKit with OrangeCat: OrangeCat is expected",
|
|
same(expectedAuthProviders({ AUTH_RUNTIME: "accountkit", ...ORANGECAT }), [
|
|
"email-password",
|
|
"orangecat",
|
|
]),
|
|
);
|
|
ok(
|
|
"AccountKit with both: the shared sign-in is expected too",
|
|
same(expectedAuthProviders({ AUTH_RUNTIME: "accountkit", ...ORANGECAT, ...SIGNIN }), [
|
|
"email-password",
|
|
"bitbaum-signin",
|
|
"orangecat",
|
|
]),
|
|
);
|
|
ok(
|
|
"AccountKit, shared sign-in without its secret: not expected",
|
|
same(expectedAuthProviders({ AUTH_RUNTIME: "accountkit", ...SIGNIN, SIGNIN_CLIENT_SECRET: "" }), [
|
|
"email-password",
|
|
]),
|
|
);
|
|
|
|
const saved = { ...process.env };
|
|
Object.assign(process.env, SIGNIN);
|
|
delete process.env.AUTH_RUNTIME;
|
|
ok("Auth.js: no shared sign-in button (nothing mounts it)", !getEnabledAuthProviders().signin);
|
|
process.env.AUTH_RUNTIME = "accountkit";
|
|
const enabled = getEnabledAuthProviders();
|
|
ok("AccountKit with SIGNIN_*: the shared sign-in button shows", enabled.signin);
|
|
ok(
|
|
"the button uses AccountKit's own words",
|
|
sharedSigninLabel(enabled) === "Continue with Google, Apple, GitHub, X or Facebook",
|
|
);
|
|
process.env.SIGNIN_CLIENT_SECRET = "";
|
|
ok("a missing secret hides it", sharedSigninLabel(getEnabledAuthProviders()) === null);
|
|
process.env = saved;
|
|
|
|
console.log(`\n${pass} passed, ${fail} failed`);
|
|
if (fail) process.exit(1);
|