mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-31 07:35:24 +00:00
feat: move totp and passkeys into plugins (C1)
This commit is contained in:
1 parent
f4f26a9b8b
commit
5c18435105
235 files changed
+22545
-5610
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import type { Router } from "express";
|
||||
import type { PluginContext } from "@termix/plugin-sdk/backend";
|
||||
import { credentials } from "./tables.js";
|
||||
import { createCredentialRepository } from "./repository.js";
|
||||
import { createPasskeyService } from "./passkeys.js";
|
||||
import { PUBLIC_PATHS, registerPasskeyRoutes } from "./routes.js";
|
||||
|
||||
export async function activate(ctx: PluginContext) {
|
||||
const table = await ctx.db.define(credentials);
|
||||
const repository = createCredentialRepository(ctx.db, table);
|
||||
const passkeys = createPasskeyService(ctx, repository);
|
||||
|
||||
// No describe: a passkey only helps a user who already registered one, so
|
||||
// it never counts for the password lockout guard.
|
||||
ctx.auth.registerLoginMethod({
|
||||
id: "passkey",
|
||||
labelKey: "signIn",
|
||||
icon: "fingerprint",
|
||||
kind: "form",
|
||||
verify: (request) => passkeys.verifyLogin(request.body ?? {}),
|
||||
});
|
||||
|
||||
registerPasskeyRoutes(
|
||||
ctx.http.router<Router>({ public: PUBLIC_PATHS }),
|
||||
ctx,
|
||||
repository,
|
||||
passkeys,
|
||||
);
|
||||
}
|
||||
|
||||
export async function deactivate() {
|
||||
// Everything above was registered through ctx and is disposed by core.
|
||||
}
|
||||
Reference in new issue
Block a user