feat: verify email addresses and recover forgotten passwords
Ekklesia could authenticate a person and, since Pass 1, send a transactional email — but it had no way to establish that an address belonged to whoever claimed it, and no way back in for someone who forgot their password. A verified address is now a precondition for holding a session. Better Auth enforces that after the password check and before any session exists, so an unverified sign-in returns 403 with no cookie. That is why no "unverified principal" was needed: a correct password on an unverified address carries exactly the authority of no password, and /api/v1/principal is unchanged. Better Auth keeps every token. Ekklesia adds no token table, no hashing, and no expiry clock. It supplies a recipient, a subject, and two bodies, and the mail provider supplies everything about SMTP. Verification and reset links are rebuilt from a validated Dashboard origin, taking only the token — never the URL Better Auth prebuilds from a caller-supplied callbackURL — so no request can steer where a recipient lands. Following a verification link mints no session, because mail infrastructure dereferences links. Reset revokes that person's other sessions and leaves managed devices alone. Recovery answers identically for an address with an account, without one, already verified, or undeliverable — including when SMTP is broken, which is why the delivery adapter never throws. The initial platform owner is the one exception: created already verified by an operator command with no mail prerequisite, so a fresh server can be signed in to before a relay exists. Migration 0007 extends that to owners of installations that already exist. Public signup stays disabled; verification is not a licence to self-register. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
3581ad7c8e
commit
ea28f8aa2e
@@ -42,30 +42,42 @@ async function readTextFiles(directory: string): Promise<Array<{ path: string; t
|
||||
}
|
||||
|
||||
describe("outbound email stays server-only", () => {
|
||||
it("declares the SMTP dependency in Core alone", async () => {
|
||||
it("declares the SMTP transport in Core alone", async () => {
|
||||
const core = await readJson("core/package.json");
|
||||
expect(Object.keys((core.dependencies ?? {}) as object)).toContain("nodemailer");
|
||||
|
||||
const mailPackages = (names: readonly string[]): readonly string[] =>
|
||||
names.filter((name) => /nodemailer|smtp|mailgun|sendgrid|postmark|resend/iu.test(name));
|
||||
|
||||
// Every package a browser can end up executing, plus the contracts barrel a surface must not
|
||||
// reach. None may carry a mail transport.
|
||||
// reach. None may carry anything mail-related at all, in either dependency list.
|
||||
for (const manifest of [
|
||||
"packages/contracts/package.json",
|
||||
"packages/module-sdk/package.json",
|
||||
"packages/module-ui-sdk/package.json",
|
||||
"packages/module-ui-host/package.json",
|
||||
"surfaces/shell/package.json",
|
||||
"apps/api/package.json",
|
||||
]) {
|
||||
const parsed = await readJson(manifest);
|
||||
const dependencies = {
|
||||
...((parsed.dependencies ?? {}) as Record<string, string>),
|
||||
...((parsed.devDependencies ?? {}) as Record<string, string>),
|
||||
};
|
||||
const mailDependencies = Object.keys(dependencies).filter((name) =>
|
||||
/nodemailer|smtp|mailgun|sendgrid|postmark|resend/iu.test(name),
|
||||
);
|
||||
expect(mailDependencies, manifest).toEqual([]);
|
||||
expect(
|
||||
mailPackages([
|
||||
...Object.keys((parsed.dependencies ?? {}) as object),
|
||||
...Object.keys((parsed.devDependencies ?? {}) as object),
|
||||
]),
|
||||
manifest,
|
||||
).toEqual([]);
|
||||
}
|
||||
|
||||
// The API executable ships no mail package of any kind: it reaches SMTP only through Core's
|
||||
// provider. Its *test* dependencies may include `smtp-server`, which is a receiving server and
|
||||
// has no capability to send anything — that is what lets the verification and recovery
|
||||
// integration suites capture a real message instead of asserting against a fake (ADR 0038).
|
||||
const api = await readJson("apps/api/package.json");
|
||||
expect(mailPackages(Object.keys((api.dependencies ?? {}) as object))).toEqual([]);
|
||||
expect(mailPackages(Object.keys((api.devDependencies ?? {}) as object))).toEqual([
|
||||
"@types/smtp-server",
|
||||
"smtp-server",
|
||||
]);
|
||||
});
|
||||
|
||||
it("never imports the transport outside Core's own mail module", async () => {
|
||||
|
||||
Reference in New Issue
Block a user