-
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
f0c1879
Changelog.
fisx 1509a7c
Integration test.
fisx 800379a
Reject access token refresh requests from suspended users.
fisx fb1e2fd
Do not evict cookies on suspend.
fisx 5fcf1a6
Allow unsuspended users to login even if inactive.
fisx 68212d5
More precise haddocks
fisx 45ccb2d
Fix boolean logic bug.
fisx 0f95018
Better effect action name.
fisx 2f38f63
Extend changelog entry.
fisx 8c40151
Better changelog entry.
fisx 23ba81c
Better haddocks.
fisx aab85c0
Better guard logic: reduce responsibilities of caller.
fisx c854b3d
Integration tests: always test labels when testing error status.
fisx 414ce3a
Rewrite integration test: inline functions.
fisx 2e6f067
Undo change to original cookie revokation semantics.
fisx 267353e
Remove redundant constraints.
fisx a445907
Fix: catchSuspendedUsers should do nothing on non-existing users.
fisx 98a20a0
Haddocks.
fisx 0cef09d
Rm dead code.
fisx e6372bf
Fix ancient (and previously harmless) bug in brig integration tests.
fisx 704b677
Adjust brig integration test to new behavior.
fisx 2da2222
Keep track of user inactivity in postgres and without cookies.
fisx 49d2f65
Update postgres schema dump.
fisx 3abd1ae
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.