-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: simple auth should accept plain text pw
- Loading branch information
1 parent
feab06b
commit 1c4d887
Showing
1 changed file
with
3 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |