Skip to content

fix(platform): an organization's idle timeout signs SSO sessions out while they are in use #5249

Closed

Description

@tale-code-bot

Found while working on #5164 (board task TALE-260) and not fixed there. Read from the code at feature-train 610007bd07ee9bea6ccc2667dc9d0641c308718f; not reproduced against a running deployment.

What happens

With SESSION_IDLE_TIMEOUT_MINUTES unset, an organization's Session idle timeout signs a person who signed in through SSO out one window after sign-in, however actively they use Tale.

Why

  • createSsoUserSession (services/platform/backend/domains/sso/service.ts) inserts the session row itself. While the variable is unset, the row's expiresAt is 30 days ahead (sessionExpiryMs(now, 30 days)).
  • Better Auth 1.7.7 refreshes a session (writes expiresAt and updatedAt) at the first request once expiresAt - expiresIn + updateAge has passed (shouldBeUpdated in better-auth/dist/api/routes/session.mjs). expiresIn is 7 days, so a 30-day row is first refreshed about 23 days after sign-in. Until then its updatedAt stays at the sign-in time.
  • The idle sweep (services/platform/backend/domains/governance/session-idle.ts) reads updatedAt as the session's last use. It revokes a live session of a member of an organization whose window is on once updatedAt is older than that window.

So the sweep revokes the SSO session one window after sign-in, plus the cookie cache's length when SESSION_COOKIE_CACHE_SECONDS is set.

With the variable set, the row gets the window as its lifetime, and Better Auth refreshes it as usual. Only the unset case is affected.

The same shape: "don't remember me"

A session from Better Auth's email sign-in with rememberMe: false also has a fixed lifetime of one day, and Better Auth never refreshes it. Under a window, the sweep revokes it one window after sign-in, whether the variable is set or not.

Tale's own sign-in form does not send rememberMe: false, so only callers of the auth API make such sessions.

Expected

Under an idle window, an SSO session in use stays signed in. It goes once it has been idle for the window, like any other session.

Activity

  1. added
    agent-ready
    on Nov 1, 2026
  2. tale-code-bot commented on Nov 1, 2026

    @tale-code-bot
    CollaboratorAuthor

    The fix of this issue is on its way to train (board task TALE-349, branch fix/sso-session-idle-refresh). Every authorization now records the session's use, which keeps single sign-on and "don't remember me" sessions in use signed in under an idle window.

    Split off as #5264: on the feature line, that record undoes part of the write saving of #5164. #5264 proposes recording the use only where Better Auth's own refresh does not.

  3. added a commit that references this issue on Nov 1, 2026
    065ecd3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions