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

syn2mas: migrate access tokens, refresh tokens and devices #3926

Merged
merged 11 commits into from
Feb 5, 2025

Conversation

reivilibre
Copy link
Contributor

We also now support deviceless access tokens/compat_sessions, human names on compat_sessions and the migration of guests.

Commit-by-commit suggested! :)

@reivilibre reivilibre requested a review from sandhose January 30, 2025 18:52
@reivilibre reivilibre force-pushed the rei/syn2mas_8_atrtdevs branch from 3cf7796 to 4db2158 Compare January 30, 2025 18:55
Copy link

cloudflare-workers-and-pages bot commented Jan 30, 2025

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7181cc8
Status: ✅  Deploy successful!
Preview URL: https://41221c0f.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://rei-syn2mas-8-atrtdevs.matrix-authentication-service-docs.pages.dev

View logs

@reivilibre reivilibre force-pushed the rei/syn2mas_8_atrtdevs branch from 4db2158 to d0e9ea2 Compare January 30, 2025 18:57
migrator = "MIGRATOR",
fixtures("user_alice", "access_token_alice_with_refresh_token")
)]
async fn test_read_access_and_refresh_tokens(pool: PgPool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to have test for the annoying edge cases of like a token which was refreshed but not yet used, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a test

@@ -204,9 +204,9 @@ impl CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'_> {
r#"
UPDATE compat_refresh_tokens
SET consumed_at = $2
WHERE compat_refresh_token_id = $1
WHERE compat_session_id = $1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add AND consumed_at IS NULL, so that we don't update all the refresh tokens consumed ts

Also, you need to change/remove the DatabaseError::ensure_affected_rows(&res, 1) bellow, else it will error out if there are more than one row affected

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did that in 59e25c0

Ok(SynapseRowCounts { users })
let devices = sqlx::query_scalar(
"
SELECT COUNT(1) FROM devices
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHERE NOT hidden? else we'll count the cross signing devices as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did that in d823aff

created_at,
is_synapse_admin: synapse_admins.contains(&user_id),
last_active_at: last_seen.map(DateTime::from),
last_active_ip: ip.map(|ip| ip.parse()).transpose().ok().flatten(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor, but maybe we should log a warning if for some reason that doesn't parse? That would help us in test runs we're not loosing a bunch of IPs here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did that in 0efbff8

.to_owned();
let Some(user_id) = user_localparts_to_uuid.get(username.as_str()).copied() else {
return Err(Error::MissingUserFromDependentTable {
table: "devices".to_owned(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't notice before, but curious why this is a String and not a &'static str?

@sandhose sandhose force-pushed the rei/syn2mas_8_atrtdevs branch from 0efbff8 to 7181cc8 Compare February 5, 2025 10:42
@sandhose sandhose merged commit f0e14ee into main Feb 5, 2025
21 checks passed
@sandhose sandhose deleted the rei/syn2mas_8_atrtdevs branch February 5, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants