basicAuth
constbasicAuth: (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.
Parameters
Section titled “Parameters”config?
Section titled “config?”BasicAuthConfig
Validation function and optional realm name.
Returns
Section titled “Returns”A Policy at priority 10.
Example
Section titled “Example”basicAuth({ realm: "Admin Area", validate: async (username, password) => { return username === "admin" && password === env.ADMIN_PASSWORD; },});