Skip to content

Commit e11feea

Browse files
kirrg001kevinansfield
authored andcommitted
🎨 increase token expiry (#7972)
refs #5202 - please read #5202 (comment)
1 parent 0414b9a commit e11feea

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

core/server/api/authentication.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ authentication = {
587587

588588
var newAccessToken = globalUtils.uid(256),
589589
refreshToken = globalUtils.uid(256),
590-
newAccessExpiry = Date.now() + globalUtils.ONE_HOUR_MS,
591-
refreshExpires = Date.now() + globalUtils.ONE_WEEK_MS;
590+
newAccessExpiry = Date.now() + globalUtils.ONE_MONTH_MS,
591+
refreshExpires = Date.now() + globalUtils.SIX_MONTH_MS;
592592

593593
return dataProvider.Accesstoken.add({
594594
token: newAccessToken,
@@ -609,7 +609,7 @@ authentication = {
609609
return {
610610
access_token: newAccessToken,
611611
refresh_token: refreshToken,
612-
expires_in: globalUtils.ONE_HOUR_S
612+
expires_in: globalUtils.ONE_MONTH_S
613613
};
614614
});
615615
});

core/server/middleware/oauth.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function exchangeRefreshToken(client, refreshToken, scope, done) {
1515
} else {
1616
var token = model.toJSON(),
1717
accessToken = utils.uid(256),
18-
accessExpires = Date.now() + utils.ONE_HOUR_MS,
19-
refreshExpires = Date.now() + utils.ONE_WEEK_MS;
18+
accessExpires = Date.now() + utils.ONE_MONTH_MS,
19+
refreshExpires = Date.now() + utils.SIX_MONTH_MS;
2020

2121
if (token.expires > Date.now()) {
2222
models.Accesstoken.add({
@@ -27,7 +27,7 @@ function exchangeRefreshToken(client, refreshToken, scope, done) {
2727
}).then(function then() {
2828
return models.Refreshtoken.edit({expires: refreshExpires}, {id: token.id});
2929
}).then(function then() {
30-
return done(null, accessToken, {expires_in: utils.ONE_HOUR_S});
30+
return done(null, accessToken, {expires_in: utils.ONE_MONTH_S});
3131
}).catch(function handleError(error) {
3232
return done(error, false);
3333
});

core/server/utils/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ utils = {
2121
*/
2222
ONE_HOUR_S: 3600,
2323
ONE_DAY_S: 86400,
24+
ONE_MONTH_S: 2628000,
25+
SIX_MONTH_S: 15768000,
2426
ONE_YEAR_S: 31536000,
2527
ONE_HOUR_MS: 3600000,
2628
ONE_DAY_MS: 86400000,
2729
ONE_WEEK_MS: 604800000,
2830
ONE_MONTH_MS: 2628000000,
31+
SIX_MONTH_MS: 15768000000,
2932
ONE_YEAR_MS: 31536000000,
3033

3134
/**

core/test/integration/model/model_accesstoken_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('Accesstoken Model', function () {
2828
token: 'foobartoken',
2929
user_id: 1,
3030
client_id: 1,
31-
expires: Date.now() + utils.ONE_HOUR_MS
31+
expires: Date.now() + utils.ONE_MONTH_MS
3232
})
3333
.then(function (token) {
3434
should.exist(token);

0 commit comments

Comments
 (0)