From 8a2d98c67ab792becde32941aed1b02f4c76e9b8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 15 Feb 2017 07:37:00 +0000 Subject: [PATCH] Add basic auth middleware --- src/middleware/basic-auth.ts | 8 ++++++++ src/types/fakes.d.ts | 1 + 2 files changed, 9 insertions(+) create mode 100644 src/middleware/basic-auth.ts 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'