The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Remove checking of permissions for places which are not in scope
Joshen Limb10aed8f2f05
diff --git a/studio/components/interfaces/Authentication/Templates.tsx b/studio/components/interfaces/Authentication/Templates.tsxindex 30dc1eb3457..f8bbd23ee66 100644--- a/studio/components/interfaces/Authentication/Templates.tsx+++ b/studio/components/interfaces/Authentication/Templates.tsx@@ -17,16 +17,17 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'const Templates: FC<any> = ({ project }) => {const router = useRouter()const { ui } = useStore()- const canUpdate = checkPermissions(- PermissionAction.SQL_UPDATE,- 'postgres.public.custom_config_gotrue'- )const magicLinkEnable = semver.gte(// @ts-ignoresemver.coerce(toJS(project?.kpsVersion) || 'kps-v0.0.1'),semver.coerce('kps-v2.5.3'))+ const canUpdateTemplates = checkPermissions(+ PermissionAction.SQL_UPDATE,+ 'postgres.public.custom_config_gotrue'+ )+const { config, error, mutateAuthConfig } = useProjectAuthConfig(project.ref)if (error) {return (@@ -72,7 +73,6 @@ const Templates: FC<any> = ({ project }) => {readOnly={!IS_PLATFORM}inputClassName="font-mono"errorMessage="Please enter an sms body."- disabled={!canUpdate}/></SchemaFormPanel></div>@@ -94,7 +94,6 @@ const Templates: FC<any> = ({ project }) => {name="MAILER_SUBJECTS_CONFIRMATION"readOnly={!IS_PLATFORM}errorMessage="Please enter a subject."- disabled={!canUpdate}/><LongTextFieldshowInlineError@@ -103,7 +102,6 @@ const Templates: FC<any> = ({ project }) => {readOnly={!IS_PLATFORM}inputClassName="font-mono"errorMessage="Please enter an email body."- disabled={!canUpdate}/></SchemaFormPanel></div>@@ -125,7 +123,6 @@ const Templates: FC<any> = ({ project }) => {name="MAILER_SUBJECTS_RECOVERY"readOnly={!IS_PLATFORM}errorMessage="Please enter a subject."- disabled={!canUpdate}/><LongTextFieldshowInlineError@@ -134,7 +131,6 @@ const Templates: FC<any> = ({ project }) => {readOnly={!IS_PLATFORM}inputClassName="font-mono"errorMessage="Please enter an email body."- disabled={!canUpdate}/></SchemaFormPanel></div>@@ -157,7 +153,6 @@ const Templates: FC<any> = ({ project }) => {name="MAILER_SUBJECTS_MAGIC_LINK"readOnly={!IS_PLATFORM}errorMessage="Please enter a subject."- disabled={!canUpdate}/><LongTextFieldshowInlineError@@ -166,7 +161,6 @@ const Templates: FC<any> = ({ project }) => {readOnly={!IS_PLATFORM}inputClassName="font-mono"errorMessage="Please enter an email body."- disabled={!canUpdate}/></SchemaFormPanel></div>@@ -189,7 +183,6 @@ const Templates: FC<any> = ({ project }) => {name="MAILER_SUBJECTS_EMAIL_CHANGE"readOnly={!IS_PLATFORM}errorMessage="Please enter a subject."- disabled={!canUpdate}/><LongTextFieldshowInlineError@@ -198,7 +191,6 @@ const Templates: FC<any> = ({ project }) => {readOnly={!IS_PLATFORM}inputClassName="font-mono"errorMessage="Please enter an email body."- disabled={!canUpdate}/></SchemaFormPanel></div>@@ -220,7 +212,6 @@ const Templates: FC<any> = ({ project }) => {name="MAILER_SUBJECTS_INVITE"readOnly={!IS_PLATFORM}errorMessage="Please enter a subject."- disabled={!canUpdate}/><LongTextFieldshowInlineError@@ -229,7 +220,6 @@ const Templates: FC<any> = ({ project }) => {readOnly={!IS_PLATFORM}inputClassName="font-mono"errorMessage="Please enter an email body."- disabled={!canUpdate}/></SchemaFormPanel></div>diff --git a/studio/components/interfaces/Billing/Subscription/Subscription.tsx b/studio/components/interfaces/Billing/Subscription/Subscription.tsxindex a4964994f6a..bd2293490ca 100644--- a/studio/components/interfaces/Billing/Subscription/Subscription.tsx+++ b/studio/components/interfaces/Billing/Subscription/Subscription.tsx@@ -1,15 +1,14 @@-import { Button, Loading } from '@supabase/ui'import dayjs from 'dayjs'+import { FC } from 'react'import { sum } from 'lodash'import { useRouter } from 'next/router'-import { FC } from 'react'+import { Button, Loading } from '@supabase/ui'+import { PermissionAction } from '@supabase/shared-types/out/constants'-import { checkPermissions, useStore } from 'hooks'+import { checkPermissions, useStore, useFlag } from 'hooks'import { STRIPE_PRODUCT_IDS } from 'lib/constants'import { formatBytes } from 'lib/helpers'-import { PermissionAction } from '@supabase/shared-types/out/constants'-import { useFlag } from 'hooks'import { PRICING_TIER_PRODUCT_IDS } from 'lib/constants'import { chargeableProducts } from '../PAYGUsage/PAYGUsage.constants'import { PaygStats, ProductFeature } from '../PAYGUsage/PAYGUsage.types'diff --git a/studio/components/interfaces/TableGridEditor/EmptyState.tsx b/studio/components/interfaces/TableGridEditor/EmptyState.tsxindex 818977aadc6..c96fd4a0009 100644--- a/studio/components/interfaces/TableGridEditor/EmptyState.tsx+++ b/studio/components/interfaces/TableGridEditor/EmptyState.tsx@@ -11,18 +11,18 @@ interface Props {const EmptyState: FC<Props> = ({ selectedSchema, onAddTable }) => {const { meta } = useStore()- const canCreate = checkPermissions(PermissionAction.TENANT_SQL_CREATE_TABLE, 'postgres.public')const tables = meta.tables.list((table: PostgresTable) => table.schema === selectedSchema)+ const canCreateTables = checkPermissions(+ PermissionAction.TENANT_SQL_CREATE_TABLE,+ 'postgres.public'+ )+const renderNoTablesCTA = () => {return (<div className="flex flex-col items-center justify-center space-y-4"><p className="text-sm">There are no tables available in this schema</p>- {selectedSchema === 'public' && (- <Button onClick={onAddTable} disabled={!canCreate}>- Create a new table- </Button>- )}+ {selectedSchema === 'public' && <Button onClick={onAddTable}>Create a new table</Button>}</div>)}@@ -34,9 +34,7 @@ const EmptyState: FC<Props> = ({ selectedSchema, onAddTable }) => {) : (<div className="flex flex-col items-center space-y-4"><p className="text-sm">Select a table or create a new one</p>- <Button onClick={onAddTable} disabled={!canCreate}>- Create a new table- </Button>+ <Button onClick={onAddTable}>Create a new table</Button></div>)}</div>diff --git a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsxindex ede253f2660..ec9eb877257 100644--- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx@@ -68,7 +68,6 @@ const TableGridEditor: FC<Props> = ({const canInsert = checkPermissions(PermissionAction.TENANT_SQL_INSERT, String(tableId))const canUpdate = checkPermissions(PermissionAction.TENANT_SQL_UPDATE, String(tableId))// const canEdit = canAdminWrite && canInsert && canUpdate- const canEdit = true// @ts-ignoreconst schema = meta.schemas.list().find((schema) => schema.name === selectedSchema)@@ -145,7 +144,7 @@ const TableGridEditor: FC<Props> = ({theme={theme}gridProps={{ height: '100%' }}storageRef={projectRef}- editable={!isViewSelected && !isLocked && canEdit}+ editable={!isViewSelected && !isLocked}schema={selectedTable.schema}table={gridTable}headerActions={diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsxindex 468728720e4..6c0d846faa5 100644--- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx+++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx@@ -1,9 +1,9 @@-import { Button, Dropdown, IconHome, IconSettings, IconUser } from '@supabase/ui'+import Link from 'next/link'+import { FC } from 'react'import { isUndefined } from 'lodash'import { observer } from 'mobx-react-lite'-import Link from 'next/link'import { useRouter } from 'next/router'-import { FC } from 'react'+import { Button, Dropdown, IconHome, IconSettings, IconUser } from '@supabase/ui'import { useFlag, useStore } from 'hooks'import { IS_PLATFORM } from 'lib/constants'diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsxindex b20adb78ffe..be88a785db2 100644--- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx+++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx@@ -32,7 +32,7 @@ export const generateProductRoutes = (ref: string, project?: ProjectBase): Route/>),link: isProjectBuilding ? buildingUrl : `/project/${ref}/editor`,- hidden: !checkPermissions(PermissionAction.SQL_SELECT, 'postgres.public'),+ // disabled: !checkPermissions(PermissionAction.SQL_SELECT, 'postgres.public'),},{key: 'auth',@@ -40,13 +40,16 @@ export const generateProductRoutes = (ref: string, project?: ProjectBase): Routeicon: <IconUsers size={18} strokeWidth={2} />,link: isProjectBuilding ? buildingUrl : `/project/${ref}/auth/users`,},- {- key: 'storage',- label: 'Storage',- icon: <IconArchive size={18} strokeWidth={2} />,- link: isProjectBuilding ? buildingUrl : `/project/${ref}/storage/buckets`,- hidden: !IS_PLATFORM,- },+ ...(IS_PLATFORM+ ? [+ {+ key: 'storage',+ label: 'Storage',+ icon: <IconArchive size={18} strokeWidth={2} />,+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/storage/buckets`,+ },+ ]+ : []),{key: 'sql',label: 'SQL Editor',@@ -98,33 +101,42 @@ export const generateOtherRoutes = (ref: string, project?: ProjectBase): Route[])return [- {- key: 'logs-explorer',- label: 'Logs Explorer',- icon: <IconList size={18} strokeWidth={2} />,- link: isProjectBuilding ? buildingUrl : `/project/${ref}/logs-explorer`,- hidden: !IS_PLATFORM,- },- {- key: 'reports',- label: 'Reports',- icon: <IconBarChart size={18} strokeWidth={2} />,- link: isProjectBuilding ? buildingUrl : `/project/${ref}/reports`,- hidden: !IS_PLATFORM || !canReadReport || !canReadStats,- },+ ...(IS_PLATFORM+ ? [+ {+ key: 'logs-explorer',+ label: 'Logs Explorer',+ icon: <IconList size={18} strokeWidth={2} />,+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/logs-explorer`,+ },+ ]+ : []),+ ...(IS_PLATFORM+ ? [+ {+ key: 'reports',+ label: 'Reports',+ icon: <IconBarChart size={18} strokeWidth={2} />,+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/reports`,+ },+ ]+ : []),{key: 'api',label: 'API',icon: <IconFileText size={18} strokeWidth={2} />,link: isProjectBuilding ? buildingUrl : `/project/${ref}/api`,},- {- key: 'settings',- label: 'Settings',- icon: <IconSettings size={18} strokeWidth={2} />,- link: `/project/${ref}/settings/general`,- hidden:- !IS_PLATFORM || !checkPermissions(PermissionAction.SQL_SELECT, 'postgres.public.projects'),- },+ ...(IS_PLATFORM+ ? [+ {+ key: 'settings',+ label: 'Settings',+ icon: <IconSettings size={18} strokeWidth={2} />,+ link: `/project/${ref}/settings/general`,+ // disabled: !checkPermissions(PermissionAction.SQL_SELECT, 'postgres.public.projects'),+ },+ ]+ : []),]}diff --git a/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts b/studio/components/layouts/SettingsLayout/SettingsMenu.utils.tsindex 7042a751fd8..f2fb7aa6848 100644--- a/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts+++ b/studio/components/layouts/SettingsLayout/SettingsMenu.utils.ts@@ -8,6 +8,7 @@ export const generateSettingsMenu = (ref: string, project?: ProjectBase): Producconst isProjectBuilding = project?.status !== PROJECT_STATUS.ACTIVE_HEALTHYconst buildingUrl = `/project/${ref}/building`+ const canReadStorage = checkPermissions(PermissionAction.STORAGE_ADMIN_READ, '*')const canReadInvoices = checkPermissions(PermissionAction.BILLING_READ, 'stripe.invoices')const canReadSubscriptions = checkPermissions(PermissionAction.BILLING_READ,@@ -47,14 +48,14 @@ export const generateSettingsMenu = (ref: string, project?: ProjectBase): Produckey: 'storage',url: isProjectBuilding ? buildingUrl : `/project/${ref}/storage/settings`,items: [],- hidden: !checkPermissions(PermissionAction.STORAGE_ADMIN_READ, '*'),+ // disabled: canReadStorage,},{name: 'Billing & Usage',key: 'billing',url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/billing`,items: [],- hidden: canReadInvoices && canReadSubscriptions,+ // disabled: canReadInvoices && canReadSubscriptions,},],},diff --git a/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx b/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsxindex 94cf99d1956..6d8a5e8ec5f 100644--- a/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx+++ b/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx@@ -60,7 +60,10 @@ const TableEditorMenu: FC<Props> = ({const [searchText, setSearchText] = useState<string>('')const [schemaViews, setSchemaViews] = useState<SchemaView[]>([])const [isRefreshing, setIsRefreshing] = useState<boolean>(false)- const canCreate = checkPermissions(PermissionAction.TENANT_SQL_CREATE_TABLE, 'postgres.public.*')+ const canCreateTables = checkPermissions(+ PermissionAction.TENANT_SQL_CREATE_TABLE,+ 'postgres.public.*'+ )// We may need to shift this to the schema store and do something like meta.schema.loadViews()// I don't need we need a separate store for viewsdiff --git a/studio/components/ui/ProductMenu/ProductMenu.tsx b/studio/components/ui/ProductMenu/ProductMenu.tsxindex 71000b977b9..c0544b03459 100644--- a/studio/components/ui/ProductMenu/ProductMenu.tsx+++ b/studio/components/ui/ProductMenu/ProductMenu.tsx@@ -26,19 +26,17 @@ const ProductMenu: FC<Props> = ({ page, menu }) => {}/><div>- {group.items- .filter(({ hidden }) => !hidden)- .map((item: ProductMenuGroupItem) => (- <ProductMenuItem- key={item.key}- url={item.url}- name={item.name}- icon={item.icon}- isActive={page === item.key}- isExternal={item.isExternal}- target={item.isExternal ? '_blank' : '_self'}- />- ))}+ {group.items.map((item: ProductMenuGroupItem) => (+ <ProductMenuItem+ key={item.key}+ url={item.url}+ name={item.name}+ icon={item.icon}+ isActive={page === item.key}+ isExternal={item.isExternal}+ target={item.isExternal ? '_blank' : '_self'}+ />+ ))}</div></div></div>diff --git a/studio/components/ui/ProductMenu/ProductMenu.types.ts b/studio/components/ui/ProductMenu/ProductMenu.types.tsindex 1b5162d0f13..876dc3ffec0 100644--- a/studio/components/ui/ProductMenu/ProductMenu.types.ts+++ b/studio/components/ui/ProductMenu/ProductMenu.types.ts@@ -13,5 +13,5 @@ export interface ProductMenuGroupItem {items: any[]icon?: ReactNodeisExternal?: boolean- hidden?: boolean+ disabled?: boolean}diff --git a/studio/components/ui/ui.types.ts b/studio/components/ui/ui.types.tsindex 4f0dba09e34..a6726a5d8d7 100644--- a/studio/components/ui/ui.types.ts+++ b/studio/components/ui/ui.types.ts@@ -5,5 +5,5 @@ export interface Route {label: stringicon: ReactNodelink: string- hidden?: boolean+ disabled?: boolean}diff --git a/studio/pages/project/[ref]/auth/settings.tsx b/studio/pages/project/[ref]/auth/settings.tsxindex ff84896c17b..0ac9c8774e2 100644--- a/studio/pages/project/[ref]/auth/settings.tsx+++ b/studio/pages/project/[ref]/auth/settings.tsx@@ -1,10 +1,9 @@-import { observer } from 'mobx-react-lite'import { useEffect } from 'react'-+import { observer } from 'mobx-react-lite'import { PermissionAction } from '@supabase/shared-types/out/constants'-import { checkPermissions, useStore } from 'hooks'-import { NextPageWithLayout } from 'types'+import { NextPageWithLayout } from 'types'+import { checkPermissions, useStore } from 'hooks'import { AuthProvidersForm } from 'components/interfaces'import AutoSchemaForm from 'components/interfaces/Auth/AutoSchemaForm'import RedirectDomains from 'components/interfaces/Auth/RedirectDomains/RedirectDomains'diff --git a/studio/pages/project/[ref]/reports/[id].tsx b/studio/pages/project/[ref]/reports/[id].tsxindex a746c3beb13..c4d9f1a7b65 100644--- a/studio/pages/project/[ref]/reports/[id].tsx+++ b/studio/pages/project/[ref]/reports/[id].tsx@@ -1,4 +1,4 @@-import React, { useEffect, useState } from 'react'+import { useEffect, useState } from 'react'import RGL, { WidthProvider } from 'react-grid-layout'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'@@ -69,9 +69,7 @@ const Reports = () => {const canSaveReport = checkPermissions(PermissionAction.SQL_UPDATE,'postgres.public.user_content',- {- resource: { type: 'report' },- }+ { resource: { type: 'report' } })const contentStore = useProjectContentStore(ref)@@ -302,12 +300,7 @@ const Reports = () => {<Dropdown.Checkboxkey={metric.key}checked={config.layout?.find((x: any) => x.attribute === metric.key)}- onChange={(e) =>- handleChartSelection({- metric,- value: e,- })- }+ onChange={(e) => handleChartSelection({ metric, value: e })}><div className="flex flex-col space-y-0"><span>{metric.label}</span>@@ -368,7 +361,7 @@ const Reports = () => {<Badge color="green">There are unsaved changes</Badge></div>)}- {canSaveReport && hasEdits && (+ {hasEdits && (<Buttontype={!hasEdits ? 'default' : 'primary'}disabled={!hasEdits}diff --git a/studio/pages/project/[ref]/reports/index.tsx b/studio/pages/project/[ref]/reports/index.tsxindex fa2cbe16efd..78e7021edb5 100644--- a/studio/pages/project/[ref]/reports/index.tsx+++ b/studio/pages/project/[ref]/reports/index.tsx@@ -1,18 +1,17 @@import { useEffect, useState } from 'react'import { observer } from 'mobx-react-lite'import { useRouter } from 'next/router'+import { PermissionAction } from '@supabase/shared-types/out/constants'-import { API_URL, PROJECT_STATUS } from 'lib/constants'+import { NextPageWithLayout } from 'types'import { checkPermissions, useStore } from 'hooks'import { post } from 'lib/common/fetch'-import { ProjectLayoutWithAuth } from 'components/layouts'+import { API_URL, PROJECT_STATUS } from 'lib/constants'+import { useProjectContentStore } from 'stores/projectContentStore'import Loading from 'components/ui/Loading'+import { ProjectLayoutWithAuth } from 'components/layouts'import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'--import { useProjectContentStore } from 'stores/projectContentStore'import { createReport } from 'components/to-be-cleaned/Reports/Reports.utils'-import { NextPageWithLayout } from 'types'-import { PermissionAction } from '@supabase/shared-types/out/constants'const PageLayout: NextPageWithLayout = () => {const [loading, setLoading] = useState(true)@@ -26,11 +25,7 @@ const PageLayout: NextPageWithLayout = () => {const canCreateReport = checkPermissions(PermissionAction.SQL_INSERT,'postgres.public.user_content',- {- resource: {- type: 'report',- },- }+ { resource: { type: 'report' } })const contentStore = useProjectContentStore(ref)@@ -63,8 +58,6 @@ const PageLayout: NextPageWithLayout = () => {<ProductEmptyStatetitle="Reports"ctaButtonLabel="Create report"- // infoButtonLabel="About reports"- // infoButtonUrl="https://supabase.com/docs/guides/storage"onClickCta={() => {try {createReport({ router })@@ -75,7 +68,6 @@ const PageLayout: NextPageWithLayout = () => {})}}}- disabled={!canCreateReport}><p className="text-scale-1100 text-sm">Create custom reports for your projects.</p><p className="text-scale-1100 text-sm">diff --git a/studio/stores/UiStore.ts b/studio/stores/UiStore.tsindex b4444a0e6ac..a79d1279e27 100644--- a/studio/stores/UiStore.ts+++ b/studio/stores/UiStore.ts@@ -16,7 +16,7 @@ export interface IUiStore {selectedOrganization?: Organizationnotification?: Notificationprofile?: User- permissions?: any // todo: type this+ permissions?: any // [Joshen TODO]: type thisload: () => voidsetTheme: (theme: 'dark' | 'light') => voidonThemeOptionChange: (themeOption: 'dark' | 'light' | 'system') => void@@ -24,7 +24,7 @@ export interface IUiStore {setOrganizationSlug: (slug?: string) => voidsetNotification: (notification: Notification) => stringsetProfile: (value?: User) => void- setPermissions: (permissions?: any) => void // todo: type this+ setPermissions: (permissions?: any) => void // [Joshen TODO]: type this}export default class UiStore implements IUiStore {rootStore: IRootStore@@ -36,7 +36,7 @@ export default class UiStore implements IUiStore {selectedOrganizationSlug?: stringnotification?: Notificationprofile?: User- permissions?: any = [] // todo: define this+ permissions?: any = [] // [Joshen TODO]: define thisconstructor(rootStore: IRootStore) {this.rootStore = rootStore