Skip to content

[codex] Require org admin for SSO provider registration - #196

Merged
salasebas merged 1 commit into
mainfrom
codex/ope-182-sso-admin-registration
Jul 2, 2026
Merged

[codex] Require org admin for SSO provider registration#196
salasebas merged 1 commit into
mainfrom
codex/ope-182-sso-admin-registration

Conversation

@salasebas

Copy link
Copy Markdown
Owner

Summary

Fixes OPE-182.

RustAuth now requires an organization admin or owner role before a user can register or attach an organization-scoped SSO provider. This intentionally diverges from Better Auth 1.6.9 because provider registration establishes the trust anchor used by SSO auto-provisioning.

Root Cause

POST /sso/register accepted an organizationId when the authenticated user was any member of that organization. The provider was then persisted as organization-scoped, and successful SSO callbacks could auto-provision users into that organization.

Changes

  • Reuse the existing org admin/owner role check for organization-scoped provider registration.
  • Return ORGANIZATION_ADMIN_REQUIRED for registration/update attempts that only have membership.
  • Add regression tests for non-member rejection, plain-member rejection, and admin success.
  • Keep SSO auto-provisioning behavior unchanged.

Validation

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p rustauth-sso --all-features -> 346 passed

Linear: OPE-182

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
rustauth-docs-site Ignored Ignored Jul 2, 2026 7:56am

@salasebas
salasebas marked this pull request as ready for review July 2, 2026 08:16
@salasebas
salasebas merged commit 2a540ab into main Jul 2, 2026
23 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78419f36bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return Ok(true);
}
is_org_member(adapter, user_id, organization_id).await
is_org_admin(adapter, user_id, organization_id).await

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor custom creator roles for org SSO registration

When the organization plugin uses a non-default creator_role such as founder, org creation stores that value as the creator's member role and the organization permission code treats it as owner-equivalent. This new is_org_admin path only accepts literal owner/admin, so those owner-equivalent creators now receive ORGANIZATION_ADMIN_REQUIRED from /sso/register or when attaching a provider, even though they are the configured organization owners. Consider including the configured creator role (or the org permission check) in this predicate.

Useful? React with 👍 / 👎.

@github-actions github-actions Bot mentioned this pull request Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant