diff --git a/src/middleware/basic-auth.ts b/src/middleware/basic-auth.ts new file mode 100644 index 0000000..12dc09b --- /dev/null +++ b/src/middleware/basic-auth.ts @@ -0,0 +1,8 @@ +import basicAuth from 'express-basic-auth'; + +export default function basicAuthHandler(username : string, password : string) { + return basicAuth({ + authorizer: (req_username : string, req_password : string) => req_username === username && req_password === password, + challenge: true + }); +} diff --git a/src/types/fakes.d.ts b/src/types/fakes.d.ts index b5ddadc..5089d78 100644 --- a/src/types/fakes.d.ts +++ b/src/types/fakes.d.ts @@ -2,3 +2,4 @@ declare module 'express-ip-access-control'; declare module 'connect-static-file'; +declare module 'express-basic-auth'