V 2.1.0 Verbesserungen von Claud Code eingefügt

This commit is contained in:
2026-04-27 10:39:09 +02:00
parent a7863c519f
commit 38c18a5ead
7 changed files with 22 additions and 21 deletions

View File

@@ -1,20 +1,10 @@
/**
* Reusable authentication library
* Configure users via environment variables in .env:
* AUTH_USERS=user1:$2a$10$hash1,user2:$2a$10$hash2
*
* Use scripts/generate-password.js to generate password hashes
*/
import bcrypt from 'bcryptjs';
export interface User {
username: string;
password: string;
}
/**
* Parse users from environment variable
* Format: username:password,username2:password2
*/
export function getUsers(): User[] {
const usersString = process.env.AUTH_USERS || '';
if (!usersString) {
@@ -30,21 +20,15 @@ export function getUsers(): User[] {
.filter((user) => user.username && user.password);
}
/**
* Verify user credentials
*/
export function verifyCredentials(username: string, password: string): boolean {
export async function verifyCredentials(username: string, password: string): Promise<boolean> {
const users = getUsers();
const user = users.find(u => u.username === username);
if (!user) {
return false;
}
return user.password === password;
return bcrypt.compare(password, user.password);
}
/**
* Check if authentication is enabled
*/
export function isAuthEnabled(): boolean {
return !!process.env.AUTH_USERS;
}