[PR #8613] fix(sso): include owner role in organization provisioning types #16345

Open
opened 2026-04-13 10:29:56 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8613

State: open
Merged: No


Summary

This PR fixes #8604, a type mismatch in the SSO plugin where organization provisioning role types were too narrow and excluded "owner".

Problem

In SSO organization provisioning, TypeScript only allowed "member" or "admin" in exported role unions.
This caused downstream type errors when checking for "owner", even though "owner" is a valid default organization role.

Root Cause

The public SSO types in packages/sso/src/types.ts were hardcoded to:

  • defaultRole?: "member" | "admin"
  • getRole?: (...) => Promise<"member" | "admin">

This did not match organization role defaults.

Changes

1) Type updates

Updated packages/sso/src/types.ts:

  • defaultRole now supports "member" | "admin" | "owner"
  • getRole return type now supports Promise<"member" | "admin" | "owner">

2) Regression tests

Added tests in packages/sso/src/linking/org-assignment.test.ts:

  • assigns "owner" when provisioningOptions.defaultRole = "owner"
  • assigns "owner" when provisioningOptions.getRole returns "owner"

Why this is safe

  • Runtime assignment path already supports string roles.
  • This change aligns type definitions with valid existing behavior.
  • No breaking API or runtime behavior changes.

Validation

  • SSO package typecheck passed.
  • Focused test file passed: src/linking/org-assignment.test.ts (10/10).

Breaking Changes

None.


Summary by cubic

Allow the "owner" role in SSO organization provisioning types to fix type errors and match valid default roles. This aligns TypeScript types with existing runtime behavior.

  • Bug Fixes
    • Update packages/sso/src/types.ts: include "owner" in defaultRole and getRole return types.
    • Add tests in packages/sso/src/linking/org-assignment.test.ts verifying "owner" is assigned via defaultRole or getRole.

Written for commit 795e947ea5. Summary will update on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8613 **State:** open **Merged:** No --- ## Summary This PR fixes #8604, a type mismatch in the SSO plugin where organization provisioning role types were too narrow and excluded `"owner"`. ## Problem In SSO organization provisioning, TypeScript only allowed `"member"` or `"admin"` in exported role unions. This caused downstream type errors when checking for `"owner"`, even though `"owner"` is a valid default organization role. ## Root Cause The public SSO types in [packages/sso/src/types.ts](packages/sso/src/types.ts) were hardcoded to: - `defaultRole?: "member" | "admin"` - `getRole?: (...) => Promise<"member" | "admin">` This did not match organization role defaults. ## Changes ### 1) Type updates Updated [packages/sso/src/types.ts](packages/sso/src/types.ts): - `defaultRole` now supports `"member" | "admin" | "owner"` - `getRole` return type now supports `Promise<"member" | "admin" | "owner">` ### 2) Regression tests Added tests in [packages/sso/src/linking/org-assignment.test.ts](packages/sso/src/linking/org-assignment.test.ts): - assigns `"owner"` when `provisioningOptions.defaultRole = "owner"` - assigns `"owner"` when `provisioningOptions.getRole` returns `"owner"` ## Why this is safe - Runtime assignment path already supports string roles. - This change aligns type definitions with valid existing behavior. - No breaking API or runtime behavior changes. ## Validation - SSO package typecheck passed. - Focused test file passed: `src/linking/org-assignment.test.ts` (10/10). ## Breaking Changes None. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Allow the "owner" role in SSO organization provisioning types to fix type errors and match valid default roles. This aligns TypeScript types with existing runtime behavior. - **Bug Fixes** - Update `packages/sso/src/types.ts`: include "owner" in `defaultRole` and `getRole` return types. - Add tests in `packages/sso/src/linking/org-assignment.test.ts` verifying "owner" is assigned via `defaultRole` or `getRole`. <sup>Written for commit 795e947ea5ab582599b97c8029075f7b5a973ddf. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 10:29:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16345