Skip to content

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

Temporarily disable network bans and network restrictions on HA (#47325)

Saxon Fletcher1392cc095204
diff --git a/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx b/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx
index 83bcb9f257d..8bb1bd00dc1 100644
--- a/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx
@@ -17,16 +17,23 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import AlertError from '@/components/ui/AlertError'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { DocsButton } from '@/components/ui/DocsButton'
+import { HighAvailabilityDisabledSectionNotice } from '@/components/ui/HighAvailability/HighAvailabilityDisabledSectionNotice'
import { useBannedIPsDeleteMutation } from '@/data/banned-ips/banned-ips-delete-mutations'
import { useBannedIPsQuery } from '@/data/banned-ips/banned-ips-query'
import { useUserIPAddressQuery } from '@/data/misc/user-ip-address-query'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
+import { useHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
+const HA_DISABLED_TITLE = 'Network bans unavailable on High Availability projects'
+const HA_DISABLED_DESCRIPTION =
+ "We're working to bring network bans to High Availability projects. Contact support if this is blocking your work."
+
export const BannedIPs = () => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
+ const { isHighAvailability } = useHighAvailability()
const [selectedIPToUnban, setSelectedIPToUnban] = useState<string | null>(null) // Track the selected IP for unban
@@ -52,6 +59,11 @@ export const BannedIPs = () => {
},
})
+ const isSectionDisabled = isHighAvailability || !canUnbanNetworks
+ const sectionDisabledReason = isHighAvailability
+ ? HA_DISABLED_TITLE
+ : 'You need additional permissions to unban networks'
+
const { mutate: unbanIPs, isPending: isUnbanning } = useBannedIPsDeleteMutation({
onSuccess: () => {
toast.success('IP address successfully unbanned')
@@ -90,49 +102,56 @@ export const BannedIPs = () => {
<DocsButton href={`${DOCS_URL}/reference/cli/supabase-network-bans`} />
</PageSectionMeta>
<PageSectionContent>
- {ipListLoading ? (
- <Card>
- <CardContent className="space-y-4">
- <Skeleton className="h-4 w-full" />
- <Skeleton className="h-4 w-full" />
- </CardContent>
- </Card>
- ) : ipListError ? (
- <AlertError error={ipListError} subject="Failed to retrieve banned IP addresses" />
- ) : ipList.banned_ipv4_addresses.length > 0 ? (
- <Card>
- {ipList.banned_ipv4_addresses.map((ip) => (
- <CardContent key={ip} className="flex items-center justify-between">
- <div className="flex items-center space-x-5">
- <Globe size={16} className="text-foreground-lighter" />
- <p className="text-sm font-mono">{ip}</p>
- {ip === userIPAddress && <Badge>Your IP address</Badge>}
- </div>
- <ButtonTooltip
- variant="default"
- disabled={!canUnbanNetworks}
- onClick={() => openConfirmationModal(ip)}
- tooltip={{
- content: {
- side: 'bottom',
- text: !canUnbanNetworks
- ? 'You need additional permissions to unban networks'
- : undefined,
- },
- }}
- >
- Unban IP
- </ButtonTooltip>
- </CardContent>
- ))}
- </Card>
- ) : (
- <Card>
- <CardContent className="text-foreground text-sm">
- There are no banned IP addresses for your project
- </CardContent>
- </Card>
+ {isHighAvailability && (
+ <div className="mb-4">
+ <HighAvailabilityDisabledSectionNotice
+ title={HA_DISABLED_TITLE}
+ description={HA_DISABLED_DESCRIPTION}
+ />
+ </div>
)}
+ {!isHighAvailability &&
+ (ipListLoading ? (
+ <Card>
+ <CardContent className="space-y-4">
+ <Skeleton className="h-4 w-full" />
+ <Skeleton className="h-4 w-full" />
+ </CardContent>
+ </Card>
+ ) : ipListError ? (
+ <AlertError error={ipListError} subject="Failed to retrieve banned IP addresses" />
+ ) : ipList.banned_ipv4_addresses.length > 0 ? (
+ <Card>
+ {ipList.banned_ipv4_addresses.map((ip) => (
+ <CardContent key={ip} className="flex items-center justify-between">
+ <div className="flex items-center space-x-5">
+ <Globe size={16} className="text-foreground-lighter" />
+ <p className="text-sm font-mono">{ip}</p>
+ {ip === userIPAddress && <Badge>Your IP address</Badge>}
+ </div>
+ <ButtonTooltip
+ variant="default"
+ disabled={isSectionDisabled}
+ onClick={() => openConfirmationModal(ip)}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: isSectionDisabled ? sectionDisabledReason : undefined,
+ },
+ }}
+ >
+ Unban IP
+ </ButtonTooltip>
+ </CardContent>
+ ))}
+ </Card>
+ ) : (
+ <Card>
+ <CardContent className="text-foreground text-sm">
+ There are no banned IP addresses for your project
+ </CardContent>
+ </Card>
+ ))}
</PageSectionContent>
</PageSection>
diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
index 3e5b156d3bc..1170ae6f81f 100644
--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
@@ -13,9 +13,6 @@ import {
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
} from 'ui'
import {
PageSection,
@@ -33,32 +30,43 @@ import DisallowAllModal from './DisallowAllModal'
import RemoveRestrictionModal from './RemoveRestrictionModal'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { DocsButton } from '@/components/ui/DocsButton'
+import { HighAvailabilityDisabledSectionNotice } from '@/components/ui/HighAvailability/HighAvailabilityDisabledSectionNotice'
import { useNetworkRestrictionsQuery } from '@/data/network-restrictions/network-restrictions-query'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
+import { useHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
+const HA_DISABLED_TITLE = 'Network restrictions unavailable on High Availability projects'
+const HA_DISABLED_DESCRIPTION =
+ "We're working to bring network restrictions to High Availability projects. Contact support if this is blocking your work."
+
interface AccessButtonProps {
disabled: boolean
+ disabledTooltip?: string
onClick: (value: boolean) => void
}
-const AllowAllAccessButton = ({ disabled, onClick }: AccessButtonProps) => (
- <Tooltip>
- <TooltipTrigger asChild>
- <Button variant="default" disabled={disabled} onClick={() => onClick(true)}>
- Allow all access
- </Button>
- </TooltipTrigger>
- {disabled && (
- <TooltipContent side="bottom">
- You need additional permissions to update network restrictions
- </TooltipContent>
- )}
- </Tooltip>
+const getDisabledTooltip = (disabled: boolean, disabledTooltip?: string) =>
+ disabled ? disabledTooltip : undefined
+
+const AllowAllAccessButton = ({ disabled, disabledTooltip, onClick }: AccessButtonProps) => (
+ <ButtonTooltip
+ variant="default"
+ disabled={disabled}
+ onClick={() => onClick(true)}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: getDisabledTooltip(disabled, disabledTooltip),
+ },
+ }}
+ >
+ Allow all access
+ </ButtonTooltip>
)
-const DisallowAllAccessButton = ({ disabled, onClick }: AccessButtonProps) => (
+const DisallowAllAccessButton = ({ disabled, disabledTooltip, onClick }: AccessButtonProps) => (
<ButtonTooltip
disabled={disabled}
variant="default"
@@ -66,9 +74,7 @@ const DisallowAllAccessButton = ({ disabled, onClick }: AccessButtonProps) => (
tooltip={{
content: {
side: 'bottom',
- text: disabled
- ? 'You need additional permissions to update network restrictions'
- : undefined,
+ text: getDisabledTooltip(disabled, disabledTooltip),
},
}}
>
@@ -79,6 +85,7 @@ const DisallowAllAccessButton = ({ disabled, onClick }: AccessButtonProps) => (
export const NetworkRestrictions = () => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
+ const { isHighAvailability } = useHighAvailability()
const [isAddingAddress, setIsAddingAddress] = useState<undefined | 'IPv4' | 'IPv6'>()
const [isAllowingAll, setIsAllowingAll] = useState(false)
const [isDisallowingAll, setIsDisallowingAll] = useState(false)
@@ -98,6 +105,11 @@ export const NetworkRestrictions = () => {
}
)
+ const isSectionDisabled = isHighAvailability || !canUpdateNetworkRestrictions
+ const sectionDisabledReason = isHighAvailability
+ ? HA_DISABLED_TITLE
+ : 'You need additional permissions to update network restrictions'
+
const hasAccessToRestrictions = data?.entitlement === 'allowed'
const ipv4Restrictions = data?.config?.dbAllowedCidrs ?? []
// @ts-ignore [Joshen] API typing issue
@@ -121,14 +133,14 @@ export const NetworkRestrictions = () => {
</PageSectionSummary>
<PageSectionAside className="flex items-center gap-x-2">
<DocsButton href={`${DOCS_URL}/guides/platform/network-restrictions`} />
- {!canUpdateNetworkRestrictions ? (
+ {!canUpdateNetworkRestrictions || isHighAvailability ? (
<ButtonTooltip
disabled
variant="primary"
tooltip={{
content: {
side: 'bottom',
- text: 'You need additional permissions to update network restrictions',
+ text: sectionDisabledReason,
},
}}
>
@@ -139,7 +151,7 @@ export const NetworkRestrictions = () => {
<DropdownMenuTrigger asChild>
<Button
variant="primary"
- disabled={!canUpdateNetworkRestrictions}
+ disabled={isSectionDisabled}
iconRight={<ChevronDown size={14} />}
>
Add restriction
@@ -166,140 +178,171 @@ export const NetworkRestrictions = () => {
</PageSectionAside>
</PageSectionMeta>
<PageSectionContent>
- {isLoading ? (
- <Card>
- <CardContent>
- <div className="space-y-2">
- <ShimmeringLoader />
- <ShimmeringLoader className="w-[70%]" />
- <ShimmeringLoader className="w-[50%]" />
- </div>
- </CardContent>
- </Card>
- ) : hasApplyError ? (
- <Card>
- <CardContent>
- <div className="flex items-center justify-between">
+ {isHighAvailability && (
+ <div className="mb-4">
+ <HighAvailabilityDisabledSectionNotice
+ title={HA_DISABLED_TITLE}
+ description={HA_DISABLED_DESCRIPTION}
+ />
+ </div>
+ )}
+ {!isHighAvailability &&
+ (isLoading ? (
+ <Card>
+ <CardContent>
<div className="space-y-2">
- <div className="flex items-center space-x-2">
- <AlertCircle size={20} strokeWidth={1.5} className="text-foreground-light" />
- <p className="text-sm">
- Your network restrictions were not applied correctly
- </p>
- </div>
- <p className="text-sm text-foreground-light">
- Please try to add your network restrictions again
- </p>
- </div>
- <div className="flex items-center space-x-2">
- <AllowAllAccessButton
- disabled={!canUpdateNetworkRestrictions}
- onClick={setIsAllowingAll}
- />
- <DisallowAllAccessButton
- disabled={!canUpdateNetworkRestrictions}
- onClick={setIsDisallowingAll}
- />
- </div>
- </div>
- </CardContent>
- </Card>
- ) : (
- <Card>
- {isUninitialized || isAllowedAll ? (
- <CardContent className="flex items-center justify-between">
- <div className="flex items-start space-x-4">
- <div className="space-y-0.5">
- <p className="text-foreground text-sm">
- Your database can be accessed by all IP addresses
- </p>
- <p className="text-foreground-light text-sm">
- You may start limiting access to your database by adding a network
- restriction.
- </p>
- </div>
- </div>
- <div>
- <DisallowAllAccessButton
- disabled={!canUpdateNetworkRestrictions}
- onClick={setIsDisallowingAll}
- />
+ <ShimmeringLoader />
+ <ShimmeringLoader className="w-[70%]" />
+ <ShimmeringLoader className="w-[50%]" />
</div>
</CardContent>
- ) : isDisallowedAll ? (
- <CardContent className="flex items-center justify-between">
- <div className="flex items-start space-x-4">
- <Lock size={20} className="text-foreground-light" strokeWidth={1.5} />
- <div className="space-y-1">
- <p className="text-foreground-light text-sm">
- Your database <span className="text-amber-900 opacity-80">cannot</span> be
- accessed externally
- </p>
- <p className="text-foreground-light text-sm">
- All external IP addresses have been disallowed from accessing your project's
- database.
- </p>
- <p className="text-foreground-light text-sm">
- Note: Restrictions only apply to your database, and not to Supabase services
+ </Card>
+ ) : hasApplyError ? (
+ <Card>
+ <CardContent>
+ <div className="flex items-center justify-between">
+ <div className="space-y-2">
+ <div className="flex items-center space-x-2">
+ <AlertCircle
+ size={20}
+ strokeWidth={1.5}
+ className="text-foreground-light"
+ />
+ <p className="text-sm">
+ Your network restrictions were not applied correctly
+ </p>
+ </div>
+ <p className="text-sm text-foreground-light">
+ Please try to add your network restrictions again
</p>
</div>
- </div>
- <div>
- <AllowAllAccessButton
- disabled={!canUpdateNetworkRestrictions}
- onClick={setIsAllowingAll}
- />
- </div>
- </CardContent>
- ) : (
- <>
- <CardHeader className="md:flex-row md:items-center justify-between">
- <CardDescription className="text-foreground-light">
- <p>Only the following IP addresses have access to your database.</p>
- <p>
- You may remove all of them to allow all IP addresses to have access to your
- database.
- </p>
- <p>
- Note: Restrictions only apply to your database, and not to Supabase services
- </p>
- </CardDescription>
<div className="flex items-center space-x-2">
<AllowAllAccessButton
- disabled={!canUpdateNetworkRestrictions}
+ disabled={isSectionDisabled}
+ disabledTooltip={sectionDisabledReason}
onClick={setIsAllowingAll}
/>
<DisallowAllAccessButton
- disabled={!canUpdateNetworkRestrictions}
+ disabled={isSectionDisabled}
+ disabledTooltip={sectionDisabledReason}
onClick={setIsDisallowingAll}
/>
</div>
- </CardHeader>
- <CardContent className="py-0">
- <div className="divide-y">
- {restrictedIps.map((ip) => {
- return (
- <div key={ip} className="py-4 flex items-center justify-between">
- <div className="flex items-center space-x-5">
- <Globe size={16} className="text-foreground-lighter" />
- <Badge>{ipv4Restrictions.includes(ip) ? 'IPv4' : 'IPv6'}</Badge>
- <p className="text-sm font-mono">{ip}</p>
- </div>
- <Button
- variant="default"
- onClick={() => setSelectedRestrictionToRemove(ip)}
- >
- Remove
- </Button>
- </div>
- )
- })}
+ </div>
+ </CardContent>
+ </Card>
+ ) : (
+ <Card>
+ {isUninitialized || isAllowedAll ? (
+ <CardContent className="flex items-center justify-between">
+ <div className="flex items-start space-x-4">
+ <div className="space-y-0.5">
+ <p className="text-foreground text-sm">
+ Your database can be accessed by all IP addresses
+ </p>
+ <p className="text-foreground-light text-sm">
+ You may start limiting access to your database by adding a network
+ restriction.
+ </p>
+ </div>
+ </div>
+ <div>
+ <DisallowAllAccessButton
+ disabled={isSectionDisabled}
+ disabledTooltip={sectionDisabledReason}
+ onClick={setIsDisallowingAll}
+ />
</div>
</CardContent>
- </>
- )}
- </Card>
- )}
+ ) : isDisallowedAll ? (
+ <CardContent className="flex items-center justify-between">
+ <div className="flex items-start space-x-4">
+ <Lock size={20} className="text-foreground-light" strokeWidth={1.5} />
+ <div className="space-y-1">
+ <p className="text-foreground-light text-sm">
+ Your database <span className="text-amber-900 opacity-80">cannot</span> be
+ accessed externally
+ </p>
+ <p className="text-foreground-light text-sm">
+ All external IP addresses have been disallowed from accessing your
+ project's database.
+ </p>
+ <p className="text-foreground-light text-sm">
+ Note: Restrictions only apply to your database, and not to Supabase
+ services
+ </p>
+ </div>
+ </div>
+ <div>
+ <AllowAllAccessButton
+ disabled={isSectionDisabled}
+ disabledTooltip={sectionDisabledReason}
+ onClick={setIsAllowingAll}
+ />
+ </div>
+ </CardContent>
+ ) : (
+ <>
+ <CardHeader className="md:flex-row md:items-center justify-between">
+ <CardDescription className="text-foreground-light">
+ <p>Only the following IP addresses have access to your database.</p>
+ <p>
+ You may remove all of them to allow all IP addresses to have access to
+ your database.
+ </p>
+ <p>
+ Note: Restrictions only apply to your database, and not to Supabase
+ services
+ </p>
+ </CardDescription>
+ <div className="flex items-center space-x-2">
+ <AllowAllAccessButton
+ disabled={isSectionDisabled}
+ disabledTooltip={sectionDisabledReason}
+ onClick={setIsAllowingAll}
+ />
+ <DisallowAllAccessButton
+ disabled={isSectionDisabled}
+ disabledTooltip={sectionDisabledReason}
+ onClick={setIsDisallowingAll}
+ />
+ </div>
+ </CardHeader>
+ <CardContent className="py-0">
+ <div className="divide-y">
+ {restrictedIps.map((ip) => {
+ return (
+ <div key={ip} className="py-4 flex items-center justify-between">
+ <div className="flex items-center space-x-5">
+ <Globe size={16} className="text-foreground-lighter" />
+ <Badge>{ipv4Restrictions.includes(ip) ? 'IPv4' : 'IPv6'}</Badge>
+ <p className="text-sm font-mono">{ip}</p>
+ </div>
+ <ButtonTooltip
+ variant="default"
+ disabled={isSectionDisabled}
+ onClick={() => setSelectedRestrictionToRemove(ip)}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: getDisabledTooltip(
+ isSectionDisabled,
+ sectionDisabledReason
+ ),
+ },
+ }}
+ >
+ Remove
+ </ButtonTooltip>
+ </div>
+ )
+ })}
+ </div>
+ </CardContent>
+ </>
+ )}
+ </Card>
+ ))}
</PageSectionContent>
</PageSection>