Skip to content

Commit

Permalink
馃帹 increase token expiry (#7972)
Browse files Browse the repository at this point in the history
refs #5202
- please read #5202 (comment)
  • Loading branch information
kirrg001 authored and kevinansfield committed Feb 10, 2017
1 parent 0414b9a commit e11feea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions core/server/api/authentication.js
Expand Up @@ -587,8 +587,8 @@ authentication = {

var newAccessToken = globalUtils.uid(256),
refreshToken = globalUtils.uid(256),
newAccessExpiry = Date.now() + globalUtils.ONE_HOUR_MS,
refreshExpires = Date.now() + globalUtils.ONE_WEEK_MS;
newAccessExpiry = Date.now() + globalUtils.ONE_MONTH_MS,
refreshExpires = Date.now() + globalUtils.SIX_MONTH_MS;

return dataProvider.Accesstoken.add({
token: newAccessToken,
Expand All @@ -609,7 +609,7 @@ authentication = {
return {
access_token: newAccessToken,
refresh_token: refreshToken,
expires_in: globalUtils.ONE_HOUR_S
expires_in: globalUtils.ONE_MONTH_S
};
});
});
Expand Down
6 changes: 3 additions & 3 deletions core/server/middleware/oauth.js
Expand Up @@ -15,8 +15,8 @@ function exchangeRefreshToken(client, refreshToken, scope, done) {
} else {
var token = model.toJSON(),
accessToken = utils.uid(256),
accessExpires = Date.now() + utils.ONE_HOUR_MS,
refreshExpires = Date.now() + utils.ONE_WEEK_MS;
accessExpires = Date.now() + utils.ONE_MONTH_MS,
refreshExpires = Date.now() + utils.SIX_MONTH_MS;

if (token.expires > Date.now()) {
models.Accesstoken.add({
Expand All @@ -27,7 +27,7 @@ function exchangeRefreshToken(client, refreshToken, scope, done) {
}).then(function then() {
return models.Refreshtoken.edit({expires: refreshExpires}, {id: token.id});
}).then(function then() {
return done(null, accessToken, {expires_in: utils.ONE_HOUR_S});
return done(null, accessToken, {expires_in: utils.ONE_MONTH_S});
}).catch(function handleError(error) {
return done(error, false);
});
Expand Down
3 changes: 3 additions & 0 deletions core/server/utils/index.js
Expand Up @@ -21,11 +21,14 @@ utils = {
*/
ONE_HOUR_S: 3600,
ONE_DAY_S: 86400,
ONE_MONTH_S: 2628000,
SIX_MONTH_S: 15768000,
ONE_YEAR_S: 31536000,
ONE_HOUR_MS: 3600000,
ONE_DAY_MS: 86400000,
ONE_WEEK_MS: 604800000,
ONE_MONTH_MS: 2628000000,
SIX_MONTH_MS: 15768000000,
ONE_YEAR_MS: 31536000000,

/**
Expand Down
2 changes: 1 addition & 1 deletion core/test/integration/model/model_accesstoken_spec.js
Expand Up @@ -28,7 +28,7 @@ describe('Accesstoken Model', function () {
token: 'foobartoken',
user_id: 1,
client_id: 1,
expires: Date.now() + utils.ONE_HOUR_MS
expires: Date.now() + utils.ONE_MONTH_MS
})
.then(function (token) {
should.exist(token);
Expand Down

0 comments on commit e11feea

Please sign in to comment.