Skip to content

Conversation

@sandhose
Copy link
Member

No description provided.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 28, 2025

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

Latest commit: df14076
Status: ✅  Deploy successful!
Preview URL: https://c43c9637.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://quenting-upstream-oauth-skip.matrix-authentication-service-docs.pages.dev

View logs

@sandhose sandhose changed the base branch from main to quenting/upstream-oauth/better-conflict-options November 28, 2025 17:09
@sandhose sandhose changed the base branch from quenting/upstream-oauth/better-conflict-options to main November 28, 2025 17:11
@sandhose sandhose changed the base branch from main to quenting/upstream-oauth/better-conflict-options November 28, 2025 17:11
@sandhose sandhose requested a review from Copilot November 28, 2025 17:12
Copilot finished reviewing on behalf of sandhose November 28, 2025 17:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a skip_confirmation option for upstream OAuth2 providers, allowing users to bypass the interactive confirmation screen when registering through an OAuth provider. The implementation includes validation to ensure data integrity when this feature is enabled, requiring that localpart is mandatory and other attributes cannot be set to "suggest" mode. The PR also includes several fixes: a typo correction ("exitting" → "exiting"), a bug fix for displayname validation, removal of obsolete set_email_verification documentation, and documentation improvements including a new Shibboleth integration guide.

  • Adds skip_confirmation boolean field to OAuth2 provider claims configuration
  • Refactors user registration logic into a reusable prepare_user_registration helper function
  • Adds configuration validation ensuring safe usage of skip_confirmation feature
  • Updates documentation to reflect removed email verification field and adds Shibboleth setup guide

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
docs/setup/sso.md Removes obsolete set_email_verification configuration from examples and adds new Shibboleth integration documentation
docs/reference/configuration.md Removes set_email_verification documentation and adds skip_confirmation option documentation with usage requirements
docs/reference/cli/manage.md Updates issue-user-registration-token documentation to clarify usage limits and add --unlimited flag
docs/config.schema.json Adds skip_confirmation field schema and updates email description to remove email_verified claim reference
crates/handlers/src/upstream_oauth2/link.rs Implements skip_confirmation flow, refactors registration logic into helper function, fixes typo and displayname bug
crates/data-model/src/upstream_oauth2/provider.rs Adds skip_confirmation field to ClaimsImports struct
crates/config/src/sections/upstream_oauth2.rs Adds validation logic for skip_confirmation, ensures safe configuration, updates is_default method
crates/cli/src/sync.rs Maps skip_confirmation field from config to data model during synchronization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +768 to +810
if provider.claims_imports.skip_confirmation {
let Some(localpart) = localpart else {
return Err(RouteError::Internal(
"No localpart available even though the provider is configured to skip confirmation, this is a bug!".into()
));
};

// Register on the fly
REGISTRATION_COUNTER.add(1, &[KeyValue::new(PROVIDER, provider.id.to_string())]);

let registration = prepare_user_registration(
&mut rng,
&clock,
&mut repo,
upstream_session,
localpart,
displayname,
email,
activity_tracker.ip(),
user_agent,
post_auth_action.map(|action| serde_json::json!(action)),
)
.await?;

let registrations = UserRegistrationSessionsCookie::load(&cookie_jar);

let cookie_jar = sessions_cookie
.consume_link(link_id)?
.save(cookie_jar, &clock);

let cookie_jar = registrations.add(&registration).save(cookie_jar, &clock);

repo.save().await?;

// Redirect to the user registration flow, in case we have any other step to
// finish
return Ok((
cookie_jar,
url_builder
.redirect(&mas_router::RegisterFinish::new(registration.id))
.into_response(),
));
}
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

The new skip_confirmation feature lacks test coverage. Consider adding a test case that verifies the behavior when skip_confirmation is set to true, ensuring that the user registration is created automatically without showing the confirmation screen, and that the redirect to RegisterFinish occurs correctly.

Copilot uses AI. Check for mistakes.
Comment on lines +121 to +139
if provider.claims_imports.skip_confirmation {
if provider.claims_imports.localpart.action != ImportAction::Require {
return Err(annotate(figment::Error::custom(
"The field `action` must be `require` when `skip_confirmation` is set to `true`",
)).with_path("claims_imports.localpart").into());
}

if provider.claims_imports.email.action == ImportAction::Suggest {
return Err(annotate(figment::Error::custom(
"The field `action` must not be `suggest` when `skip_confirmation` is set to `true`",
)).with_path("claims_imports.email").into());
}

if provider.claims_imports.displayname.action == ImportAction::Suggest {
return Err(annotate(figment::Error::custom(
"The field `action` must not be `suggest` when `skip_confirmation` is set to `true`",
)).with_path("claims_imports.displayname").into());
}
}
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

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

Consider adding validation tests for the new skip_confirmation feature to ensure that:

  1. When skip_confirmation is true, the validation fails if localpart.action is not require
  2. When skip_confirmation is true, the validation fails if email.action or displayname.action is suggest
  3. When skip_confirmation is false, these constraints are not enforced

This helps prevent regressions in the validation logic.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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