From ea5a74af7d37fac24a816e500f32afbe6dc99004 Mon Sep 17 00:00:00 2001
From: Joshen Lim
Date: Mon, 30 Jan 2023 14:12:20 +0800
Subject: [PATCH] Shift network restrictions to database settings page
---
studio/components/interfaces/Database/index.ts | 2 +-
.../Database}/ConnectionPooling.tsx | 0
.../NetworkRestrictions/AddRestrictionModal.tsx | 11 +++++++++--
.../NetworkRestrictions/AllowAllModal.tsx | 0
.../NetworkRestrictions/DisallowAllModal.tsx | 9 ++++++++-
.../NetworkRestrictions/NetworkRestrictions.tsx | 9 +++++++--
.../NetworkRestrictions/RemoveRestrictionModal.tsx | 0
.../components/interfaces/Settings/Database/index.ts | 4 ++++
.../components/interfaces/Settings/General/index.ts | 10 +---------
studio/pages/project/[ref]/settings/database.tsx | 9 ++++++---
studio/pages/project/[ref]/settings/general.tsx | 5 -----
11 files changed, 36 insertions(+), 23 deletions(-)
rename studio/components/interfaces/{Database/Pooling => Settings/Database}/ConnectionPooling.tsx (100%)
rename studio/components/interfaces/Settings/{General => Database}/NetworkRestrictions/AddRestrictionModal.tsx (88%)
rename studio/components/interfaces/Settings/{General => Database}/NetworkRestrictions/AllowAllModal.tsx (100%)
rename studio/components/interfaces/Settings/{General => Database}/NetworkRestrictions/DisallowAllModal.tsx (83%)
rename studio/components/interfaces/Settings/{General => Database}/NetworkRestrictions/NetworkRestrictions.tsx (94%)
rename studio/components/interfaces/Settings/{General => Database}/NetworkRestrictions/RemoveRestrictionModal.tsx (100%)
create mode 100644 studio/components/interfaces/Settings/Database/index.ts
diff --git a/studio/components/interfaces/Database/index.ts b/studio/components/interfaces/Database/index.ts
index d866b7d8c8c..94c664c2854 100644
--- a/studio/components/interfaces/Database/index.ts
+++ b/studio/components/interfaces/Database/index.ts
@@ -15,7 +15,7 @@ import PublicationsTables from './Publications/PublicationsTables'
import BackupsList from './Backups/BackupsList'
-import ConnectionPooling from './Pooling/ConnectionPooling'
+import ConnectionPooling from '../Settings/Database/ConnectionPooling'
import CreateTrigger from './Triggers/CreateTrigger'
import DeleteTrigger from './Triggers/DeleteTrigger'
diff --git a/studio/components/interfaces/Database/Pooling/ConnectionPooling.tsx b/studio/components/interfaces/Settings/Database/ConnectionPooling.tsx
similarity index 100%
rename from studio/components/interfaces/Database/Pooling/ConnectionPooling.tsx
rename to studio/components/interfaces/Settings/Database/ConnectionPooling.tsx
diff --git a/studio/components/interfaces/Settings/General/NetworkRestrictions/AddRestrictionModal.tsx b/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
similarity index 88%
rename from studio/components/interfaces/Settings/General/NetworkRestrictions/AddRestrictionModal.tsx
rename to studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
index 6b93314d01a..94ecb1fabf4 100644
--- a/studio/components/interfaces/Settings/General/NetworkRestrictions/AddRestrictionModal.tsx
+++ b/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx
@@ -4,6 +4,7 @@ import { Alert, Button, Form, Input, Modal } from 'ui'
import { useStore, useParams } from 'hooks'
import { useNetworkRestrictionsApplyMutation } from 'data/network-restrictions/network-retrictions-apply-mutation'
+import InformationBox from 'components/ui/InformationBox'
interface Props {
restrictedIps: string[]
@@ -77,7 +78,7 @@ const AddRestrictionModal: FC = ({
= ({
validate={validate}
onSubmit={onSubmit}
>
- {({ isSubmitting }: any) => {
+ {({ isSubmitting }: { isSubmitting: boolean }) => {
return (
<>
@@ -99,6 +100,12 @@ const AddRestrictionModal: FC = ({
This will add an IP address range to a list of allowed ranges that can access
your project's database.
+
= ({ visible, onClose }) => {
= ({ visible, onClose }) => {
This will prevent any IP address other than your local machine from accessing your
project's database. Are you sure?
+
diff --git a/studio/components/interfaces/Settings/General/NetworkRestrictions/NetworkRestrictions.tsx b/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
similarity index 94%
rename from studio/components/interfaces/Settings/General/NetworkRestrictions/NetworkRestrictions.tsx
rename to studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
index bd6f745867a..2e074e77c5c 100644
--- a/studio/components/interfaces/Settings/General/NetworkRestrictions/NetworkRestrictions.tsx
+++ b/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx
@@ -116,8 +116,9 @@ const NetworkRestrictions = ({}) => {
accessed externally
- Only your local machine is able to access your project's database as all IP
- addresses have been disallowed.
+ Only IP addresses within the range of{' '}
+ 127.0.0.1/32 can access your project's
+ database as all IP addresses have been disallowed.
@@ -138,6 +139,10 @@ const NetworkRestrictions = ({}) => {
You may remove all of them to allow all IP addresses to have access to your
database
+
+ Note: Restrictions only apply to your database, and not to APIs offered over
+ HTTPS
+