@anddev-oss/verdaccio-htpasswd-azure
Version:
htpasswd auth plugin for Verdaccio that saves in Azure Blob
56 lines (55 loc) • 1.86 kB
TypeScript
import { AuthCallback, IPluginAuth, Logger, PluginOptions } from '@verdaccio/types';
import { CustomConfig } from '../types/index';
export declare const DEFAULT_SLOW_VERIFY_MS = 200;
/**
* Custom Verdaccio Authenticate Plugin.
*/
export default class AuthCustomPlugin implements IPluginAuth<CustomConfig> {
logger: Logger;
private users;
private maxUsers;
private hashConfig;
private slowVerifyMs;
private lastTime;
private blobServiceClient;
private containerClient;
private containerName;
private blobName;
constructor(config: CustomConfig, options: PluginOptions<CustomConfig>);
/**
* Authenticate an user.
* @param user user to log
* @param password provided password
* @param cb callback function
*/
authenticate(user: string, password: string, cb: AuthCallback): void;
/**
* Add user
* 1. lock file for writing (other processes can still read)
* 2. reload .htpasswd
* 3. write new data into .htpasswd.tmp
* 4. move .htpasswd.tmp to .htpasswd
* 5. reload .htpasswd
* 6. unlock file
*
* @param {string} user
* @param {string} password
* @param {function} realCb
* @returns {Promise<any>}
*/
adduser(user: string, password: string, cb: AuthCallback): Promise<any>;
/**
* changePassword - change password for existing user.
* @param {string} user
* @param {string} password
* @param {string} newPassword
* @param {function} realCb
* @returns {function}
*/
changePassword(user: string, password: string, newPassword: string, cb: AuthCallback): Promise<void>;
/**
* Reload users
* @param {function} callback
*/
reload(cb: AuthCallback): Promise<void>;
}