-
Notifications
You must be signed in to change notification settings - Fork 334
[WPB-24977] Allow suspended users to keep their cookies. #5204
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
Open
fisx
wants to merge
24
commits into
develop
Choose a base branch
from
WPB-24977-allow-suspended-apps-to-keep-their-cookies
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c4b98f0
Changelog.
fisx 77d3d88
Integration test.
fisx 0d30919
Reject access token refresh requests from suspended users.
fisx a4cc869
Do not evict cookies on suspend.
fisx 0441978
Allow unsuspended users to login even if inactive.
fisx 27ddb21
More precise haddocks
fisx 6992909
Fix boolean logic bug.
fisx 2e17ca0
Better effect action name.
fisx 9c34bc0
Extend changelog entry.
fisx ab78d2a
Better changelog entry.
fisx d1a4f32
Better haddocks.
fisx adee0cf
Better guard logic: reduce responsibilities of caller.
fisx d585b08
Integration tests: always test labels when testing error status.
fisx f92101e
Rewrite integration test: inline functions.
fisx 52aa695
Undo change to original cookie revokation semantics.
fisx a4daa7f
Remove redundant constraints.
fisx 2f57f5c
Fix: catchSuspendedUsers should do nothing on non-existing users.
fisx 3e7063c
Haddocks.
fisx b7cf041
Rm dead code.
fisx 212c45a
Fix ancient (and previously harmless) bug in brig integration tests.
fisx 874e503
Adjust brig integration test to new behavior.
fisx e8857d1
Keep track of user inactivity in postgres and without cookies.
fisx 97fdaa8
Update postgres schema dump.
fisx 02a3f32
Remove redundant polysemy constraints.
fisx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog.d/2-features/WPB-24977-allow-suspended-apps-to-keep-their-cookies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Allow suspended users to keep their cookies, but disallow them to create/refresh access tokens. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
libs/wire-subsystems/postgres-migrations/20260519120000-create-last-user-activity.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| CREATE TABLE last_user_activity ( | ||
| user_id uuid PRIMARY KEY, | ||
| active_at timestamptz NOT NULL | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| {-# LANGUAGE TemplateHaskell #-} | ||
|
|
||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2026 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Wire.UserActivityStore where | ||
|
|
||
| import Data.Id | ||
| import Data.Time.Clock | ||
| import Imports | ||
| import Polysemy | ||
|
|
||
| data UserActivityStore m a where | ||
| GetLastActivity :: UserId -> UserActivityStore m (Maybe UTCTime) | ||
| UpdateLastActivity :: UserId -> UTCTime -> UserActivityStore m () | ||
| DeleteLastActivity :: UserId -> UserActivityStore m () | ||
|
|
||
| makeSem ''UserActivityStore |
64 changes: 64 additions & 0 deletions
64
libs/wire-subsystems/src/Wire/UserActivityStore/Postgres.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| {-# LANGUAGE QuasiQuotes #-} | ||
|
|
||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2026 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Wire.UserActivityStore.Postgres | ||
| ( interpretUserActivityStoreToPostgres, | ||
| ) | ||
| where | ||
|
|
||
| import Data.Id | ||
| import Data.Time.Clock | ||
| import Hasql.TH | ||
| import Imports | ||
| import Polysemy | ||
| import Wire.Postgres | ||
| import Wire.UserActivityStore | ||
|
|
||
| interpretUserActivityStoreToPostgres :: | ||
| (PGConstraints r) => | ||
| InterpreterFor UserActivityStore r | ||
| interpretUserActivityStoreToPostgres = interpret $ \case | ||
| GetLastActivity uid -> getLastActivityImpl uid | ||
| UpdateLastActivity uid t -> updateLastActivityImpl uid t | ||
| DeleteLastActivity uid -> deleteLastActivityImpl uid | ||
|
|
||
| getLastActivityImpl :: (PGConstraints r) => UserId -> Sem r (Maybe UTCTime) | ||
| getLastActivityImpl uid = | ||
| runStatement (toUUID uid) $ | ||
| [maybeStatement| | ||
| SELECT active_at :: timestamptz | ||
| FROM last_user_activity | ||
| WHERE user_id = $1 :: uuid | ||
| |] | ||
|
|
||
| updateLastActivityImpl :: (PGConstraints r) => UserId -> UTCTime -> Sem r () | ||
| updateLastActivityImpl uid t = | ||
| runStatement (toUUID uid, t) $ | ||
| [resultlessStatement| | ||
| INSERT INTO last_user_activity (user_id, active_at) | ||
| VALUES ($1 :: uuid, $2 :: timestamptz) | ||
| ON CONFLICT (user_id) DO UPDATE SET active_at = EXCLUDED.active_at | ||
|
|
||
| |] | ||
|
|
||
| deleteLastActivityImpl :: (PGConstraints r) => UserId -> Sem r () | ||
| deleteLastActivityImpl uid = | ||
| runStatement (toUUID uid) $ | ||
| [resultlessStatement| | ||
| DELETE FROM last_user_activity WHERE user_id = $1 :: uuid | ||
| |] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.