-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apiserver: ensure at most one session per device (#398)
* Database migrations to ensure at most one session per device * fix: don't sync Kolide devices continuously if integration is disabled * Inserts to session table will overwrite existing session with matching device id * Delete invalid sessions from session store * Write tests for session cache store * Bump Go version in asdf co-authored-by: @sechmann
- Loading branch information
Showing
8 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
golang 1.22.4 | ||
golang 1.22.5 | ||
protoc 23.4 | ||
protoc-gen-go 1.31.0 | ||
protoc-gen-go-grpc 1.3.0 |
This file contains 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 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 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 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
3 changes: 3 additions & 0 deletions
3
internal/apiserver/database/schema/0006_unique_device_id_in_sessions.down.sql
This file contains 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,3 @@ | ||
-- No changes necessary | ||
|
||
DROP INDEX sessions_device_id_unique; |
10 changes: 10 additions & 0 deletions
10
internal/apiserver/database/schema/0006_unique_device_id_in_sessions.up.sql
This file contains 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,10 @@ | ||
-- Delete all sessions for all device_id's, except the most recent session for each user. | ||
DELETE FROM sessions AS s | ||
WHERE key != | ||
(SELECT key FROM sessions | ||
WHERE device_id = s.device_id | ||
ORDER BY expiry DESC | ||
LIMIT 1) | ||
; | ||
|
||
CREATE UNIQUE INDEX sessions_device_id_unique ON sessions (device_id); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.