Skip to content

Commit

Permalink
Merge pull request #106 from apigee/b132970272
Browse files Browse the repository at this point in the history
Cache no-control for OAuth
  • Loading branch information
srinandan authored May 17, 2019
2 parents 4761b68 + 77530a3 commit 54488d2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apikeys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports.init = function(config, logger, stats) {
}

var exchangeApiKeyForToken = function(req, res, next, config, logger, stats, middleware, apiKey) {
var cacheControl = req.headers["cache-control"] || 'no-control';
var cacheControl = req.headers["cache-control"] || 'no-cache';
if (cacheKey || (cacheControl && cacheControl.indexOf("no-cache") < 0)) { // caching is allowed
cache.read(apiKey, function(err, value) {
if (value) {
Expand Down Expand Up @@ -193,7 +193,7 @@ module.exports.init = function(config, logger, stats) {
req.headers["x-authorization-claims"] = new Buffer(JSON.stringify(authClaims)).toString("base64");

if (apiKey) {
var cacheControl = req.headers["cache-control"];
var cacheControl = req.headers["cache-control"] || "no-cache";
if (cacheKey || (cacheControl && cacheControl.indexOf("no-cache") < 0)) { // caching is toFixed
// default to now (in seconds) + 30m if not set
decodedToken.exp = decodedToken.exp || +(((Date.now() / 1000) + 1800).toFixed(0));
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 oauth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ module.exports.init = function(config, logger, stats) {
req.headers['x-authorization-claims'] = new Buffer(JSON.stringify(authClaims)).toString('base64');

if (apiKey) {
var cacheControl = req.headers['cache-control'];
var cacheControl = req.headers['cache-control'] || 'no-cache';
if (cacheKey || (!cacheControl || (cacheControl && cacheControl.indexOf('no-cache') < 0))) { // caching is allowed
// default to now (in seconds) + 30m if not set
decodedToken.exp = decodedToken.exp || +(((Date.now() / 1000) + 1800).toFixed(0));
Expand Down
2 changes: 1 addition & 1 deletion oauthv2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,4 @@ function sendError(req, res, next, logger, stats, code, message) {
stats.incrementStatusCount(res.statusCode);
next(code, message);
return code;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microgateway-plugins",
"version": "2.5.35",
"version": "2.5.36",
"description": "Plugins for Apige Edge Microgateway",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 54488d2

Please sign in to comment.