mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-03 16:38:22 +03:00
🎨 increase token expiry (#7971)
refs #5202 - please read https://github.com/TryGhost/Ghost/issues/5202#issuecomment-278934768
This commit is contained in:
parent
7bc546c698
commit
29fb68137f
@ -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
|
||||
};
|
||||
});
|
||||
},
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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,
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user