feat(Basic Authentication): Adding back in for controlling access

This commit is contained in:
Chris Troutner
2020-11-11 14:56:24 -08:00
parent b8589a54aa
commit 28f0a1de56
3 changed files with 37 additions and 35 deletions
+4 -2
View File
@@ -33,7 +33,7 @@ util.inspect.defaultOptions = { depth: 1 }
// let _this
// Set default rate limit value for testing
const PRO_PASSES = process.env.PRO_PASS ? process.env.PRO_PASS : 'BITBOX'
const PRO_PASSES = process.env.PRO_PASSES ? process.env.PRO_PASSES : 'testpassword'
// Convert the pro-tier password string into an array split by ':'.
const PRO_PASS = PRO_PASSES.split(':')
@@ -82,6 +82,7 @@ class AuthMW {
// Success
req.locals.proLimit = true
console.log(`User ${req.ip} authenticated using Basic Auth`)
break
}
}
@@ -96,7 +97,8 @@ class AuthMW {
// Middleware called by the route.
mw () {
return passport.authenticate(['anonymous', 'basic'], {
console.log('Initializing passport')
return passport.authenticate(['basic', 'anonymous'], {
session: false
})
}