Skip to content

Commit

Permalink
Merge pull request #29 from davidffrench/RHMAP-18579
Browse files Browse the repository at this point in the history
Rhmap 18579
  • Loading branch information
davidffrench authored Nov 22, 2017
2 parents 63afa69 + 65ff16b commit b27a451
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions lib/common/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ module.exports = function(req, res, params) {
json: true,
body: data
}, function(err, res) {
// Can set API_KEY_VALIDATION_TIMEOUT to expire more frequently than a day
var expiration = parseInt(process.env.API_KEY_AUTH_PROJ_VALIDATION_TIMEOUT, 10) || 300000; // A day
var cacheLength = now + expiration; // A day
// Can set API_KEY_VALIDATION_TIMEOUT to expire more frequently than 5 minutes
var expiration = parseInt(process.env.API_KEY_AUTH_PROJ_VALIDATION_TIMEOUT, 10) || 300000; // 5 minutes
var cacheLength = now + expiration; // 5 minutes

// Explicitly handle 404s from Millicore here - the validate_key_against_authoried_projects endpoint may not exist in this cluster
// If we get a 404, continue
if (res.statusCode === 404) {
if (res && res.statusCode === 404) {
authenticateAppApiKeyAuthProjCache[sentApiKey] = {
"timeout": cacheLength
};
Expand All @@ -190,9 +190,11 @@ module.exports = function(req, res, params) {
};
return cb();
} else {
var errorMsg = (res.body && res.body.message) || "Invalid API Key";
console.log("Issue validating app api key. Status Code: " + res.statusCode + ". Error Message: " + errorMsg);
return cb({
code: UNAUTHORISED_HTTP_CODE,
message: "Invalid API Key"
message: errorMsg
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fh-mbaas-express",
"version": "5.9.1",
"version": "5.9.2",
"description": "FeedHenry MBAAS Express",
"main": "lib/webapp.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.projectKey=fh-mbaas-express
sonar.projectName=fh-mbaas-express-nightly-master
sonar.projectVersion=5.9.1
sonar.projectVersion=5.9.2

sonar.sources=./lib
sonar.tests=./test
Expand Down

0 comments on commit b27a451

Please sign in to comment.