Skip to content

Instantly share code, notes, and snippets.

@pwelagedara
Created June 3, 2019 21:59
Show Gist options
  • Save pwelagedara/1f548763119a5d049101769b31028c6a to your computer and use it in GitHub Desktop.
Save pwelagedara/1f548763119a5d049101769b31028c6a to your computer and use it in GitHub Desktop.
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