feat(oauth): make non-expiring refresh tokens the default

doorkeeper, GitLab's current Rails OAuth implementation, issues refresh tokens that never expire. IAM defaulted them to 30 days, which would have rejected every migrated client's stored refresh token. This change makes non-expiring the default.

Configuration uses auth/oauth/core.Config.RefreshTokenLifespan: <= 0 means never expires (the new default), > 0 specifies a duration. Since fosite interprets 0 as "use my own 30-day default" and only -1 as "never expires", translation happens at the single point where fosite is configured. The hardcoded 30-day session seed was removed.

One deliberate deviation from gitlab-org/gitlab#598671 (closed): the session constructor seed was removed outright because fosite sets refresh expiry on every refresh-issuing path, making plumbing unnecessary.

Pre-existing tokens carry the old expiry in session_data, so hydration now takes it from the expires_at column instead: the row cannot be contradicted by a stale copy of itself. Making such a token non-expiring would additionally need a one-off UPDATE oauth_refresh_tokens SET expires_at = NULL, which is moot while IAM is pre-launch.

Migrations for PostgreSQL and YugabyteDB drop NOT NULL from oauth_refresh_tokens.expires_at; every insert still supplies it, now sometimes as NULL.

Unit and integration suites pass against both backends; CI green.

On a rolling deploy an old replica would read NULL expires_at as expired, and fosite answers that by revoking the client's whole token family. Splitting the deploy — NULL-tolerant read first, NULL write later — would close that window, but IAM is pre-launch with no old replicas in traffic, so no split is needed here.

Closes gitlab-org/gitlab#617814 (closed).

Edited by Smriti Garg

Merge request reports

Loading
Loading