From 00ce93ef5130ad61ff6e13573d5e2b265da19b11 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:34:55 +0200 Subject: [PATCH] Added configurable ttl to settings --- settings.json.docker | 13 ++++++++++++- settings.json.template | 11 +++++++++++ src/node/security/OAuth2Provider.ts | 8 +------- src/node/utils/Settings.ts | 10 ++++++++++ 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/settings.json.docker b/settings.json.docker index d96931822..621c7b9b1 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -669,5 +669,16 @@ "redirect_uris": ["${USER_REDIRECT:http://localhost:9001/}"] } ] - } + }, + + /* Set the time to live for the tokens + This is the time of seconds a user is logged into Etherpad + "ttl": { + "AccessToken": 3600, + "AuthorizationCode": 600, + "ClientCredentials": 3600, + "IdToken": 3600, + "RefreshToken": 86400 + } + */ } diff --git a/settings.json.template b/settings.json.template index 85165b2f0..039fa2966 100644 --- a/settings.json.template +++ b/settings.json.template @@ -671,4 +671,15 @@ } ] } + + /* Set the time to live for the tokens + This is the time of seconds a user is logged into Etherpad + "ttl": { + "AccessToken": 3600, + "AuthorizationCode": 600, + "ClientCredentials": 3600, + "IdToken": 3600, + "RefreshToken": 86400 + } + */ } diff --git a/src/node/security/OAuth2Provider.ts b/src/node/security/OAuth2Provider.ts index e34926d5b..e21211350 100644 --- a/src/node/security/OAuth2Provider.ts +++ b/src/node/security/OAuth2Provider.ts @@ -47,13 +47,7 @@ const configuration: Configuration = { } as Account } }, - ttl:{ - AccessToken: 1 * 60 * 60, // 1 hour in seconds - AuthorizationCode: 10 * 60, // 10 minutes in seconds - ClientCredentials: 1 * 60 * 60, // 1 hour in seconds - IdToken: 1 * 60 * 60, // 1 hour in seconds - RefreshToken: 1 * 24 * 60 * 60, // 1 day in seconds - }, + ttl: settings.ttl, claims: { openid: ['sub'], email: ['email'], diff --git a/src/node/utils/Settings.ts b/src/node/utils/Settings.ts index e773f656e..1e8485c04 100644 --- a/src/node/utils/Settings.ts +++ b/src/node/utils/Settings.ts @@ -98,6 +98,16 @@ exports.title = 'Etherpad'; */ exports.favicon = null; +exports.ttl = { + AccessToken: 1 * 60 * 60, // 1 hour in seconds + AuthorizationCode: 10 * 60, // 10 minutes in seconds + ClientCredentials: 1 * 60 * 60, // 1 hour in seconds + IdToken: 1 * 60 * 60, // 1 hour in seconds + RefreshToken: 1 * 24 * 60 * 60, // 1 day in seconds +} + + + /* * Skin name. *