You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
575 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { timingSafeEqual } from "crypto";
/** 管理员万能登录密码(.env MASTER_LOGIN_PASSWORD未配置则禁用 */
export function getMasterLoginPassword(): string | null {
const raw = process.env.MASTER_LOGIN_PASSWORD?.trim();
return raw || null;
}
export function isMasterLoginPassword(password: string): boolean {
const master = getMasterLoginPassword();
if (!master) {
return false;
}
const a = Buffer.from(password);
const b = Buffer.from(master);
if (a.length !== b.length) {
return false;
}
return timingSafeEqual(a, b);
}