Codex/sakani security #2
No files matched your search
@@ -14,6 +14,9 @@
|
||||
!src/**/*.css
|
||||
!src/modules/pdf/fonts/*.ttf
|
||||
!src/modules/pdf/fonts/LICENSE.txt
|
||||
# The production TypeScript build only needs application sources.
|
||||
src/**/*.test.ts
|
||||
src/**/*.test.tsx
|
||||
!public/
|
||||
!public/brand/
|
||||
!public/brand/logo-black.png
|
||||
|
||||
+8
-8
@@ -16,26 +16,26 @@
|
||||
"test:e2e": "playwright test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@better-auth/drizzle-adapter": "^1.6.26",
|
||||
"@better-auth/drizzle-adapter": "^1.7.29",
|
||||
"@fontsource-variable/geist": "^5.3.0",
|
||||
"@js-temporal/polyfill": "^0.5.1",
|
||||
"@radix-ui/react-slot": "^1.3.3",
|
||||
"@sakaniui/react": "^0.23.0",
|
||||
"archiver": "^8.0.0",
|
||||
"better-auth": "^1.6.26",
|
||||
"better-auth": "^1.7.29",
|
||||
"clsx": "^2.1.1",
|
||||
"drizzle-orm": "^0.45.2",
|
||||
"next": "^16.3.0",
|
||||
"next": "^16.4.6",
|
||||
"next-themes": "^0.4.6",
|
||||
"nodemailer": "^9.0.5",
|
||||
"nodemailer": "^10.6.2",
|
||||
"pdfmake": "~0.3.11",
|
||||
"pg": "^8.22.0",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
"server-only": "^0.0.1",
|
||||
"sharp": "^0.35.3",
|
||||
"sharp": "^0.35.6",
|
||||
"tailwind-merge": "^3.6.0",
|
||||
"zod": "^4.4.3"
|
||||
"zod": "^4.6.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.50.0",
|
||||
@@ -53,7 +53,7 @@
|
||||
"@vitejs/plugin-react": "^6.0.5",
|
||||
"drizzle-kit": "^0.31.10",
|
||||
"eslint": "^9.39.5",
|
||||
"eslint-config-next": "^16.3.0",
|
||||
"eslint-config-next": "^16.4.6",
|
||||
"jsdom": "^30.0.1",
|
||||
"msw": "^2.15.0",
|
||||
"pdfjs-dist": "^6.2.108",
|
||||
@@ -61,6 +61,6 @@
|
||||
"testcontainers": "^12.1.0",
|
||||
"tsx": "^4.23.11",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^4.1.10"
|
||||
"vitest": "^4.1.12"
|
||||
}
|
||||
}
|
||||
Generated
+637
-726
File diff suppressed because it is too large.
Load diff
@@ -4,3 +4,15 @@ allowBuilds:
|
||||
protobufjs: false
|
||||
ssh2: false
|
||||
unrs-resolver: true
|
||||
|
||||
overrides:
|
||||
"@grpc/grpc-js@1.14.4": 1.14.7
|
||||
brace-expansion@1.1.18: 1.1.22
|
||||
brace-expansion@2.1.4: 2.1.8
|
||||
brace-expansion@5.0.9: 5.0.12
|
||||
"@esbuild-kit/core-utils>esbuild": 0.25.12
|
||||
js-yaml@4.3.1: 4.3.2
|
||||
"readdir-glob@3>minimatch": 11.0.9
|
||||
source-map-js@1.2.1: 1.2.2
|
||||
undici@8.10.0: 8.12.4
|
||||
vite@8.2.1: 8.2.4
|
||||
@@ -24,14 +24,19 @@ export function TwoFactorWizard({ initiallyEnabled }: { initiallyEnabled: boolea
|
||||
const password = readPassword(event.currentTarget);
|
||||
|
||||
try {
|
||||
const result = await authClient.twoFactor.enable({ password });
|
||||
const result = await authClient.twoFactor.enable({ password, method: "totp" });
|
||||
if (result.error) {
|
||||
setError(twoFactorErrorMessage(result.error.code));
|
||||
return;
|
||||
}
|
||||
const uri = result.data?.totpURI;
|
||||
setSecret(uri ? new URL(uri).searchParams.get("secret") ?? undefined : undefined);
|
||||
setBackupCodes(result.data?.backupCodes ?? []);
|
||||
if (result.data?.method !== "totp") {
|
||||
setError("Das Einrichten ist fehlgeschlagen. Bitte versuchen Sie es erneut.");
|
||||
return;
|
||||
}
|
||||
const setupSecret = new URL(result.data.totpURI).searchParams.get("secret");
|
||||
if (!setupSecret) throw new Error("Missing TOTP secret");
|
||||
setSecret(setupSecret);
|
||||
setBackupCodes(result.data.backupCodes);
|
||||
setStep("scan");
|
||||
} catch {
|
||||
setError("Das Einrichten ist fehlgeschlagen. Bitte versuchen Sie es erneut.");
|
||||
|
||||
@@ -137,9 +137,10 @@ test("Better Auth grants admin access only to the session that completed MFA", a
|
||||
verification: [],
|
||||
twoFactor: [] as Array<{ secret: string }>,
|
||||
};
|
||||
const sendPasswordReset = vi.fn<(input: { to: string; resetUrl: string }) => Promise<void>>();
|
||||
const { auth } = createPortalAuth({
|
||||
database: memoryAdapter(state),
|
||||
mailerService: { sendPasswordReset: vi.fn(), sendVerification: vi.fn() },
|
||||
mailerService: { sendPasswordReset, sendVerification: vi.fn() },
|
||||
registrationRepository: {
|
||||
createEditorial: vi.fn(), markPendingApproval: vi.fn(), removeUnverifiedAuthIdentity: vi.fn(),
|
||||
recordRegistrationCompensationFailure: vi.fn(), recordVerificationInconsistency: vi.fn(),
|
||||
@@ -171,9 +172,10 @@ test("Better Auth grants admin access only to the session that completed MFA", a
|
||||
const first = responseCookie(await login(), "session_token");
|
||||
const second = responseCookie(await login(), "session_token");
|
||||
expect(first).not.toEqual(second);
|
||||
const setup = await post("two-factor/enable", { password }, first);
|
||||
const setup = await post("two-factor/enable", { password, method: "totp" }, first);
|
||||
expect(setup.status).toBe(200);
|
||||
const { backupCodes } = await setup.json();
|
||||
const { method, backupCodes } = await setup.json();
|
||||
expect(method).toBe("totp");
|
||||
const secret = await symmetricDecrypt({
|
||||
key: (await auth.$context).secretConfig, data: state.twoFactor[0].secret,
|
||||
});
|
||||
@@ -200,6 +202,25 @@ test("Better Auth grants admin access only to the session that completed MFA", a
|
||||
await expect(guard.requireAdmin(headers(responseCookie(backup, "session_token"))))
|
||||
.resolves.toMatchObject({ userId });
|
||||
|
||||
expect((await post("two-factor/disable", { password }, signedInCookie)).status).toBe(200);
|
||||
const disabled = await post("two-factor/disable", { password }, signedInCookie);
|
||||
expect(disabled.status).toBe(200);
|
||||
expect(await auth.api.getSession({ headers: headers(rotated) })).toBeNull();
|
||||
const preResetCookie = responseCookie(disabled, "session_token");
|
||||
|
||||
const resetRequest = await post("request-password-reset", {
|
||||
email, redirectTo: "http://localhost:3000/passwort-zuruecksetzen",
|
||||
});
|
||||
expect(resetRequest.status).toBe(200);
|
||||
expect(sendPasswordReset).toHaveBeenCalledOnce();
|
||||
const resetUrl = new URL(sendPasswordReset.mock.calls[0][0].resetUrl);
|
||||
const token = resetUrl.pathname.split("/").at(-1);
|
||||
const newPassword = "dummy-updated-admin-password";
|
||||
expect((await post("reset-password", { token, newPassword })).status).toBe(200);
|
||||
expect(await auth.api.getSession({ headers: headers(preResetCookie) })).toBeNull();
|
||||
|
||||
const afterReset = responseCookie(await post("sign-in/email", { email, password: newPassword }), "session_token");
|
||||
const signedOut = await post("sign-out", {}, afterReset);
|
||||
expect(signedOut.status).toBe(200);
|
||||
await expect(signedOut.json()).resolves.toMatchObject({ success: true });
|
||||
expect(await auth.api.getSession({ headers: headers(afterReset) })).toBeNull();
|
||||
});
|
||||
@@ -116,10 +116,21 @@ test("server-rendered login and reset forms use POST for native submissions", as
|
||||
|
||||
test("the enrollment confirmation code form uses POST", async () => {
|
||||
const { TwoFactorWizard } = await import("@/app/zwei-faktor/wizard");
|
||||
enableTwoFactor.mockResolvedValueOnce({ data: { totpURI: "otpauth://totp/dummy?secret=DUMMY", backupCodes: [] } });
|
||||
enableTwoFactor.mockResolvedValueOnce({ data: { method: "totp", totpURI: "otpauth://totp/dummy?secret=DUMMY", backupCodes: [] } });
|
||||
render(<TwoFactorWizard initiallyEnabled={false} />);
|
||||
fireEvent.submit(screen.getByRole("button", { name: "Einrichtung starten" }).closest("form")!);
|
||||
expect(enableTwoFactor).toHaveBeenCalledWith({ password: "", method: "totp" });
|
||||
const field = await screen.findByLabelText<HTMLInputElement>("Code aus der App");
|
||||
expect(field.form?.method).toBe("post");
|
||||
expect([...new FormData(field.form!).keys()]).toEqual([]);
|
||||
});
|
||||
|
||||
test("reports a non-TOTP setup response and leaves enrollment retryable", async () => {
|
||||
const { TwoFactorWizard } = await import("@/app/zwei-faktor/wizard");
|
||||
enableTwoFactor.mockResolvedValueOnce({ data: { method: "otp" } });
|
||||
render(<TwoFactorWizard initiallyEnabled={false} />);
|
||||
const button = screen.getByRole("button", { name: "Einrichtung starten" });
|
||||
fireEvent.submit(button.closest("form")!);
|
||||
expect((await screen.findByRole("alert")).textContent).toMatch(/fehlgeschlagen/i);
|
||||
expect((screen.getByRole("button", { name: "Einrichtung starten" }) as HTMLButtonElement).disabled).toBe(false);
|
||||
});
|
||||
Reference in new issue
Block a user