Skip to content

Commit 510a7bb

Browse files
authored
feat: increase keycloak session timeouts (#382)
This PR increases the SSO session max lifespan from 7 days to 30 days and session idle time from 48h to 72h, reducing forced re-authentication frequency for active users.
1 parent 8e0949e commit 510a7bb

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

helm-chart/templates/configmaps/authentication.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ data:
1515
OIDC_MANAGE_CLIENT_ID: semaphore-user-management
1616
SESSION_COOKIE_NAME: _semaphoreci_2_0_sxmoon_session
1717
ENABLE_TEMPORARY_PASSWORDS: "true"
18+
SESSION_IDLE_TIMEOUT: "72h"
19+
SESSION_MAX_TIMESPAN: "30d"
20+
ACCESS_TOKEN_LIFESPAN: "1h"
21+
OFFLINE_SESSION_IDLE_TIMEOUT: "30d"

keycloak/setup/helm/templates/setup-job.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ spec:
2828
valueFrom: { configMapKeyRef: { name: {{ .Values.global.authentication.configMapName }}, key: KC_LOCAL_URL } }
2929
- name: TF_VAR_semaphore_realm
3030
valueFrom: { configMapKeyRef: { name: {{ .Values.global.authentication.configMapName }}, key: KC_REALM } }
31+
- name: TF_VAR_semaphore_realm_session_idle_timeout
32+
valueFrom: { configMapKeyRef: { name: {{ .Values.global.authentication.configMapName }}, key: SESSION_IDLE_TIMEOUT } }
33+
- name: TF_VAR_semaphore_realm_session_max_lifespan
34+
valueFrom: { configMapKeyRef: { name: {{ .Values.global.authentication.configMapName }}, key: SESSION_MAX_TIMESPAN } }
35+
- name: TF_VAR_semaphore_realm_access_token_lifespan
36+
valueFrom: { configMapKeyRef: { name: {{ .Values.global.authentication.configMapName }}, key: ACCESS_TOKEN_LIFESPAN } }
37+
- name: TF_VAR_realm_offline_session_idle_timeout
38+
valueFrom: { configMapKeyRef: { name: {{ .Values.global.authentication.configMapName }}, key: OFFLINE_SESSION_IDLE_TIMEOUT } }
3139
- name: TF_VAR_semaphore_user_management_client_id
3240
valueFrom: { configMapKeyRef: { name: {{ .Values.global.authentication.configMapName }}, key: OIDC_MANAGE_CLIENT_ID } }
3341
- name: TF_VAR_semaphore_user_management_client_name

keycloak/setup/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ resource "keycloak_realm" "semaphore_realm" {
3232

3333
login_theme = var.semaphore_realm_login_theme
3434

35-
access_token_lifespan = "60m"
36-
offline_session_idle_timeout = "60m"
35+
access_token_lifespan = var.semaphore_realm_access_token_lifespan
36+
offline_session_idle_timeout = var.semaphore_realm_offline_session_idle_timeout
3737

38-
sso_session_idle_timeout = "48h"
39-
sso_session_max_lifespan = "168h"
38+
sso_session_idle_timeout = var.semaphore_realm_session_idle_timeout
39+
sso_session_max_lifespan = var.semaphore_realm_session_max_lifespan
4040

4141
registration_email_as_username = true
4242
verify_email = false

keycloak/setup/variables.tf

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,30 @@ variable "semaphore_realm" {
1919
type = string
2020
}
2121

22+
variable "semaphore_realm_session_idle_timeout" {
23+
description = "Semaphore realm session idle timeout"
24+
type = string
25+
default = "72h"
26+
}
27+
28+
variable "semaphore_realm_session_max_lifespan" {
29+
description = "Semaphore realm session max lifespan"
30+
type = string
31+
default = "30d"
32+
}
33+
34+
variable "semaphore_realm_access_token_lifespan" {
35+
description = "Semaphore realm access token lifespan"
36+
type = string
37+
default = "1h"
38+
}
39+
40+
variable "semaphore_realm_offline_session_idle_timeout" {
41+
description = "Semaphore realm offline session idle timeout"
42+
type = string
43+
default = "30d"
44+
}
45+
2246
variable "semaphore_realm_update_password_action" {
2347
description = "If enabled, newly created accounts will be required to update their password on first login"
2448
type = bool
@@ -137,4 +161,4 @@ variable "gitlab_provider_client_secret" {
137161
variable "gitlab_provider_authorization_url" {
138162
description = "Gitlab provider authorization url"
139163
type = string
140-
}
164+
}

0 commit comments

Comments
 (0)