@nephele/authenticator-htpasswd
Version:
Apache htpasswd based authenticator for the Nephele WebDAV server.
29 lines (28 loc) • 1.29 kB
TypeScript
import type { Readable } from 'node:stream';
import type { Request } from 'express';
import type { Authenticator as AuthenticatorInterface, AuthResponse as NepheleAuthResponse } from 'nephele';
import User from './User.js';
export type AuthenticatorConfig = {
realm?: string;
unauthorizedAccess?: boolean;
authUserFilename?: string;
authUserFile?: string;
blockAuthUserFilename?: boolean;
};
export type AuthResponse = NepheleAuthResponse<any, {
user: User;
}>;
export default class Authenticator implements AuthenticatorInterface {
realm: string;
unauthorizedAccess: boolean;
authUserFilename: string;
authUserFile?: string;
blockAuthUserFilename: boolean;
constructor({ realm, unauthorizedAccess, authUserFilename, authUserFile, blockAuthUserFilename, }?: AuthenticatorConfig);
authenticate(request: Request, response: AuthResponse): Promise<User>;
cleanAuthentication(_request: Request, _response: AuthResponse): Promise<void>;
_checkHtpasswd(username: string, password: string, htpasswd: string): Promise<boolean>;
_checkPassword(digest: string, password: string): Promise<boolean>;
_getHtpasswdFile(request: Request, response: AuthResponse): Promise<string>;
_streamToString(stream: Readable): Promise<string>;
}