Enforce Membership Validation for getFullOrganization Endpoint #544

Closed
opened 2026-03-13 07:52:09 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @msywulak on GitHub (Jan 9, 2025).

Is this suited for github?

  • Yes, this is suited for github

Currently, the getFullOrganization endpoint allows any user to retrieve an organization's details by providing a valid organizationId or organizationSlug, regardless of their membership in that organization. This can lead to unauthorized data access and security concerns.

Describe the solution you'd like

The getFullOrganization endpoint should validate that the requesting user is a member of the organization before returning its details. This can be implemented by:

  • Fetching the list of organizations the user belongs to (using adapter.listOrganizations or a similar method).
  • Checking whether the provided organizationId or organizationSlug matches any of the organizations the user is a member of.
  • Returning an appropriate error (e.g., ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION) if the user is not a member.

Describe alternatives you've considered

  1. Adding middleware to enforce this check globally for endpoints accessing organization details.
  2. Relying on a session-bound activeOrganizationId but this is insufficient as it doesn't handle organizationSlug.

Additional context

  • This change would align the behavior of getFullOrganization with other endpoints like listOrganizations, which inherently filters results based on the user's membership.
  • Suggested Error Code: ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION.
  • Example Use Case: Preventing unauthorized users from accessing sensitive organization metadata by simply knowing a valid organizationId or organizationSlug.
Originally created by @msywulak on GitHub (Jan 9, 2025). ### Is this suited for github? - [X] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Currently, the `getFullOrganization` endpoint allows any user to retrieve an organization's details by providing a valid `organizationId` or `organizationSlug`, regardless of their membership in that organization. This can lead to unauthorized data access and security concerns. ### Describe the solution you'd like The `getFullOrganization` endpoint should validate that the requesting user is a member of the organization before returning its details. This can be implemented by: - Fetching the list of organizations the user belongs to (using `adapter.listOrganizations` or a similar method). - Checking whether the provided `organizationId` or `organizationSlug` matches any of the organizations the user is a member of. - Returning an appropriate error (e.g., `ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION`) if the user is not a member. ### Describe alternatives you've considered 1. Adding middleware to enforce this check globally for endpoints accessing organization details. 2. Relying on a session-bound `activeOrganizationId` but this is insufficient as it doesn't handle `organizationSlug`. ### Additional context - This change would align the behavior of getFullOrganization with other endpoints like listOrganizations, which inherently filters results based on the user's membership. - Suggested Error Code: `ORGANIZATION_ERROR_CODES.USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION`. - Example Use Case: Preventing unauthorized users from accessing sensitive organization metadata by simply knowing a valid organizationId or organizationSlug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#544