From 1c4d887b7aae1fa3c4af68a89590f7608d99773d Mon Sep 17 00:00:00 2001 From: spacemeowx2 Date: Wed, 6 May 2020 20:16:10 +0800 Subject: [PATCH] fix: simple auth should accept plain text pw --- server/src/auth/CustomAuthProvider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/auth/CustomAuthProvider.ts b/server/src/auth/CustomAuthProvider.ts index 73a6e33..122f462 100644 --- a/server/src/auth/CustomAuthProvider.ts +++ b/server/src/auth/CustomAuthProvider.ts @@ -1,14 +1,16 @@ import { BasicAuthProvider, AuthError, AuthErrorType, SHA1 } from './types' export class CustomAuthProvider extends BasicAuthProvider { + private sha1: Buffer constructor(private username: string, private password: string) { super() + this.sha1 = SHA1(this.password) } async getUserPasswordSHA1(username: string) { if (username !== this.username) { throw new AuthError(AuthErrorType.NoSuchUser, 'No such user') } - return Buffer.from(this.password, 'hex') + return this.sha1 } }