Created
June 3, 2019 21:59
-
-
Save pwelagedara/1f548763119a5d049101769b31028c6a to your computer and use it in GitHub Desktop.
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
var config = { | |
appRoot: __dirname, // required config | |
// Security Handlers | |
swaggerSecurityHandlers: { | |
apiKeyAuth: function(req, authOrSecDef, scopesOrApiKey, cb) { | |
var apiKey = req.headers['x-api-key']; // Values get simplified here. | |
console.log(req.headers); | |
console.log(apiKey); | |
if (apiKey) { | |
if(apiKey == app.get("API_KEY")) { | |
cb(); | |
} else{ | |
cb(new Error('authentication failed')); | |
} | |
} else { | |
cb(new Error('authentication failed')); | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment