Files
supabase/apps/studio/data/sso
25120657db feat(sso): improve SSO management UX (safe deletion + invitation type selection) (#43615)
## feat(sso): improve SSO management UX (safe deletion + invitation type
selection)

This PR improves the SSO management experience by introducing a safer
deletion flow for SSO providers and allowing explicit control over
invitation authentication type.

## SSO Provider Deletion Improvements

The SSO provider deletion flow has been redesigned to better communicate
the impact of the action and prevent accidental destructive operations.

### UX Improvements

* Replace `ConfirmationModal` with `TextConfirmModal` in `SSOConfig`
* Require typing the SSO domain to confirm deletion
* Display the number of organization members authenticating via SSO who
will be removed
* Add destructive visual styling and clear warnings about irreversible
consequences
* Update confirmation button label to emphasize impact:

  * `I understand, delete SSO provider and members`

### Warning Content

The modal now clearly communicates:

* The domain being deleted
* That SSO authentication will be disabled
* That SSO-authenticated members will be permanently removed
* That those members must be re-invited to regain access

If SSO members exist, a highlighted destructive warning box shows:

```
X organization member(s) who authenticate via SSO will be permanently removed
```

### Implementation Details

* Add `useOrganizationMembersQuery` to fetch organization members
* Calculate SSO members by filtering `is_sso_user === true`
* Only display the member warning when the count > 0
* Modal uses `variant="destructive"` and `size="small"`

This pattern follows the existing **Delete organization** confirmation
flow.

### Initial Delete Support

This PR also introduces the underlying deletion functionality:

* Add `useSSOConfigDeleteMutation`
* Add delete button (trash icon, danger styling) in the SSO config
footer
* Layout mirrors `CustomDomainDelete` pattern:

  * delete button on the left
  * save/cancel actions on the right
* Success toast shown after deletion
* Form resets to explicit default values after deletion

## Invitation Type Selection

Organizations with SSO configured can now explicitly choose the
authentication method when inviting new members.

Previously, invitations always inherited the inviter's authentication
method. This made it difficult to support mixed authentication
organizations.

### New Invitation Options

When SSO is enabled, the invite dialog now shows an **Invitation type**
dropdown:

* **Automatic (based on your account)**
  Default behavior; inherits authentication method from the inviter.

* **Require SSO authentication**
  Sends an SSO invitation.

* **Email/password authentication**
  Sends a non-SSO invitation.

### Implementation Details

* Add `useOrgSSOConfigQuery` to detect if SSO is configured
* Add `requireSso` field to the form schema with enum:

  * `auto`
  * `sso`
  * `non-sso`
* Only display the dropdown when the organization has an SSO provider
* Transform form values before sending to the backend:

```
sso -> { requireSso: true }
non-sso -> { requireSso: false }
auto -> {} (omit parameter)
```

* Update `OrganizationCreateInvitationVariables` to include optional
`requireSso`
* Preserve backward compatibility by only sending the field when
explicitly set

## Bug Fixes

* Attribute mapping preset buttons (Azure, GSuite, Okta) now properly
mark the form as dirty so the save button becomes enabled
* Form reset after deletion now uses explicit default values instead of
the last saved state

## Problems Solved

This PR addresses several UX issues:

1. Deleting an SSO provider previously used a simple confirmation with
no explanation of impact
2. Users could not see how many members would be affected by deletion
3. The destructive and irreversible nature of the action was not
visually emphasized
4. Invitations always inherited the inviter's auth method
5. Organizations could not intentionally mix SSO and non-SSO users

## Types

TypeScript types in `api-types` were updated to support the new
`require_sso` parameter.

---------

Co-authored-by: Chris Stockton <chris.stockton@supabase.io>
Co-authored-by: Ali Waseem <waseema393@gmail.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-03-16 09:56:06 -07:00
..