Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update network restrictions to support IPv6 (#20548)

Joshen Lim89a96c788aab
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
index 2f6ac1f6c3d..2345d14f00d 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
@@ -1,6 +1,5 @@
import * as Tooltip from '@radix-ui/react-tooltip'
import { useParams } from 'common'
-import { useState } from 'react'
import toast from 'react-hot-toast'
import { Button, Form, IconHelpCircle, Input, Modal } from 'ui'
@@ -12,22 +11,31 @@ import {
isValidAddress,
normalize,
} from './NetworkRestrictions.utils'
+import { useNetworkRestrictionsQuery } from 'data/network-restrictions/network-restrictions-query'
+
+const IPV4_MAX_CIDR_BLOCK_SIZE = 32
+const IPV6_MAX_CIDR_BLOCK_SIZE = 128
interface AddRestrictionModalProps {
- restrictedIps: string[]
- visible: boolean
+ type?: 'IPv4' | 'IPv6'
hasOverachingRestriction: boolean
onClose: () => void
}
const AddRestrictionModal = ({
- restrictedIps,
- visible,
+ type,
hasOverachingRestriction,
onClose,
}: AddRestrictionModalProps) => {
const formId = 'add-restriction-form'
const { ref } = useParams()
+
+ const { data } = useNetworkRestrictionsQuery({ projectRef: ref })
+ const ipv4Restrictions = data?.config?.dbAllowedCidrs ?? []
+ // @ts-ignore [Joshen] API typing issue
+ const ipv6Restrictions = data?.config?.dbAllowedCidrsV6 ?? []
+ const restrictedIps = ipv4Restrictions.concat(ipv6Restrictions)
+
const { mutate: applyNetworkRestrictions, isLoading: isApplying } =
useNetworkRestrictionsApplyMutation({
onSuccess: () => {
@@ -38,12 +46,20 @@ const AddRestrictionModal = ({
const validate = (values: any) => {
const errors: any = {}
+
+ if (type === undefined) return errors
+
const { ipAddress, cidrBlockSize } = values
// Validate CIDR block size
- const isOutOfCidrSizeRange = cidrBlockSize < 0 || cidrBlockSize > 32
+ const isOutOfCidrSizeRange =
+ type === 'IPv4'
+ ? cidrBlockSize < 0 || cidrBlockSize > IPV4_MAX_CIDR_BLOCK_SIZE
+ : cidrBlockSize < 0 || cidrBlockSize > IPV6_MAX_CIDR_BLOCK_SIZE
if (cidrBlockSize.length === 0 || isOutOfCidrSizeRange) {
- errors.cidrBlockSize = 'Size has to be between 0 to 32'
+ errors.cidrBlockSize = `Size has to be between 0 to ${
+ type === 'IPv4' ? IPV4_MAX_CIDR_BLOCK_SIZE : IPV6_MAX_CIDR_BLOCK_SIZE
+ }`
}
// Validate IP address
@@ -53,7 +69,7 @@ const AddRestrictionModal = ({
return errors
}
- const isPrivate = checkIfPrivate(ipAddress)
+ const isPrivate = checkIfPrivate(type, ipAddress)
if (isPrivate) errors.ipAddress = 'Private IP addresses are not supported'
return errors
@@ -71,41 +87,68 @@ const AddRestrictionModal = ({
return toast(`The address ${address} is already restricted`)
}
- const dbAllowedCidrs = hasOverachingRestriction
- ? [normalizedAddress]
- : [...restrictedIps, normalizedAddress]
- applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs })
+ // Need to replace over arching restriction (allow all / disallow all)
+ if (hasOverachingRestriction) {
+ const dbAllowedCidrs = type === 'IPv4' ? [normalizedAddress] : []
+ const dbAllowedCidrsV6 = type === 'IPv6' ? [normalizedAddress] : []
+ applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs, dbAllowedCidrsV6 })
+ } else {
+ const dbAllowedCidrs =
+ type === 'IPv4' ? [...ipv4Restrictions, normalizedAddress] : ipv4Restrictions
+ const dbAllowedCidrsV6 =
+ type === 'IPv6' ? [...ipv6Restrictions, normalizedAddress] : ipv6Restrictions
+ applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs, dbAllowedCidrsV6 })
+ }
}
return (
<Modal
hideFooter
size="medium"
- visible={visible}
+ visible={type !== undefined}
onCancel={onClose}
- header="Add a new restriction"
+ header={`Add a new ${type} restriction`}
>
<Form
validateOnBlur
id={formId}
className="!border-t-0"
- initialValues={{ ipAddress: '', cidrBlockSize: 32 }}
+ initialValues={{
+ ipAddress: '',
+ cidrBlockSize:
+ type === 'IPv4'
+ ? IPV4_MAX_CIDR_BLOCK_SIZE.toString()
+ : IPV6_MAX_CIDR_BLOCK_SIZE.toString(),
+ }}
validate={validate}
onSubmit={onSubmit}
>
- {({ values, resetForm }: any) => {
- const isPrivate = isValidAddress(values.ipAddress)
- ? checkIfPrivate(values.ipAddress)
- : false
+ {({ values }: any) => {
+ const isPrivate =
+ type !== undefined && isValidAddress(values.ipAddress)
+ ? checkIfPrivate(type, values.ipAddress)
+ : false
const isValidBlockSize =
- values.cidrBlockSize !== '' && values.cidrBlockSize >= 0 && values.cidrBlockSize <= 32
- const availableAddresses = Math.pow(2, 32 - (values?.cidrBlockSize ?? 0))
- const addressRange = getAddressEndRange(`${values.ipAddress}/${values.cidrBlockSize}`)
+ values.cidrBlockSize !== '' &&
+ ((type === 'IPv4' &&
+ values.cidrBlockSize >= 0 &&
+ values.cidrBlockSize <= IPV4_MAX_CIDR_BLOCK_SIZE) ||
+ (type === 'IPv6' &&
+ values.cidrBlockSize >= 0 &&
+ values.cidrBlockSize <= IPV6_MAX_CIDR_BLOCK_SIZE))
+ const availableAddresses =
+ type === 'IPv4'
+ ? Math.pow(2, IPV4_MAX_CIDR_BLOCK_SIZE - (values?.cidrBlockSize ?? 0))
+ : Math.pow(2, IPV6_MAX_CIDR_BLOCK_SIZE - (values?.cidrBlockSize ?? 0))
+ const addressRange =
+ type !== undefined
+ ? getAddressEndRange(type, `${values.ipAddress}/${values.cidrBlockSize}`)
+ : undefined
const isValidCIDR = isValidBlockSize && !isPrivate && addressRange !== undefined
const normalizedAddress = isValidCIDR
? normalize(`${values.ipAddress}/${values.cidrBlockSize}`)
- : `{values.ipAddress}/{values.cidrBlockSize}`
+ : `${values.ipAddress}/${values.cidrBlockSize}`
return (
<>
@@ -113,19 +156,21 @@ const AddRestrictionModal = ({
<div className="py-6 space-y-4">
<p className="text-sm text-foreground-light">
This will add an IP address range to a list of allowed ranges that can access
- your database. Only IPv4 addresses are supported at the moment.
+ your database.
</p>
<InformationBox
- title="Note: Restrictions only apply to direct connections to your database and PgBouncer"
+ title="Note: Restrictions only apply to direct connections to your database and connection pooler"
description="They do not currently apply to APIs offered over HTTPS, such as PostgREST, Storage, or Authentication. Supavisor will start enforcing network restrictions from January 24th 2024."
+ urlLabel="Learn more"
+ url="https://supabase.com/docs/guides/platform/network-restrictions#limitations"
/>
<div className="flex space-x-4">
<div className="w-[55%]">
<Input
- label="IPv4 address"
+ label={`${type} address`}
id="ipAddress"
name="ipAddress"
- placeholder="0.0.0.0"
+ placeholder={type === 'IPv4' ? '0.0.0.0' : '::0'}
/>
</div>
<div className="flex-grow">
@@ -150,7 +195,11 @@ const AddRestrictionModal = ({
Classless inter-domain routing (CIDR) notation is the notation
used to identify networks and hosts in the networks. The block
size tells us how many bits we need to take for the network
- prefix, and is a value between 0 to 32.
+ prefix, and is a value between 0 to{' '}
+ {type === 'IPv4'
+ ? IPV4_MAX_CIDR_BLOCK_SIZE
+ : IPV6_MAX_CIDR_BLOCK_SIZE}
+ .
</span>
</div>
</Tooltip.Content>
@@ -161,9 +210,13 @@ const AddRestrictionModal = ({
id="cidrBlockSize"
name="cidrBlockSize"
type="number"
- placeholder="32"
+ placeholder={
+ type === 'IPv4'
+ ? IPV4_MAX_CIDR_BLOCK_SIZE.toString()
+ : IPV6_MAX_CIDR_BLOCK_SIZE.toString()
+ }
min={0}
- max={32}
+ max={type === 'IPv4' ? IPV4_MAX_CIDR_BLOCK_SIZE : IPV6_MAX_CIDR_BLOCK_SIZE}
/>
</div>
</div>
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsx
index 2afb599b262..bbd0cd23c60 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsx
@@ -17,7 +17,11 @@ const AllowAllModal = ({ visible, onClose }: AllowAllModalProps) => {
const onSubmit = async () => {
if (!ref) return console.error('Project ref is required')
- applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs: ['0.0.0.0/0'] })
+ applyNetworkRestrictions({
+ projectRef: ref,
+ dbAllowedCidrs: ['0.0.0.0/0'],
+ dbAllowedCidrsV6: ['::/0'],
+ })
}
return (
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx
index 3dc18feca1f..bec2b653ee3 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx
@@ -16,12 +16,15 @@ const DisallowAllModal = ({ visible, onClose }: DisallowAllModalProps) => {
const onSubmit = async () => {
if (!ref) return console.error('Project ref is required')
- await applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs: ['127.0.0.1/32'] })
+ await applyNetworkRestrictions({
+ projectRef: ref,
+ dbAllowedCidrs: ['127.0.0.1/32'],
+ dbAllowedCidrsV6: ['::1/128'],
+ })
}
return (
<Modal
- closable
hideFooter
size="medium"
visible={visible}
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
index 9ba1fa643aa..04968f387fc 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
@@ -3,7 +3,19 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import Link from 'next/link'
import { useState } from 'react'
-import { Button, IconAlertCircle, IconExternalLink, IconGlobe, IconLock } from 'ui'
+import {
+ Badge,
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ IconAlertCircle,
+ IconChevronDown,
+ IconExternalLink,
+ IconGlobe,
+ IconLock,
+} from 'ui'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { FormHeader, FormPanel } from 'components/ui/Forms'
@@ -75,15 +87,15 @@ const DisallowAllAccessButton = ({ disabled, onClick }: AccessButtonProps) => (
</Tooltip.Root>
)
-const NetworkRestrictions = ({}) => {
+const NetworkRestrictions = () => {
const { ref } = useParams()
const { project } = useProjectContext()
- const [isAddingAddress, setIsAddingAddress] = useState(false)
+ const [isAddingAddress, setIsAddingAddress] = useState<undefined | 'IPv4' | 'IPv6'>()
const [isAllowingAll, setIsAllowingAll] = useState(false)
const [isDisallowingAll, setIsDisallowingAll] = useState(false)
const [selectedRestrictionToRemove, setSelectedRestrictionToRemove] = useState<string>()
- const { data, isLoading } = useNetworkRestrictionsQuery({ projectRef: ref })
+ const { data, isLoading } = useNetworkRestrictionsQuery({ projectRef: ref })
const canUpdateNetworkRestrictions = useCheckPermissions(PermissionAction.UPDATE, 'projects', {
resource: {
project_id: project?.id,
@@ -91,13 +103,19 @@ const NetworkRestrictions = ({}) => {
})
const hasAccessToRestrictions = data?.entitlement === 'allowed'
- const restrictedIps = data?.config?.dbAllowedCidrs ?? []
+ const ipv4Restrictions = data?.config?.dbAllowedCidrs ?? []
+ // @ts-ignore [Joshen] API typing issue
+ const ipv6Restrictions = data?.config?.dbAllowedCidrsV6 ?? []
+ const restrictedIps = ipv4Restrictions.concat(ipv6Restrictions)
const restrictionStatus = data?.status ?? ''
const hasApplyError = restrictedIps.length === 0 && restrictionStatus === 'stored'
const isUninitialized = restrictedIps.length === 0 && restrictionStatus.length === 0
- const isAllowedAll = restrictedIps.includes('0.0.0.0/0')
- const isDisallowedAll = restrictedIps.length === 1 && restrictedIps[0] === '127.0.0.1/32'
+ const isAllowedAll = restrictedIps.includes('0.0.0.0/0') && restrictedIps.includes('::/0')
+ const isDisallowedAll =
+ restrictedIps.length === 2 &&
+ restrictedIps.includes('127.0.0.1/32') &&
+ restrictedIps.includes('::1/128')
if (!hasAccessToRestrictions) return <></>
@@ -121,12 +139,33 @@ const NetworkRestrictions = ({}) => {
</Button>
<Tooltip.Root delayDuration={0}>
<Tooltip.Trigger asChild>
- <Button
- disabled={!canUpdateNetworkRestrictions}
- onClick={() => setIsAddingAddress(true)}
- >
- Add restriction
- </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="primary"
+ disabled={!canUpdateNetworkRestrictions}
+ iconRight={<IconChevronDown />}
+ >
+ Add restriction
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" side="bottom" className="w-48">
+ <DropdownMenuItem
+ key="IPv4"
+ disabled={isLoading}
+ onClick={() => setIsAddingAddress('IPv4')}
+ >
+ <p className="block text-foreground">Add IPv4 restriction</p>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ key="IPv6"
+ disabled={isLoading}
+ onClick={() => setIsAddingAddress('IPv6')}
+ >
+ <p className="block text-foreground">Add IPv6 restriction</p>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
</Tooltip.Trigger>
{!canUpdateNetworkRestrictions && (
<Tooltip.Portal>
@@ -262,6 +301,9 @@ const NetworkRestrictions = ({}) => {
<div key={ip} className="px-8 py-4 flex items-center justify-between">
<div className="flex items-center space-x-5">
<IconGlobe size={16} className="text-foreground-light" />
+ <Badge color="scale">
+ {ipv4Restrictions.includes(ip) ? 'IPv4' : 'IPv6'}
+ </Badge>
<p className="text-sm font-mono">{ip}</p>
</div>
<Button type="default" onClick={() => setSelectedRestrictionToRemove(ip)}>
@@ -280,14 +322,12 @@ const NetworkRestrictions = ({}) => {
<DisallowAllModal visible={isDisallowingAll} onClose={() => setIsDisallowingAll(false)} />
<AddRestrictionModal
- visible={isAddingAddress}
- restrictedIps={restrictedIps}
+ type={isAddingAddress}
hasOverachingRestriction={isAllowedAll || isDisallowedAll}
- onClose={() => setIsAddingAddress(false)}
+ onClose={() => setIsAddingAddress(undefined)}
/>
<RemoveRestrictionModal
visible={selectedRestrictionToRemove !== undefined}
- restrictedIps={restrictedIps}
selectedRestriction={selectedRestrictionToRemove}
onClose={() => setSelectedRestrictionToRemove(undefined)}
/>
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.utils.ts b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.utils.ts
index 806111e9b17..ac266b34b02 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.utils.ts
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.utils.ts
@@ -1,32 +1,54 @@
import { IPv4CidrRange, IPv6CidrRange, Validator, collapseIPv6Number } from 'ip-num'
-const privateIPRanges = [
+const privateIPv4Ranges = [
IPv4CidrRange.fromCidr('10.0.0.0/8'),
IPv4CidrRange.fromCidr('172.16.0.0/12'),
IPv4CidrRange.fromCidr('192.168.0.0/16'),
]
+const privateIPv6Ranges = [IPv6CidrRange.fromCidr('fc00::/7')]
+
export const isValidAddress = (address: string) => {
// Only validating address, should not include cidr block size
if (address.includes('/')) return false
const [isIpv4] = Validator.isValidIPv4String(address)
- return isIpv4
+ const [isIpv6] = Validator.isValidIPv6String(address)
+ return isIpv4 || isIpv6
}
-export const checkIfPrivate = (cidr: string) => {
- const address = IPv4CidrRange.fromCidr(`${cidr}/32`)
- const res = privateIPRanges.map((range) => address.inside(range))
- return res.includes(true)
+export const checkIfPrivate = (type: 'IPv4' | 'IPv6', cidr: string) => {
+ if (type === 'IPv4') {
+ const address = IPv4CidrRange.fromCidr(`${cidr}/32`)
+ const res = privateIPv4Ranges.map((range) => address.inside(range))
+ return res.includes(true)
+ } else {
+ const address = IPv6CidrRange.fromCidr(`${cidr}/128`)
+ const res = privateIPv6Ranges.map((range) => address.inside(range))
+ return res.includes(true)
+ }
}
-export const getAddressEndRange = (address: string) => {
- try {
- const cidr = IPv4CidrRange.fromCidr(address)
- const start = cidr.getFirst().octets.join('.')
- const end = cidr.getLast().octets.join('.')
- return { start, end }
- } catch (error: any) {
- return undefined
+const padHexadecimal = (str: string) => `${'0'.repeat(4 - str.length)}${str}`
+
+export const getAddressEndRange = (type: 'IPv4' | 'IPv6', address: string) => {
+ if (type === 'IPv4') {
+ try {
+ const cidr = IPv4CidrRange.fromCidr(address)
+ const start = cidr.getFirst().octets.join('.')
+ const end = cidr.getLast().octets.join('.')
+ return { start, end }
+ } catch (error: any) {
+ return undefined
+ }
+ } else {
+ try {
+ const cidr = IPv6CidrRange.fromCidr(address)
+ const start = cidr.getFirst().hexadecatet.toString().split(',').map(padHexadecimal).join(':')
+ const end = cidr.getLast().hexadecatet.toString().split(',').map(padHexadecimal).join(':')
+ return { start, end }
+ } catch (error: any) {
+ return undefined
+ }
}
}
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx
index 7b9811e56ba..4cc3035c758 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx
@@ -3,22 +3,28 @@ import { Alert, Button, Modal } from 'ui'
import { useNetworkRestrictionsApplyMutation } from 'data/network-restrictions/network-retrictions-apply-mutation'
import { useStore } from 'hooks'
+import { useNetworkRestrictionsQuery } from 'data/network-restrictions/network-restrictions-query'
interface RemoveRestrictionModalProps {
visible: boolean
- restrictedIps: string[]
selectedRestriction?: string
onClose: () => void
}
const RemoveRestrictionModal = ({
visible,
- restrictedIps,
selectedRestriction,
onClose,
}: RemoveRestrictionModalProps) => {
const { ui } = useStore()
const { ref } = useParams()
+
+ const { data } = useNetworkRestrictionsQuery({ projectRef: ref })
+ const ipv4Restrictions = data?.config?.dbAllowedCidrs ?? []
+ // @ts-ignore [Joshen] API typing issue
+ const ipv6Restrictions: string[] = data?.config?.dbAllowedCidrsV6 ?? []
+ const restrictedIps = ipv4Restrictions.concat(ipv6Restrictions)
+
const { mutate: applyNetworkRestrictions, isLoading: isApplying } =
useNetworkRestrictionsApplyMutation({
onSuccess: () => onClose(),
@@ -35,13 +41,23 @@ const RemoveRestrictionModal = ({
const onSubmit = async () => {
if (!ref) return console.error('Project ref is required')
+ if (!selectedRestriction) return console.error('Missing selected restriction')
- const dbAllowedCidrs = restrictedIps.filter((ip) => ip !== selectedRestriction)
+ const dbAllowedCidrs = ipv4Restrictions.includes(selectedRestriction)
+ ? ipv4Restrictions.filter((ip) => ip !== selectedRestriction)
+ : ipv4Restrictions
+ const dbAllowedCidrsV6 = ipv6Restrictions.includes(selectedRestriction)
+ ? ipv6Restrictions.filter((ip) => ip !== selectedRestriction)
+ : ipv6Restrictions
- if (dbAllowedCidrs.length === 0) {
- applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs: ['0.0.0.0/0'] })
+ if (dbAllowedCidrs.length === 0 && dbAllowedCidrsV6.length === 0) {
+ applyNetworkRestrictions({
+ projectRef: ref,
+ dbAllowedCidrs: ['0.0.0.0/0'],
+ dbAllowedCidrsV6: ['::/0'],
+ })
} else {
- applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs })
+ applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs, dbAllowedCidrsV6 })
}
}
diff --git a/apps/studio/components/ui/InformationBox.tsx b/apps/studio/components/ui/InformationBox.tsx
index f29f1735242..cc5381ab7de 100644
--- a/apps/studio/components/ui/InformationBox.tsx
+++ b/apps/studio/components/ui/InformationBox.tsx
@@ -65,11 +65,13 @@ const InformationBox = ({
<div className="text-foreground-light text-sm">{description}</div>
{url && (
- <Button asChild type="default" icon={<IconExternalLink />}>
- <Link href={url} target="_blank" rel="noreferrer" className="pt-2">
- {urlLabel}
- </Link>
- </Button>
+ <div>
+ <Button asChild type="default" icon={<IconExternalLink />}>
+ <Link href={url} target="_blank" rel="noreferrer">
+ {urlLabel}
+ </Link>
+ </Button>
+ </div>
)}
{button && <div>{button}</div>}
diff --git a/apps/studio/data/api.d.ts b/apps/studio/data/api.d.ts
index be6d65262e9..c348c55a554 100644
--- a/apps/studio/data/api.d.ts
+++ b/apps/studio/data/api.d.ts
@@ -774,7 +774,7 @@ export interface paths {
}
'/platform/integrations/vercel/connections/{connection_id}/sync-envs': {
/** Syncs supabase project envs with given connection id */
- post: operations['VercelConnectionsController_syncVercelConnectionEnvs']
+ post: operations['VercelConnectionsController_syncVercelConnectionEnvironments']
}
'/platform/integrations/vercel/connections/{connection_id}': {
/** Deletes vercel project connection */
@@ -3796,6 +3796,8 @@ export interface components {
app_config?: components['schemas']['ProjectAppConfigResponse']
jwt_secret?: string
service_api_keys?: components['schemas']['ProjectServiceApiKeyResponse'][]
+ /** @enum {string|null} */
+ db_ip_addr_config: 'legacy' | 'static-ipv4' | 'concurrent-ipv6' | 'ipv6' | null
}
TransferProjectBody: {
target_organization_slug: string
@@ -4613,7 +4615,6 @@ export interface components {
current_app_version: string
latest_app_version: string
target_upgrade_versions: components['schemas']['ProjectVersion'][]
- requires_manual_intervention: string | null
potential_breaking_changes: string[]
duration_estimate_hours: number
legacy_auth_custom_roles: string[]
@@ -4634,6 +4635,7 @@ export interface components {
| '8_upgrade_completion_failed'
/** @enum {string} */
progress?:
+ | '0_requested'
| '1_started'
| '2_launched_upgraded_instance'
| '3_detached_volume_from_upgraded_instance'
@@ -4966,6 +4968,11 @@ export interface components {
* @example postgresql://postgres:[email protected]:5432/postgres
*/
DATABASE_URL: string
+ /**
+ * @description Pooler connection string
+ * @example postgres://postgres.abcdefghijklmnop:[email protected]:6543/postgres
+ */
+ DATABASE_POOLER_URL: string
}
ResourceProvisioningResponse: {
/** @description Supabase envs config */
@@ -10347,7 +10354,7 @@ export interface operations {
}
}
/** Syncs supabase project envs with given connection id */
- VercelConnectionsController_syncVercelConnectionEnvs: {
+ VercelConnectionsController_syncVercelConnectionEnvironments: {
parameters: {
path: {
connection_id: string
diff --git a/apps/studio/data/network-restrictions/network-restrictions-query.ts b/apps/studio/data/network-restrictions/network-restrictions-query.ts
index 366f53ecd2f..678266f74cc 100644
--- a/apps/studio/data/network-restrictions/network-restrictions-query.ts
+++ b/apps/studio/data/network-restrictions/network-restrictions-query.ts
@@ -1,8 +1,7 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+import { get } from 'data/fetchers'
import { networkRestrictionKeys } from './keys'
-import { get } from 'lib/common/fetch'
-import { API_ADMIN_URL } from 'lib/constants'
export type NetworkRestrictionsVariables = { projectRef?: string }
@@ -20,16 +19,17 @@ export async function getNetworkRestrictions(
) {
if (!projectRef) throw new Error('projectRef is required')
- const response = (await get(`${API_ADMIN_URL}/projects/${projectRef}/network-restrictions`, {
+ const { data, error } = await get('/v1/projects/{ref}/network-restrictions', {
+ params: { path: { ref: projectRef } },
signal,
- })) as NetworkRestrictionsResponse
+ })
// Not allowed error is a valid response to denote if a project
// has access to the network restrictions UI, so we'll handle it here
- if (response.error) {
+ if (error) {
const isNotAllowedError =
- (response.error as any)?.code === 400 &&
- (response.error as any)?.message?.includes('not allowed to set up network restrictions')
+ (error as any)?.code === 400 &&
+ (error as any)?.message?.includes('not allowed to set up network restrictions')
if (isNotAllowedError) {
return {
@@ -38,11 +38,11 @@ export async function getNetworkRestrictions(
status: '',
} as NetworkRestrictionsResponse
} else {
- throw response.error
+ throw error
}
}
- return response
+ return data
}
export type NetworkRestrictionsData = Awaited<ReturnType<typeof getNetworkRestrictions>>
diff --git a/apps/studio/data/network-restrictions/network-retrictions-apply-mutation.ts b/apps/studio/data/network-restrictions/network-retrictions-apply-mutation.ts
index 8a7b200f7a3..455594126ad 100644
--- a/apps/studio/data/network-restrictions/network-retrictions-apply-mutation.ts
+++ b/apps/studio/data/network-restrictions/network-retrictions-apply-mutation.ts
@@ -1,29 +1,30 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'lib/common/fetch'
-import { API_ADMIN_URL } from 'lib/constants'
+import { post } from 'data/fetchers'
import { ResponseError } from 'types'
import { networkRestrictionKeys } from './keys'
export type NetworkRestrictionsApplyVariables = {
projectRef: string
dbAllowedCidrs: string[]
+ dbAllowedCidrsV6: string[]
}
export async function applyNetworkRestrictions({
projectRef,
dbAllowedCidrs,
+ dbAllowedCidrsV6,
}: NetworkRestrictionsApplyVariables) {
if (!projectRef) throw new Error('projectRef is required')
- const response = await post(
- `${API_ADMIN_URL}/projects/${projectRef}/network-restrictions/apply`,
- { dbAllowedCidrs }
- )
- if (response.error) throw response.error
+ const { data, error } = await post('/v1/projects/{ref}/network-restrictions/apply', {
+ params: { path: { ref: projectRef } },
+ body: { dbAllowedCidrs, dbAllowedCidrsV6 },
+ })
- return response
+ if (error) throw error
+ return data
}
type NetworkRestrictionsApplyData = Awaited<ReturnType<typeof applyNetworkRestrictions>>