2020-02-23 19:42:36 +00:00
|
|
|
import { IAuthentication } from '../types/Authentication';
|
|
|
|
|
|
|
|
interface IStaticAuthOtions {
|
|
|
|
validCrentials: {
|
|
|
|
username: string;
|
|
|
|
password: string;
|
|
|
|
}[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export class StaticAuth implements IAuthentication {
|
|
|
|
private validCredentials: { username: string; password: string }[];
|
|
|
|
|
|
|
|
constructor(options: IStaticAuthOtions) {
|
|
|
|
this.validCredentials = options.validCrentials;
|
|
|
|
}
|
|
|
|
|
|
|
|
async authenticate(username: string, password: string) {
|
|
|
|
return !!this.validCredentials.find(
|
2020-05-14 13:02:15 +00:00
|
|
|
(credential) => credential.username === username && credential.password === password
|
2020-02-23 19:42:36 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|