Skip to content

basicAuth

const basicAuth: (config?) => Policy

Defined in: src/policies/auth/basic-auth.ts:37

Basic Authentication policy — validate base64-encoded credentials.

Sends a WWW-Authenticate header on failure to prompt browser credential dialogs. The realm is sanitized to prevent header injection.

BasicAuthConfig

Validation function and optional realm name.

Policy

A Policy at priority 10.

basicAuth({
realm: "Admin Area",
validate: async (username, password) => {
return username === "admin" && password === env.ADMIN_PASSWORD;
},
});