Hi everyone,
I’m investigating how sessions are handled in the peertube-plugin-auth-saml2 plugin and noticed something that could become a scalability issue.
Environment:
- PeerTube version: 6.3.3
- Plugin: peertube-plugin-auth-saml2
- IdP: Keycloak
What I observed:
-
Each time a user logs in via SAML, a new entry is created in the plugin table (
storagecolumn). -
These entries look like
saml_session_<random_id>and storename_idandsession_index. -
Even for the same user, multiple sessions are stored instead of updating/reusing an existing one.
Example:
- Same user (
u0011@yourdomain.com) has multiple session entries with differentsession_indexvalues.
Concern:
-
Over time, this leads to accumulation of many session records per user.
-
With a large number of users and frequent logins, this could cause unnecessary growth in the database and impact performance.
My question:
-
Is this behavior intentional (e.g., to support multiple concurrent SAML sessions or SLO requirements)?
-
Or should the plugin be updating/replacing existing sessions for the same
name_idinstead of creating new ones? -
Is there any recommended cleanup mechanism or configuration to prevent unbounded growth?
Would appreciate any clarification on the design decision or best practices for handling this.
Thanks!
Example:
{
"saml_session_147272034def8efefe73": {
"name_id": "u0015@yourdomain.com",
"session_index": "iXNcxuM1TWr2dbxRJUnr4i4b::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_1a14ca232e58a45080ea": {
"name_id": "u0011@yourdomain.com",
"session_index": "Hxfi_LtPIgUKClxuZsVTBAj2::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_2e24022a9ec486d0c3bc": {
"name_id": "u0011@yourdomain.com",
"session_index": "gm9hcuhYKj3AQuFQrLDVrdUp::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_312fc66bced2bbcc6555": {
"name_id": "u0013@yourdomain.com",
"session_index": "Y1uEabNrde3bi-rgjLYtCi6n::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_53095c156434f4e297e7": {
"name_id": "u0014@yourdomain.com",
"session_index": "fcWQ2wSQf-Gb14nylbtenN3o::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_58ac7b051d85cf1a6c8d": {
"name_id": "u0015@yourdomain.com",
"session_index": "enUlGM3-uASxnpsiegUwUxel::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_76110c94da31ae8f9ab8": {
"name_id": "u0011@yourdomain.com",
"session_index": "nYcib7aV37rzpKTStQbrF7Tw::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_80479274012748ddda49": {
"name_id": "u0015@yourdomain.com",
"session_index": "qUVLSq-t_r8PEy6YAUj9u1a5::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_9013a3245c28a4e1a546": {
"name_id": "u0015@yourdomain.com",
"session_index": "iXNcxuM1TWr2dbxRJUnr4i4b::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_a80f09997053bbc366ae": {
"name_id": "u0015@yourdomain.com",
"session_index": "qebG7tQl9enC5MwFFeRGQNk6::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_c23cfeaeb80129b37364": {
"name_id": "u0011@yourdomain.com",
"session_index": "KX46iuVaVGd_itWyFPI6a-bO::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_d6273916583745e0f9ce": {
"name_id": "u0011@yourdomain.com",
"session_index": "mtLAkYQoV3XcuP93QOeHfpgm::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_ed86e90b895593016d93": {
"name_id": "u0013@yourdomain.com",
"session_index": "gVd1GxgpKkj387iQ4vNIHIfW::eeb4d31f-991d-44c5-967d-76da73ad7449"
},
"saml_session_ffc38bf368a3b9da3af9": {
"name_id": "u0013@yourdomain.com",
"session_index": "gVd1GxgpKkj387iQ4vNIHIfW::eeb4d31f-991d-44c5-967d-76da73ad7449"
}
}