Created
June 19, 2017 20:50
-
-
Save modeswitch/d8fb5483f7015ee8de88afc268218fc6 to your computer and use it in GitHub Desktop.
basic auth
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
const express = require("express"); | |
let app = express(); | |
let basicAuth = require("express-basic-auth"); | |
app.use(basicAuth({ | |
users: { | |
"brainsights": "donthackus", | |
}, | |
challenge: true, | |
unauthorizedResponse: (req) => { | |
return req.auth ? | |
(`Credentials ${req.auth.user}:${req.auth.password} rejected`) : | |
`No credentials provided`; | |
}, | |
})); | |
app.listen(process.env["PORT"] || 8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment