Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add inactivity-timeout to sessions #1288

Merged
merged 1 commit into from
Nov 6, 2023
Merged

Conversation

hf
Copy link
Contributor

@hf hf commented Oct 30, 2023

Adds the ability for sessions to time-out after a period of inactivity. "Activity" is defined as refreshing the session.

This can be configured by setting the GOTRUE_SESSIONS_INACTIVITY_TIMEOUT to a duration.

Since this PR modifies the database by adding a new refreshed_at nullable column to sessions, it also adds some useful columns to the sessions table to track the User-Agent and IP address that performed the refresh / session creation.

internal/api/token_refresh.go Outdated Show resolved Hide resolved
@hf hf force-pushed the hf/inactivity-timeout-sessions branch 2 times, most recently from 72ca691 to 60beb19 Compare November 1, 2023 10:26
@hf hf marked this pull request as ready for review November 1, 2023 10:28
@hf hf requested a review from a team as a code owner November 1, 2023 10:28
internal/api/token.go Outdated Show resolved Hide resolved
@hf
Copy link
Contributor Author

hf commented Nov 6, 2023

Added one change I did not foresee and that is, if the session has no refreshed_at value it should use the token's updated_at value instead so that old sessions that had not been touched in a while (but are still valid per the inactivity timeout) don't just get killed.

@hf hf force-pushed the hf/inactivity-timeout-sessions branch from e7f1767 to 79330c2 Compare November 6, 2023 20:11
@hf hf force-pushed the hf/inactivity-timeout-sessions branch from 79330c2 to 98086f6 Compare November 6, 2023 20:11
internal/models/sessions.go Show resolved Hide resolved
internal/api/token_refresh.go Outdated Show resolved Hide resolved
@hf hf merged commit 6c8a96e into master Nov 6, 2023
1 check passed
@hf hf deleted the hf/inactivity-timeout-sessions branch November 6, 2023 22:40
Copy link
Contributor

github-actions bot commented Nov 6, 2023

🎉 This PR is included in version 2.108.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

hf added a commit that referenced this pull request Nov 7, 2023
Builds on top of #1288.

Adds cleanup for timeboxed sessions and sessions that have expired due
to inactivity timeout.

It achieves backward compatibility with sessions that have `null` in
`refreshed_at` by looking at the `updated_at` column of the refresh
tokens table. This approach is the one that puts the least strain on the
database, having considered backfilling (very expensive at least
`O(nlogn)` over the whole refresh tokens table).
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
Adds the ability for sessions to time-out after a period of inactivity.
"Activity" is defined as refreshing the session.

This can be configured by setting the
`GOTRUE_SESSIONS_INACTIVITY_TIMEOUT` to a duration.

Since this PR modifies the database by adding a new `refreshed_at`
nullable column to `sessions`, it also adds some useful columns to the
`sessions` table to track the `User-Agent` and IP address that performed
the refresh / session creation.
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
…e#1298)

Builds on top of supabase#1288.

Adds cleanup for timeboxed sessions and sessions that have expired due
to inactivity timeout.

It achieves backward compatibility with sessions that have `null` in
`refreshed_at` by looking at the `updated_at` column of the refresh
tokens table. This approach is the one that puts the least strain on the
database, having considered backfilling (very expensive at least
`O(nlogn)` over the whole refresh tokens table).
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
Adds the ability for sessions to time-out after a period of inactivity.
"Activity" is defined as refreshing the session.

This can be configured by setting the
`GOTRUE_SESSIONS_INACTIVITY_TIMEOUT` to a duration.

Since this PR modifies the database by adding a new `refreshed_at`
nullable column to `sessions`, it also adds some useful columns to the
`sessions` table to track the `User-Agent` and IP address that performed
the refresh / session creation.
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
…e#1298)

Builds on top of supabase#1288.

Adds cleanup for timeboxed sessions and sessions that have expired due
to inactivity timeout.

It achieves backward compatibility with sessions that have `null` in
`refreshed_at` by looking at the `updated_at` column of the refresh
tokens table. This approach is the one that puts the least strain on the
database, having considered backfilling (very expensive at least
`O(nlogn)` over the whole refresh tokens table).
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
Adds the ability for sessions to time-out after a period of inactivity.
"Activity" is defined as refreshing the session.

This can be configured by setting the
`GOTRUE_SESSIONS_INACTIVITY_TIMEOUT` to a duration.

Since this PR modifies the database by adding a new `refreshed_at`
nullable column to `sessions`, it also adds some useful columns to the
`sessions` table to track the `User-Agent` and IP address that performed
the refresh / session creation.
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 15, 2024
…e#1298)

Builds on top of supabase#1288.

Adds cleanup for timeboxed sessions and sessions that have expired due
to inactivity timeout.

It achieves backward compatibility with sessions that have `null` in
`refreshed_at` by looking at the `updated_at` column of the refresh
tokens table. This approach is the one that puts the least strain on the
database, having considered backfilling (very expensive at least
`O(nlogn)` over the whole refresh tokens table).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants