Skip to content

Commit 41a96d8

Browse files
authored
feat: add AUTH_SESSION_TIMEOUT environment variable for configurable session duration (#5041)
1 parent 8b9133f commit 41a96d8

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

docs/deployment/configuration.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Keep is highly configurable through environment variables. This allows you to cu
9595
| Env var | Purpose | Required | Default Value | Valid options |
9696
| :-----------------------------------: | :---------------------------------------------------------------: | :------: | :-----------: | :------------------------------------------------: |
9797
| **AUTH_TYPE** | Specifies the authentication type | No | "NOAUTH" | "AUTH0", "KEYCLOAK", "DB", "NOAUTH", "OAUTH2PROXY" |
98+
| **AUTH_SESSION_TIMEOUT** | Specifies user session timeout. Default is 30 days(2592000) | No | 2592000 | "AUTH0", "KEYCLOAK", "DB", "NOAUTH", "OAUTH2PROXY" |
9899
| **KEEP_JWT_SECRET** | Secret key for JWT token generation and validation (DB auth only) | Yes | None | Any strong secret string |
99100
| **KEEP_DEFAULT_USERNAME** | Default username for the admin user (DB auth only) | No | "keep" | Any valid username string |
100101
| **KEEP_DEFAULT_PASSWORD** | Default password for the admin user (DB auth only) | No | "keep" | Any strong password string |

keep-ui/auth.config.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ export class BackendRefusedError extends AuthError {
2121
static type = "BackendRefusedError";
2222
}
2323

24+
const authSessionTimeout = process.env.AUTH_SESSION_TIMEOUT
25+
? Number.parseInt(process.env.AUTH_SESSION_TIMEOUT)
26+
: 30 * 24 * 60 * 60; // Default to 30 days if not set
2427
// Determine auth type with backward compatibility
2528
const authTypeEnv = process.env.AUTH_TYPE;
2629
export const authType =
2730
authTypeEnv === MULTI_TENANT
2831
? AuthType.AUTH0
2932
: authTypeEnv === SINGLE_TENANT
30-
? AuthType.DB
31-
: authTypeEnv === NO_AUTH
32-
? AuthType.NOAUTH
33-
: (authTypeEnv as AuthType);
33+
? AuthType.DB
34+
: authTypeEnv === NO_AUTH
35+
? AuthType.NOAUTH
36+
: (authTypeEnv as AuthType);
3437

3538
export const proxyUrl =
3639
process.env.HTTP_PROXY ||
@@ -238,7 +241,7 @@ export const config = {
238241
},
239242
session: {
240243
strategy: "jwt" as const,
241-
maxAge: 30 * 24 * 60 * 60, // 30 days
244+
maxAge: authSessionTimeout, // 30 days
242245
},
243246
callbacks: {
244247
authorized({ auth, request: { nextUrl } }) {

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "keep"
3-
version = "0.45.4"
3+
version = "0.45.5"
44
description = "Alerting. for developers, by developers."
55
authors = ["Keep Alerting LTD"]
66
packages = [{include = "keep"}]

0 commit comments

Comments
 (0)