Skip to content

Commit 1b0b6a3

Browse files
committed
syn2mas: warn about existing oauth-delegated user_external_ids
1 parent 6f281b1 commit 1b0b6a3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

crates/syn2mas/src/synapse_reader/checks.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ pub enum CheckError {
7373
)]
7474
SynapseMissingOAuthProvider { provider: String, num_users: i64 },
7575

76+
#[error(
77+
"Synapse database has {num_users} mapping entries from a previously-configured MAS instance. If this is from a previous migration attempt, run the following SQL query against the Synapse database: `DELETE FROM user_external_ids WHERE auth_provider = 'oauth-delegated';` and then run the migration again."
78+
)]
79+
ExistingOAuthDelegated { num_users: i64 },
80+
7681
#[error(
7782
"Synapse config contains an OpenID Connect or OAuth2 provider '{provider}' (issuer: {issuer:?}) used by {num_users} users which must also be configured in the MAS configuration as an upstream provider."
7883
)]
@@ -292,6 +297,14 @@ pub async fn synapse_database_check(
292297
let syn_oauth2 = synapse.all_oidc_providers();
293298
let mas_oauth2 = UpstreamOAuth2Config::extract_or_default(mas)?;
294299
for row in oauth_provider_user_counts {
300+
// This is a special case of a previous migration attempt to MAS
301+
if row.auth_provider == "oauth-delegated" {
302+
errors.push(CheckError::ExistingOAuthDelegated {
303+
num_users: row.num_users,
304+
});
305+
continue;
306+
}
307+
295308
let matching_syn = syn_oauth2.get(&row.auth_provider);
296309

297310
let Some(matching_syn) = matching_syn else {

0 commit comments

Comments
 (0)