The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(role): Allow eligible organizations to invite users as 'No-access' base role (#50922)
Tanun Turbo Chalermsinsuwan77e3b4382f62
diff --git a/apps/docs/content/guides/platform/access-control.mdx b/apps/docs/content/guides/platform/access-control.mdxindex 73bea005159..36717e0e9e8 100644--- a/apps/docs/content/guides/platform/access-control.mdx+++ b/apps/docs/content/guides/platform/access-control.mdx@@ -11,10 +11,11 @@ For each organization and project, a member can have one of the following roles:- **Administrator**: full access to everything in organization and project resources **except** updating organization settings, transferring projects outside of the organization, and adding new owners.- **Developer**: read-only access to organization resources and content access to project resources but cannot change any project settings.- **Read-Only**: read-only access to organization and project resources.+- **No-access**: no access to any organization or project resources by default. Use this for members who should only see the specific projects they're granted a [project-scoped role](#organization-scoped-roles-vs-project-scoped-roles) on.<Admonition type="note">-Read-Only role is only available on the [Team and Enterprise plans](/pricing).+Read-Only and No-access roles are only available on the [Team and Enterprise plans](/pricing).</Admonition>@@ -67,6 +68,8 @@ Each member in the organization can be assigned a role that is scoped either toThis allows for more granular control, ensuring that users only have visibility and access to the projects relevant to their role.+To default a member to zero project access and grant access on a per-project basis, assign them the organization-level **No access** role, then grant project-scoped roles for the specific projects they need. The **No-access** role is omitted from the permission tables below since it has none of the listed permissions by default.+### Organization permissions across rolesThe table below shows the actions each role can take on the resources belonging to the organization.diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsxindex 516b9ed8a26..c9976e5bed0 100644--- a/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx+++ b/apps/studio/components/interfaces/Organization/TeamSettings/InviteMemberButton.tsx@@ -358,12 +358,20 @@ export const InviteMemberButton = () => {const canAssignRole = rolesAddable.includes(role.id)const isOwnerRole = role.name === 'Owner'const disabledForStripe = isStripeProjectsOrg && isOwnerRole- const disabled = !canAssignRole || disabledForStripe++ const isNoAccessRole = role.name === 'No-access'+ const isApplyingProjectRole = !applyToOrg+ const disabledForProjectRole = isApplyingProjectRole && isNoAccessRole++ const disabled =+ !canAssignRole || disabledForStripe || disabledForProjectRoleconst disabledReason = disabledForStripe? 'Cannot be assigned in Stripe Projects organizations'- : !canAssignRole- ? 'Additional permissions required to assign role'- : undefined+ : disabledForProjectRole+ ? 'Cannot assign No-access role to project-scoped members'+ : !canAssignRole+ ? 'Additional permissions required to assign role'+ : undefinedreturn (<FormItem asChild key={role.id}>diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/Roles.constants.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/Roles.constants.tsxindex a3759ad9ca9..30b7ec2d957 100644--- a/apps/studio/components/interfaces/Organization/TeamSettings/Roles.constants.tsx+++ b/apps/studio/components/interfaces/Organization/TeamSettings/Roles.constants.tsx@@ -17,4 +17,5 @@ export const ROLE_DESCRIPTIONS: Record<string, ReactNode> = {'Manage project content, including deleting data, users, files, and Edge Functions. Cannot change settings or delete projects.','Read-only':'View resources without modifying or deleting them. SQL Editor access is limited to SELECT queries.',+ 'No-access': 'No access to any organization or project resources',}diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.tsxindex c4470ea1bac..b57a713e1c7 100644--- a/apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.tsx+++ b/apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.tsx@@ -282,12 +282,19 @@ export const UpdateRolesPanel = ({ visible, member, onClose }: UpdateRolesPanelPconst canAssignRole = rolesAddable.includes(role.id)const isOwnerRole = role.name === 'Owner'const disabledForStripe = isStripeProjectsOrg && isOwnerRole- const disabled = !canAssignRole || disabledForStripe++ const isNoAccessRole = role.name === 'No-access'+ const disabledForProjectRole =+ !isApplyingRoleToAllProjects && isNoAccessRole+ const disabled =+ !canAssignRole || disabledForStripe || disabledForProjectRoleconst disabledReason = disabledForStripe? 'Cannot be assigned in Stripe Projects organizations'- : !canAssignRole- ? 'Additional permissions required to assign role'- : undefined+ : disabledForProjectRole+ ? 'Cannot assign No-access role to project-scoped members'+ : !canAssignRole+ ? 'Additional permissions required to assign role'+ : undefinedreturn (<SelectItemdiff --git a/apps/studio/data/organization-members/organization-roles-query.ts b/apps/studio/data/organization-members/organization-roles-query.tsindex 826f3029eba..669d1a8de5f 100644--- a/apps/studio/data/organization-members/organization-roles-query.ts+++ b/apps/studio/data/organization-members/organization-roles-query.ts@@ -5,7 +5,7 @@ import { organizationKeys } from './keys'import { get, handleError } from '@/data/fetchers'import type { ResponseError, UseCustomQueryOptions } from '@/types'-export const FIXED_ROLE_ORDER = ['Owner', 'Administrator', 'Developer', 'Read-only']+export const FIXED_ROLE_ORDER = ['Owner', 'Administrator', 'Developer', 'Read-only', 'None']export type OrganizationRolesVariables = { slug?: string }export type OrganizationRolesResponse = components['schemas']['OrganizationRoleResponse_Output']export type OrganizationRole =@@ -50,8 +50,17 @@ export const useOrganizationRolesV2Query = <TData = OrganizationRolesData>(.sort((a, b) => {return FIXED_ROLE_ORDER.indexOf(a.name) - FIXED_ROLE_ORDER.indexOf(b.name)})- .filter((role) => FIXED_ROLE_ORDER.includes(role.name)),+ .filter((role) => FIXED_ROLE_ORDER.includes(role.name))+ .map((role) => ({ ...role, name: getOverrideRoleName(role.name) })),} as TData},...options,})++const OVERRIDE_ROLE_NAMES: Record<string, string> = {+ None: 'No-access',+}++export function getOverrideRoleName(rolename: string) {+ return OVERRIDE_ROLE_NAMES[rolename] ?? rolename+}