Skip to content

fix: require INVITE_EXTERNAL_USERS for externalInvitations query#1384

Open
damsleth wants to merge 1 commit into
devfrom
fix/external-invitations-auth
Open

fix: require INVITE_EXTERNAL_USERS for externalInvitations query#1384
damsleth wants to merge 1 commit into
devfrom
fix/external-invitations-auth

Conversation

@damsleth
Copy link
Copy Markdown
Member

Summary

  • Add @Authorized<IAuthOptions>({ scope: PermissionScope.INVITE_EXTERNAL_USERS }) to the externalInvitations query so read access matches the gating already in place on inviteExternalUser and cancelExternalInvitation. Before this change, any authenticated tenant user could fetch the list of pending invitations (names, emails, inviter).
  • The field is bundled inside the Admin Users UsersAdmin query, which ACCESS_ADMIN users open without necessarily holding INVITE_EXTERNAL_USERS. To avoid a FORBIDDEN on that shared query, guard the field with @include(if: \$includeInvitations) and derive the variable client-side via usePermissions.
  • Add resolver tests covering the authorized / unauthorized / empty-permissions branches against the shared auth checker.

Test plan

  • npm run lint passes
  • npm test passes for the new SubscriptionResolver tests (3 added); pre-existing unrelated TS2694/TS2339 failures in ReportService / extensions / passport index remain unchanged on this branch and on base
  • Smoke: admin with INVITE_EXTERNAL_USERS sees pending invitations on Admin > Users
  • Smoke: admin without INVITE_EXTERNAL_USERS opens Admin > Users with no error and no invitations list
  • Smoke: non-admin user cannot call externalInvitations directly (receives FORBIDDEN)

Read access to the pending external-user invitations list (names, emails,
inviter) now matches the write access required by inviteExternalUser and
cancelExternalInvitation. Previously any authenticated tenant user could
fetch it.

The invitations field is bundled into the UsersAdmin query, so the Admin
Users tab would otherwise 403 for admins lacking INVITE_EXTERNAL_USERS.
Guard the field with @include(if: $includeInvitations) and derive the
variable client-side via usePermissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant