-
Notifications
You must be signed in to change notification settings - Fork 68
Option to skip confirmation when registering through an upstream OAuth provider #5296
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
base: quenting/upstream-oauth/better-conflict-options
Are you sure you want to change the base?
Option to skip confirmation when registering through an upstream OAuth provider #5296
Conversation
Deploying matrix-authentication-service-docs with
|
| 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 |
…uenting/upstream-oauth/skip-interactive
There was a problem hiding this 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_confirmationboolean field to OAuth2 provider claims configuration - Refactors user registration logic into a reusable
prepare_user_registrationhelper 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.
| 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(®istration).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(), | ||
| )); | ||
| } |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
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.
| 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()); | ||
| } | ||
| } |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
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:
- When
skip_confirmationistrue, the validation fails iflocalpart.actionis notrequire - When
skip_confirmationistrue, the validation fails ifemail.actionordisplayname.actionissuggest - When
skip_confirmationisfalse, these constraints are not enforced
This helps prevent regressions in the validation logic.
There was a problem hiding this 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.
No description provided.