[GH-ISSUE #2955] Support for Team-Specific Roles #9411

Closed
opened 2026-04-13 04:51:24 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @sifr42 on GitHub (Jun 9, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2955

Is this suited for github?

  • Yes, this is suited for github

The Organization Plugin assigns organization-level roles. Users can also be assigned to Teams. However, a user's role within a Team is their general organization-level role. This limits scenarios where a user needs different capabilities within a specific Team compared to their overall organization role, or different capabilities across various Teams (if multi-team membership per organization is ever implemented).

For example, an organization_user might need to be a project_manager for a specific Team (managing that Team's projects), while remaining a standard user organization-wide.

Describe the solution you'd like

We propose enabling the assignment of explicit, distinct roles to a user for each Team they are a member of.

This could involve:

  • A team_role field specified when adding a user to a Team, distinct from their organization_role.
  • The AccessControl system defining permissions for these team roles (e.g., team_project_manager can project:create_in_team, project:update_team_project).
  • The userContext would then include both organizationRoles and an activeTeamRole.

Describe alternatives you've considered

Custom Database Table: Managing team-specific roles externally. Native support would be cleaner.
Complex Application Logic: Deriving "effective" team permissions solely from organization roles and team context, which lacks clarity for distinct team responsibilities.

Additional context

Native team-specific roles would significantly enhance the Organization Plugin's flexibility for multi-tenant apps with varied access needs within Teams (e.g., a user managing "projects" only for a specific client Team they belong to). This is a common requirement for granular RBAC.

Originally created by @sifr42 on GitHub (Jun 9, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2955 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. The Organization Plugin assigns organization-level roles. Users can also be assigned to Teams. However, a user's role within a Team is their general organization-level role. This limits scenarios where a user needs different capabilities within a specific Team compared to their overall organization role, or different capabilities across various Teams (if multi-team membership per organization is ever implemented). For example, an organization_user might need to be a project_manager for a specific Team (managing that Team's projects), while remaining a standard user organization-wide. ### Describe the solution you'd like We propose enabling the assignment of explicit, distinct roles to a user for each Team they are a member of. This could involve: - A team_role field specified when adding a user to a Team, distinct from their organization_role. - The AccessControl system defining permissions for these team roles (e.g., team_project_manager can project:create_in_team, project:update_team_project). - The userContext would then include both organizationRoles and an activeTeamRole. ### Describe alternatives you've considered Custom Database Table: Managing team-specific roles externally. Native support would be cleaner. Complex Application Logic: Deriving "effective" team permissions solely from organization roles and team context, which lacks clarity for distinct team responsibilities. ### Additional context Native team-specific roles would significantly enhance the Organization Plugin's flexibility for multi-tenant apps with varied access needs within Teams (e.g., a user managing "projects" only for a specific client Team they belong to). This is a common requirement for granular RBAC.
GiteaMirror added the locked label 2026-04-13 04:51:24 -05:00
Author
Owner

@JPustkuchen commented on GitHub (Jun 13, 2025):

Sounds similar to https://github.com/better-auth/better-auth/discussions/2130 ?

<!-- gh-comment-id:2969436804 --> @JPustkuchen commented on GitHub (Jun 13, 2025): Sounds similar to https://github.com/better-auth/better-auth/discussions/2130 ?
Author
Owner

@dosubot[bot] commented on GitHub (Sep 12, 2025):

Hi, @d-d-developer. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested enhanced role management in the Organization Plugin to support distinct, team-specific roles for users.
  • The proposal includes adding a team_role field and updating the AccessControl system for native support.
  • A maintainer noted the similarity to a related discussion (#2130), indicating this feature is under consideration but not yet resolved.
  • No further updates or progress have been made recently on this issue.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3285855210 --> @dosubot[bot] commented on GitHub (Sep 12, 2025): Hi, @d-d-developer. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested enhanced role management in the Organization Plugin to support distinct, team-specific roles for users. - The proposal includes adding a `team_role` field and updating the AccessControl system for native support. - A maintainer noted the similarity to a related discussion (#2130), indicating this feature is under consideration but not yet resolved. - No further updates or progress have been made recently on this issue. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open. - Otherwise, this issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Author
Owner

@Saibaba161 commented on GitHub (Sep 13, 2025):

Hey, this issue is still relevant. We still need this

<!-- gh-comment-id:3287555276 --> @Saibaba161 commented on GitHub (Sep 13, 2025): Hey, this issue is still relevant. We still need this
Author
Owner

@JPustkuchen commented on GitHub (Sep 16, 2025):

Same here, this would be a fantastic feature! But please also note https://github.com/better-auth/better-auth/discussions/2130

<!-- gh-comment-id:3296670074 --> @JPustkuchen commented on GitHub (Sep 16, 2025): Same here, this would be a fantastic feature! But please also note https://github.com/better-auth/better-auth/discussions/2130
Author
Owner

@XavierGeerinck commented on GitHub (Nov 1, 2025):

FYI: Gave this a shot in #5718

<!-- gh-comment-id:3476348573 --> @XavierGeerinck commented on GitHub (Nov 1, 2025): FYI: Gave this a shot in #5718
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 1, 2025):

You can move forward by trying an implementation that extends the team membership API so it accepts a separate team_role field alongside the organization_role. This means updating the logic that sets the membership—ensure the user context is enhanced to include an activeTeamRole and that the AccessControl system is modified to check for permissions granted by these team-specific roles (for example, allowing a team_project_manager to perform project-related actions within that team only) [1].

Since you mentioned that you already tried something in the related issue (#5718), the next steps would be to:

• Verify that the team_role field is correctly stored and retrieved when a user joins a team.
• Update the permission-checking middleware to include team-specific checks, so that operations like project creation within a team actually reference the team_role permissions.
• Ensure that your user context now contains both organizationRoles and the activeTeamRole so that the client-side access control views and decisions are based on both levels of roles.
• Test edge cases such as multi-team membership and switching between teams to confirm that the appropriate permissions are consistently applied.

If any issues arise during these modifications, check that the new field isn’t conflicting with existing organization-level role checks, and consider adding logging or debug output to your AccessControl routines to trace which permissions are being evaluated [1], [2].

Let me know if you need further clarification on any of these steps.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3476348727 --> @better-auth-agent[bot] commented on GitHub (Nov 1, 2025): You can move forward by trying an implementation that extends the team membership API so it accepts a separate team_role field alongside the organization_role. This means updating the logic that sets the membership—ensure the user context is enhanced to include an activeTeamRole and that the AccessControl system is modified to check for permissions granted by these team-specific roles (for example, allowing a team_project_manager to perform project-related actions within that team only) [[1]](https://github.com/better-auth/better-auth/issues/2955). Since you mentioned that you already tried something in the related issue (#5718), the next steps would be to: • Verify that the team_role field is correctly stored and retrieved when a user joins a team. • Update the permission-checking middleware to include team-specific checks, so that operations like project creation within a team actually reference the team_role permissions. • Ensure that your user context now contains both organizationRoles and the activeTeamRole so that the client-side access control views and decisions are based on both levels of roles. • Test edge cases such as multi-team membership and switching between teams to confirm that the appropriate permissions are consistently applied. If any issues arise during these modifications, check that the new field isn’t conflicting with existing organization-level role checks, and consider adding logging or debug output to your AccessControl routines to trace which permissions are being evaluated [[1]](https://github.com/better-auth/better-auth/issues/2955), [[2]](https://github.com/better-auth/better-auth/issues/4493). Let me know if you need further clarification on any of these steps. <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@dosubot[bot] commented on GitHub (Jan 31, 2026):

Hi, @sifr42. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested support for team-specific roles in the Organization Plugin for finer access control.
  • A maintainer noted its similarity to an ongoing discussion in issue #2130.
  • Another user confirmed the feature is still needed.
  • A contributor attempted an implementation via PR #5718.
  • I provided guidance on extending APIs to support this, but no final resolution yet.

Next Steps:

  • Please let me know if this feature is still relevant to the latest version of better-auth by commenting on this issue.
  • If I don’t hear back within 7 days, the issue will be automatically closed.

Thanks for your understanding and contribution!

<!-- gh-comment-id:3828772726 --> @dosubot[bot] commented on GitHub (Jan 31, 2026): Hi, @sifr42. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested support for team-specific roles in the Organization Plugin for finer access control. - A maintainer noted its similarity to an ongoing discussion in issue #2130. - Another user confirmed the feature is still needed. - A contributor attempted an implementation via PR #5718. - I provided guidance on extending APIs to support this, but no final resolution yet. **Next Steps:** - Please let me know if this feature is still relevant to the latest version of better-auth by commenting on this issue. - If I don’t hear back within 7 days, the issue will be automatically closed. Thanks for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9411