[GH-ISSUE #3011] hasPermission fails when called with multiple permissions if those permissions are granted by different roles #26757

Open
opened 2026-04-17 17:26:05 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @harveylee on GitHub (Jun 13, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3011

Originally assigned to: @ping-maxwell on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

See https://stackblitz.com/edit/stackblitz-starters-wsvsumaj?file=index.js (node ./index.js to start)

  1. Use Organization plugin with two custom roles, each with a single custom permission (say, role AUser has a: use-a and role BUser has b: use-b)
  2. Assign both roles to one user
  3. Call hasPermission with each permission separately - both succeed
  4. Call hasPermission on both permissions together - fails

Current vs. Expected behavior

Expected: if user has the roles that grant permission A and permission B, then hasPermission on the union of those permissions (A and B) should also succeed
Actual: hasPermission returns success === false

What version of Better Auth are you using?

1.2.9

Provide environment information

- OS: Windows 11 Build 26100
- WSL2: Linux 6.6.87.1-microsoft-standard-WSL2 
- Debian trixie

Which area(s) are affected? (Select all that apply)

Backend, Client, Package

Auth config (if applicable)

See Stackblitz repro

Additional context

I think the reason is because the permissions for the roles are checked independently, and no single role has all of the requested permissions.

The way I expected this to work is that the permissions for all the roles are gathered first, and then those permissions are checked against the requested permissions.

Originally created by @harveylee on GitHub (Jun 13, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3011 Originally assigned to: @ping-maxwell on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce See https://stackblitz.com/edit/stackblitz-starters-wsvsumaj?file=index.js (`node ./index.js` to start) 1. Use Organization plugin with two custom roles, each with a single custom permission (say, role AUser has `a: use-a` and role BUser has `b: use-b`) 2. Assign both roles to one user 3. Call `hasPermission` with each permission separately - both succeed 4. Call `hasPermission` on both permissions together - fails ### Current vs. Expected behavior Expected: if user has the roles that grant permission A and permission B, then `hasPermission` on the union of those permissions (A and B) should also succeed Actual: `hasPermission` returns `success === false` ### What version of Better Auth are you using? 1.2.9 ### Provide environment information ```bash - OS: Windows 11 Build 26100 - WSL2: Linux 6.6.87.1-microsoft-standard-WSL2 - Debian trixie ``` ### Which area(s) are affected? (Select all that apply) Backend, Client, Package ### Auth config (if applicable) ```typescript See Stackblitz repro ``` ### Additional context I think the reason is because the permissions for the roles are checked independently, and no single role has all of the requested permissions. The way I expected this to work is that the permissions for all the roles are gathered first, and then those permissions are checked against the requested permissions.
GiteaMirror added the bugorganization labels 2026-04-17 17:26:05 -05:00
Author
Owner

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

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

Issue Summary

  • You reported that the hasPermission function in Better Auth v1.2.9 returns false when checking multiple permissions granted across different roles.
  • The problem occurs because the function checks permissions per role instead of aggregating them across all roles.
  • You provided a Stackblitz reproduction to demonstrate the issue.
  • There have been no further comments or updates on this issue.

Next Steps

  • Please let me know if this issue is still relevant with 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:3285855199 --> @dosubot[bot] commented on GitHub (Sep 12, 2025): Hi, @harveylee. 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 reported that the `hasPermission` function in Better Auth v1.2.9 returns false when checking multiple permissions granted across different roles. - The problem occurs because the function checks permissions per role instead of aggregating them across all roles. - You provided a Stackblitz reproduction to demonstrate the issue. - There have been no further comments or updates on this issue. **Next Steps** - Please let me know if this issue is still relevant with 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

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

Still occurs in 1.3.9. I updated the Stackblitz repro (still at https://stackblitz.com/edit/stackblitz-starters-wsvsumaj?file=index.js)

<!-- gh-comment-id:3287602048 --> @harveylee commented on GitHub (Sep 13, 2025): Still occurs in 1.3.9. I updated the Stackblitz repro (still at https://stackblitz.com/edit/stackblitz-starters-wsvsumaj?file=index.js)
Author
Owner

@dosubot[bot] commented on GitHub (Dec 13, 2025):

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

Issue Summary

  • You reported that the hasPermission function returns false when checking multiple permissions granted across different roles.
  • The problem arises because hasPermission checks permissions per role instead of aggregating them.
  • You confirmed the issue still occurs in version 1.3.9 and provided an updated reproduction link.
  • The maintainers have yet to address the permission aggregation logic in hasPermission.

Next Steps

  • Please confirm if this issue is still relevant with the latest version of better-auth by commenting on this issue.
  • If no response is received, I will automatically close this issue in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3649576693 --> @dosubot[bot] commented on GitHub (Dec 13, 2025): Hi, @harveylee. 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 reported that the `hasPermission` function returns false when checking multiple permissions granted across different roles. - The problem arises because `hasPermission` checks permissions per role instead of aggregating them. - You confirmed the issue still occurs in version 1.3.9 and provided an updated reproduction link. - The maintainers have yet to address the permission aggregation logic in `hasPermission`. **Next Steps** - Please confirm if this issue is still relevant with the latest version of better-auth by commenting on this issue. - If no response is received, I will automatically close this issue in 7 days. Thank you for your understanding and contribution!
Author
Owner

@harveylee commented on GitHub (Dec 15, 2025):

Hello. This is still an issue in better-auth 1.4.7. I have updated the Stackblitz reproduciton again
https://stackblitz.com/edit/stackblitz-starters-wsvsumaj

<!-- gh-comment-id:3652762058 --> @harveylee commented on GitHub (Dec 15, 2025): Hello. This is still an issue in better-auth 1.4.7. I have updated the Stackblitz reproduciton again https://stackblitz.com/edit/stackblitz-starters-wsvsumaj
Author
Owner

@dosubot[bot] commented on GitHub (Mar 16, 2026):

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

Issue Summary:

  • You reported that the hasPermission method incorrectly returns false when checking multiple permissions granted across different roles.
  • The method currently checks permissions per role instead of aggregating them, causing incorrect results.
  • Despite updates to better-auth up to version 1.4.7, the issue persists.
  • You have provided updated Stackblitz reproductions each time to demonstrate the problem.
  • The issue has been marked as stale twice before, and you confirmed it remains unresolved.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of better-auth by commenting on this issue.
  • If I do not hear back within 7 days, I will automatically close the issue.

Thank you for your understanding and contribution!

<!-- gh-comment-id:4068840865 --> @dosubot[bot] commented on GitHub (Mar 16, 2026): Hi, @harveylee. 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 reported that the `hasPermission` method incorrectly returns false when checking multiple permissions granted across different roles. - The method currently checks permissions per role instead of aggregating them, causing incorrect results. - Despite updates to better-auth up to version 1.4.7, the issue persists. - You have provided updated Stackblitz reproductions each time to demonstrate the problem. - The issue has been marked as stale twice before, and you confirmed it remains unresolved. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of better-auth by commenting on this issue. - If I do not hear back within 7 days, I will automatically close the issue. Thank you for your understanding and contribution!
Author
Owner

@harveylee commented on GitHub (Mar 18, 2026):

Still an issue in v1.5.5

Updated repro:
https://codesandbox.io/p/devbox/better-auth-org-permissions-1-5-5-vrl3jn

<!-- gh-comment-id:4085916471 --> @harveylee commented on GitHub (Mar 18, 2026): Still an issue in v1.5.5 Updated repro: https://codesandbox.io/p/devbox/better-auth-org-permissions-1-5-5-vrl3jn
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26757