denim-api-auth-middleware
Advanced tools
Comparing version 1.0.4 to 1.0.5
const makeApiKeyAuthMiddleware = apiKeys => (req, res, next) => { | ||
const authHeader = req.get('Authorization') | ||
if(!authHeader) res.status(403).send('Forbidden') | ||
if(typeof authHeader === 'undefined') { | ||
res.status(403).send('Forbidden') | ||
}else{ | ||
const authHeaderParts = req.get('Authorization').split(':') | ||
const reqKey = authHeaderParts[0] | ||
const reqPass = authHeaderParts[authHeaderParts.length - 1] | ||
const authHeaderParts = req.get('Authorization').split(':') | ||
const reqKey = authHeaderParts[0] | ||
const reqPass = authHeaderParts[authHeaderParts.length - 1] | ||
if (apiKeys[reqKey] !== reqPass) { | ||
res.status(403).send('Forbidden') | ||
} | ||
} | ||
if (apiKeys[reqKey] !== reqPass) { | ||
res.status(403).send('Forbidden') | ||
} | ||
next() | ||
@@ -13,0 +16,0 @@ } |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
var makeApiKeyAuthMiddleware = function makeApiKeyAuthMiddleware(apiKeys) { | ||
return function (req, res, next) { | ||
var authHeader = req.get('Authorization'); | ||
if (!authHeader) res.status(403).send('Forbidden'); | ||
return function (req, res, next) { | ||
var authHeader = req.get('Authorization'); | ||
if (typeof authHeader === 'undefined') { | ||
res.status(403).send('Forbidden'); | ||
} else { | ||
var authHeaderParts = req.get('Authorization').split(':'); | ||
var reqKey = authHeaderParts[0]; | ||
var reqPass = authHeaderParts[authHeaderParts.length - 1]; | ||
var authHeaderParts = req.get('Authorization').split(':'); | ||
var reqKey = authHeaderParts[0]; | ||
var reqPass = authHeaderParts[authHeaderParts.length - 1]; | ||
if (apiKeys[reqKey] !== reqPass) { | ||
res.status(403).send('Forbidden'); | ||
} | ||
} | ||
if (apiKeys[reqKey] !== reqPass) { | ||
res.status(403).send('Forbidden'); | ||
} | ||
next(); | ||
}; | ||
next(); | ||
}; | ||
}; | ||
@@ -21,0 +24,0 @@ |
{ | ||
"name": "denim-api-auth-middleware", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Express API Key Auth Middleware", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
262692
46