diff --git a/core/server/api/authentication.js b/core/server/api/authentication.js index 4e464107cf..cc85eec2d1 100644 --- a/core/server/api/authentication.js +++ b/core/server/api/authentication.js @@ -138,8 +138,8 @@ authentication = { createTokens: function createTokens(data, options) { var localAccessToken = globalUtils.uid(191), localRefreshToken = globalUtils.uid(191), - accessExpires = Date.now() + globalUtils.ONE_HOUR_MS, - refreshExpires = Date.now() + globalUtils.ONE_WEEK_MS, + accessExpires = Date.now() + globalUtils.ONE_MONTH_MS, + refreshExpires = Date.now() + globalUtils.SIX_MONTH_MS, client = options.context.client_id, user = options.context.user; @@ -159,7 +159,7 @@ authentication = { return { access_token: localAccessToken, refresh_token: localRefreshToken, - expires_in: globalUtils.ONE_HOUR_S + expires_in: globalUtils.ONE_MONTH_S }; }); }, diff --git a/core/server/auth/oauth.js b/core/server/auth/oauth.js index 471f682299..7588283c0f 100644 --- a/core/server/auth/oauth.js +++ b/core/server/auth/oauth.js @@ -17,8 +17,8 @@ function exchangeRefreshToken(client, refreshToken, scope, body, authInfo, done) } else { var token = model.toJSON(), accessToken = utils.uid(191), - 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()) { spamPrevention.userLogin.reset(authInfo.ip, body.refresh_token + 'login'); @@ -31,7 +31,7 @@ function exchangeRefreshToken(client, refreshToken, scope, body, authInfo, 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); }); diff --git a/core/server/utils/index.js b/core/server/utils/index.js index a792ebf336..9bcf9dd3d9 100644 --- a/core/server/utils/index.js +++ b/core/server/utils/index.js @@ -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, /** diff --git a/core/test/integration/model/model_accesstoken_spec.js b/core/test/integration/model/model_accesstoken_spec.js index 2a00a5273d..d8590413dd 100644 --- a/core/test/integration/model/model_accesstoken_spec.js +++ b/core/test/integration/model/model_accesstoken_spec.js @@ -29,7 +29,7 @@ describe('Accesstoken Model', function () { token: 'foobartoken', user_id: testUtils.DataGenerator.Content.users[0].id, client_id: testUtils.DataGenerator.forKnex.clients[0].id, - expires: Date.now() + utils.ONE_HOUR_MS + expires: Date.now() + utils.ONE_MONTH_MS }) .then(function (token) { should.exist(token);