mirror of
https://github.com/unraid/api.git
synced 2026-04-25 16:58:38 -05:00
29 lines
621 B
TypeScript
29 lines
621 B
TypeScript
/*!
|
|
* Copyright 2019-2020 Lime Technology Inc. All rights reserved.
|
|
* Written by: Alexis Tyler
|
|
*/
|
|
|
|
import htpasswd from 'htpasswd-js';
|
|
import { paths } from '../../paths';
|
|
|
|
interface Options {
|
|
username: string;
|
|
password: string;
|
|
file?: string;
|
|
}
|
|
|
|
/**
|
|
* Check if the username and password match a htpasswd file.
|
|
*/
|
|
export const checkAuth = async (options: Options): Promise<any> => {
|
|
const { username, password, file } = options;
|
|
|
|
// `valid` will be true if and only if
|
|
// username and password were correct.
|
|
return htpasswd.authenticate({
|
|
username,
|
|
password,
|
|
file: file ?? paths.get('htpasswd')
|
|
});
|
|
};
|