Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

denim-api-auth-middleware

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

denim-api-auth-middleware - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

17

api-auth-middleware.js
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc