The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Redirect URLs, not Redirect Domains
Benjamin Dobell0271ab45caea
diff --git a/studio/components/interfaces/Auth/Auth.constants.ts b/studio/components/interfaces/Auth/Auth.constants.tsindex 32f80bc5cb2..aac17a564ec 100644--- a/studio/components/interfaces/Auth/Auth.constants.ts+++ b/studio/components/interfaces/Auth/Auth.constants.ts@@ -7,7 +7,7 @@// "https://uptime-monitor-fe.vercel.app/"// Supports wildcards, port numbers at the end, paths at the end and query params-const baseDomainRegex =+const baseUrlRegex =/^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_*-]+(\.[a-zA-Z0-9_*-]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)+(?:\.[a-z]+)*(?::\d+)?(?![^<]*(?:<\/\w+>|\/?>))(.*)?\/?(.)*?$/gm// iOS deep linking scheme https://benoitpasquier.com/deep-linking-url-scheme-ios/@@ -21,7 +21,7 @@ const localhostRegex = /^(?:^|\s)((https?:\/\/)?(?:localhost|[\w-]+(?:\.[\w-]+)+const chromeExtensionRegex = /chrome-extension:\/\/([a-zA-Z]*)/gm// combine the above regexes-export const domainRegex = new RegExp(- `(${baseDomainRegex.source})|(${localhostRegex.source})|(${appRegex.source})|(${chromeExtensionRegex.source})`,+export const urlRegex = new RegExp(+ `(${baseUrlRegex.source})|(${localhostRegex.source})|(${appRegex.source})|(${chromeExtensionRegex.source})`,'i')diff --git a/studio/components/interfaces/Auth/RedirectDomains/DomainList.tsx b/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsxsimilarity index 82%rename from studio/components/interfaces/Auth/RedirectDomains/DomainList.tsxrename to studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsxindex 08929879c79..72eeab1194e 100644--- a/studio/components/interfaces/Auth/RedirectDomains/DomainList.tsx+++ b/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx@@ -9,10 +9,10 @@ import { HorizontalShimmerWithIcon } from 'components/ui/Shimmers'interface Props {canUpdate: boolean- onSelectDomainToDelete: (domain: string) => void+ onSelectUrlToDelete: (url: string) => void}-const DomainList: FC<Props> = ({ canUpdate, onSelectDomainToDelete }) => {+const RedirectUrlList: FC<Props> = ({ canUpdate, onSelectUrlToDelete }) => {const { authConfig } = useStore()const URI_ALLOW_LIST_ARRAY = authConfig.config.URI_ALLOW_LIST@@ -31,20 +31,20 @@ const DomainList: FC<Props> = ({ canUpdate, onSelectDomainToDelete }) => {</ValueContainer></>) : URI_ALLOW_LIST_ARRAY.length > 0 ? (- URI_ALLOW_LIST_ARRAY.map((domain: string) => {+ URI_ALLOW_LIST_ARRAY.map((url: string) => {return (- <ValueContainer key={domain}>+ <ValueContainer key={url}><div className="flex items-center gap-4 font-mono"><span className="text-scale-900"><IconGlobe strokeWidth={2} size={14} /></span>- <span className="text-sm">{domain}</span>+ <span className="text-sm">{url}</span></div>{canUpdate && (<Buttontype="default"icon={<IconTrash />}- onClick={() => onSelectDomainToDelete(domain)}+ onClick={() => onSelectUrlToDelete(url)}>Remove</Button>@@ -69,4 +69,4 @@ const DomainList: FC<Props> = ({ canUpdate, onSelectDomainToDelete }) => {)}-export default observer(DomainList)+export default observer(RedirectUrlList)diff --git a/studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.tsx b/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsxsimilarity index 64%rename from studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.tsxrename to studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsxindex 5eede56fce7..ad8e9a80e8f 100644--- a/studio/components/interfaces/Auth/RedirectDomains/RedirectDomains.tsx+++ b/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsx@@ -7,10 +7,10 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { checkPermissions, useStore } from 'hooks'import { FormHeader } from 'components/ui/Forms'-import { domainRegex } from '../Auth.constants'-import DomainList from './DomainList'+import { urlRegex } from '../Auth.constants'+import RedirectUrlList from './RedirectUrlList'-const RedirectDomains = () => {+const RedirectUrls = () => {const { authConfig, ui } = useStore()const URI_ALLOW_LIST_ARRAY = authConfig.config.URI_ALLOW_LIST@@ -19,24 +19,24 @@ const RedirectDomains = () => {const [open, setOpen] = useState(false)const [isDeleting, setIsDeleting] = useState(false)- const [selectedDomainToDelete, setSelectedDomainToDelete] = useState<string>()+ const [selectedUrlToDelete, setSelectedUrlToDelete] = useState<string>()const canUpdateConfig = checkPermissions(PermissionAction.UPDATE, 'custom_config_gotrue')- const newDomainSchema = object({- domain: string().matches(domainRegex, 'URL is not valid').required(),+ const newUrlSchema = object({+ url: string().matches(urlRegex, 'URL is not valid').required(),})- const onAddNewDomain = async (values: any, { setSubmitting }: any) => {+ const onAddNewUrl = async (values: any, { setSubmitting }: any) => {setSubmitting(true)const payload = URI_ALLOW_LIST_ARRAY- payload.push(values.domain)+ payload.push(values.url)const payloadString = payload.toString()if (payloadString.length > 2 * 1024) {ui.setNotification({- message: 'Too many redirect domains, please remove some or try to use wildcards',+ message: 'Too many redirect URLs, please remove some or try to use wildcards',category: 'error',})@@ -47,36 +47,36 @@ const RedirectDomains = () => {const { error } = await authConfig.update({ URI_ALLOW_LIST: payloadString })if (!error) {setOpen(false)- ui.setNotification({ category: 'success', message: 'Successfully added domain' })+ ui.setNotification({ category: 'success', message: 'Successfully added URL' })} else {ui.setNotification({error,category: 'error',- message: `Failed to update domain: ${error?.message}`,+ message: `Failed to update URL: ${error?.message}`,})}setSubmitting(false)}- const onConfirmDeleteDomain = async (domain?: string) => {- if (!domain) return+ const onConfirmDeleteUrl = async (url?: string) => {+ if (!url) returnsetIsDeleting(true)- // Remove selectedDomain from array and update- const payload = URI_ALLOW_LIST_ARRAY.filter((e: string) => e !== domain)+ // Remove selectedUrl from array and update+ const payload = URI_ALLOW_LIST_ARRAY.filter((e: string) => e !== url)const { error } = await authConfig.update({ URI_ALLOW_LIST: payload.toString() })if (!error) {- setSelectedDomainToDelete(undefined)- ui.setNotification({ category: 'success', message: 'Successfully removed domain' })+ setSelectedUrlToDelete(undefined)+ ui.setNotification({ category: 'success', message: 'Successfully removed URL' })} else {ui.setNotification({error,category: 'error',- message: `Failed to remove domain: ${error?.message}`,+ message: `Failed to remove URL: ${error?.message}`,})}@@ -88,12 +88,12 @@ const RedirectDomains = () => {<div className="flex items-center justify-between"><FormHeadertitle="Redirect URLs"- description="URLs that auth providers are permitted to redirect to post authentication"+ description="URLs that auth providers are permitted to redirect to post authentication."/><Tooltip.Root delayDuration={0}><Tooltip.Trigger><Button disabled={!canUpdateConfig} onClick={() => setOpen(true)}>- Add domain+ Add URL</Button></Tooltip.Trigger>{!canUpdateConfig && (@@ -113,36 +113,47 @@ const RedirectDomains = () => {)}</Tooltip.Root></div>- <DomainList canUpdate={canUpdateConfig} onSelectDomainToDelete={setSelectedDomainToDelete} />+ <RedirectUrlList canUpdate={canUpdateConfig} onSelectUrlToDelete={setSelectedUrlToDelete} /><ModalhideFootersize="small"visible={open}onCancel={() => setOpen(!open)}- header={<h3 className="text-sm">Add a new domain</h3>}+ header={<h3 className="text-sm">Add a new URL</h3>}><FormvalidateOnBlur- id="new-domain-form"- initialValues={{ domain: '' }}- validationSchema={newDomainSchema}- onSubmit={onAddNewDomain}+ id="new-redirect-url-form"+ initialValues={{ url: '' }}+ validationSchema={newUrlSchema}+ onSubmit={onAddNewUrl}>{({ isSubmitting }: { isSubmitting: boolean }) => {return (<div className="mb-4 space-y-4 pt-4"><div className="px-5"><p className="text-scale-1100 text-sm">- This will add a domain to a list of allowed domains that can interact with your- Authenticaton services for this project.+ This will add a URL to a list of allowed URLs that can interact with your+ Authentication services for this project.+ </p>+ <p className="text-scale-1100 text-sm mt-2">+ Supports{' '}+ <a+ target="_blank"+ className="text-brand-900 hover:text-brand-1200 transition-colors"+ href="https://github.com/gobwas/glob"+ >+ globs+ </a>+ {' '}where <code>.</code> and <code>/</code> are used as delimiters.</p></div><div className="border-overlay-border border-t" /><div className="px-5"><Input- id="domain"- name="domain"- label="Domain"+ id="url"+ name="url"+ label="URL"placeholder="https://mydomain.com"/></div>@@ -150,13 +161,13 @@ const RedirectDomains = () => {<div className="px-5"><Buttonblock- form="new-domain-form"+ form="new-redirect-url-form"htmlType="submit"size="medium"disabled={isSubmitting}loading={isSubmitting}>- Add domain+ Add URL</Button></div></div>@@ -167,18 +178,18 @@ const RedirectDomains = () => {<ModalhideFootersize="small"- visible={selectedDomainToDelete !== undefined}- header={<h3 className="text-sm">Remove domain</h3>}- onCancel={() => setSelectedDomainToDelete(undefined)}+ visible={selectedUrlToDelete !== undefined}+ header={<h3 className="text-sm">Remove URL</h3>}+ onCancel={() => setSelectedUrlToDelete(undefined)}><div className="mb-4 space-y-4 pt-4"><div className="px-5"><p className="text-scale-1100 mb-2 text-sm">Are you sure you want to remove{' '}- <span className="text-scale-1200">{selectedDomainToDelete}</span>?+ <span className="text-scale-1200">{selectedUrlToDelete}</span>?</p><p className="text-scale-1100 text-sm">- This domain will no longer work with your authentication configuration.+ This URL will no longer work with your authentication configuration.</p></div><div className="border-overlay-border border-t"></div>@@ -187,7 +198,7 @@ const RedirectDomains = () => {blocktype="default"size="medium"- onClick={() => setSelectedDomainToDelete(undefined)}+ onClick={() => setSelectedUrlToDelete(undefined)}>Cancel</Button>@@ -196,9 +207,9 @@ const RedirectDomains = () => {size="medium"type="warning"loading={isDeleting}- onClick={() => onConfirmDeleteDomain(selectedDomainToDelete)}+ onClick={() => onConfirmDeleteUrl(selectedUrlToDelete)}>- {isDeleting ? 'Removing...' : 'Remove domain'}+ {isDeleting ? 'Removing...' : 'Remove URL'}</Button></div></div>@@ -207,4 +218,4 @@ const RedirectDomains = () => {)}-export default observer(RedirectDomains)+export default observer(RedirectUrls)diff --git a/studio/components/interfaces/Auth/RedirectDomains/ValueContainer.tsx b/studio/components/interfaces/Auth/RedirectUrls/ValueContainer.tsxsimilarity index 100%rename from studio/components/interfaces/Auth/RedirectDomains/ValueContainer.tsxrename to studio/components/interfaces/Auth/RedirectUrls/ValueContainer.tsxdiff --git a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsxindex 888e2c4d161..f6eb10046a4 100644--- a/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx+++ b/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx@@ -13,7 +13,7 @@ import {FormSectionLabel,} from 'components/ui/Forms'import { useStore, checkPermissions } from 'hooks'-import { domainRegex } from './../Auth.constants'+import { urlRegex } from './../Auth.constants'import { defaultDisabledSmtpFormValues } from './SmtpForm.constants'import { generateFormValues, isSmtpEnabled } from './SmtpForm.utils'@@ -55,7 +55,7 @@ const SmtpForm = () => {},then: (schema) =>schema- .matches(domainRegex, 'Must be a valid URL or IP address')+ .matches(urlRegex, 'Must be a valid URL or IP address').required('Host URL is required.'),otherwise: (schema) => schema,}),diff --git a/studio/pages/project/[ref]/auth/settings.tsx b/studio/pages/project/[ref]/auth/settings.tsxindex ea14e36bc0d..0bc8ed2ca78 100644--- a/studio/pages/project/[ref]/auth/settings.tsx+++ b/studio/pages/project/[ref]/auth/settings.tsx@@ -6,7 +6,7 @@ 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'+import RedirectUrls from 'components/interfaces/Auth/RedirectUrls/RedirectUrls'import { AuthLayout } from 'components/layouts'import { FormsContainer } from 'components/ui/Forms'import NoPermission from 'components/ui/NoPermission'@@ -26,7 +26,7 @@ const PageLayout: NextPageWithLayout = () => {return (<FormsContainer><AutoSchemaForm />- <RedirectDomains />+ <RedirectUrls /><AuthProvidersForm /></FormsContainer>)diff --git a/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx b/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsxindex 3ceb9e46087..7d10bf80748 100644--- a/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx+++ b/studio/stores/authConfig/schema/AuthProviders/AuthProvidersFormValidation.tsx@@ -1,5 +1,5 @@import { boolean, number, object, string } from 'yup'-import { domainRegex } from 'components/interfaces/Auth/Auth.constants'+import { urlRegex } from 'components/interfaces/Auth/Auth.constants'const JSON_SCHEMA_VERSION = 'http://json-schema.org/draft-07/schema#'@@ -379,7 +379,7 @@ const EXTERNAL_PROVIDER_AZURE = {then: (schema) => schema.required('Secret ID is required'),otherwise: (schema) => schema,}),- EXTERNAL_AZURE_URL: string().matches(domainRegex, 'Must be a valid URL').optional(),+ EXTERNAL_AZURE_URL: string().matches(urlRegex, 'Must be a valid URL').optional(),}),misc: {iconKey: 'microsoft-icon',@@ -577,7 +577,7 @@ const EXTERNAL_PROVIDER_GITLAB = {then: (schema) => schema.required('Client Secret is required'),otherwise: (schema) => schema,}),- EXTERNAL_GITLAB_URL: string().matches(domainRegex, 'Must be a valid URL').optional(),+ EXTERNAL_GITLAB_URL: string().matches(urlRegex, 'Must be a valid URL').optional(),}),misc: {iconKey: 'gitlab-icon',@@ -665,8 +665,8 @@ const EXTERNAL_PROVIDER_KEYCLOAK = {EXTERNAL_KEYCLOAK_URL: string().when('EXTERNAL_KEYCLOAK_ENABLED', {is: true,then: (schema) =>- schema.matches(domainRegex, 'Must be a valid URL').required('Realm URL is required'),- otherwise: (schema) => schema.matches(domainRegex, 'Must be a valid URL'),+ schema.matches(urlRegex, 'Must be a valid URL').required('Realm URL is required'),+ otherwise: (schema) => schema.matches(urlRegex, 'Must be a valid URL'),}),}),misc: {@@ -931,7 +931,7 @@ const EXTERNAL_PROVIDER_WORKOS = {validationSchema: object().shape({EXTERNAL_WORKOS_ENABLED: boolean().required(),EXTERNAL_WORKOS_URL: string()- .matches(domainRegex, 'Must be a valid URL')+ .matches(urlRegex, 'Must be a valid URL').when('EXTERNAL_WORKOS_ENABLED', {is: true,then: (schema) => schema.required('WorkOS URL is required'),diff --git a/studio/tests/components/Auth/Auth.constants.test.js b/studio/tests/components/Auth/Auth.constants.test.jsindex 4c8a3fe62f3..ab7504014dc 100644--- a/studio/tests/components/Auth/Auth.constants.test.js+++ b/studio/tests/components/Auth/Auth.constants.test.js@@ -1,87 +1,87 @@-import { domainRegex } from 'components/interfaces/Auth/Auth.constants'+import { urlRegex } from 'components/interfaces/Auth/Auth.constants'describe('Auth.constants: domainRegex', () => {test('should validate typical URLs', () => {const mockInput1 = 'http://domain.com'- const output1 = domainRegex.test(mockInput1)+ const output1 = urlRegex.test(mockInput1)expect(output1).toBe(true)const mockInput2 = 'https://supabase.io'- const output2 = domainRegex.test(mockInput2)+ const output2 = urlRegex.test(mockInput2)expect(output2).toBe(true)const mockInput3 = 'https://new-domain-vercel.com'- const output3 = domainRegex.test(mockInput3)+ const output3 = urlRegex.test(mockInput3)expect(output3).toBe(true)const mockInput4 = 'www.test-domain.com'- const output4 = domainRegex.test(mockInput4)+ const output4 = urlRegex.test(mockInput4)expect(output4).toBe(true)})test('should validate app-based domains', () => {const mockInput1 = 'exp://exp.host/some-app'- const output1 = domainRegex.test(mockInput1)+ const output1 = urlRegex.test(mockInput1)expect(output1).toBe(true)const mockInput2 = 'exp://exp.host/some-app?release-channel=default'- const output2 = domainRegex.test(mockInput2)+ const output2 = urlRegex.test(mockInput2)expect(output2).toBe(true)})test('should validate subdomains', () => {const mockInput1 = 'https://app.supabase.com'- const output1 = domainRegex.test(mockInput1)+ const output1 = urlRegex.test(mockInput1)expect(output1).toBe(true)})test('should validate localhost URLs', () => {const mockInput1 = 'http://localhost:3000'- const output1 = domainRegex.test(mockInput1)+ const output1 = urlRegex.test(mockInput1)expect(output1).toBe(true)})test('should validate URLs with query params', () => {const mockInput1 = 'https://supabase.com?name=test'- const output1 = domainRegex.test(mockInput1)+ const output1 = urlRegex.test(mockInput1)expect(output1).toBe(true)const mockInput2 = 'https://supabase.com?name=test&description=hello&page=2'- const output2 = domainRegex.test(mockInput2)+ const output2 = urlRegex.test(mockInput2)expect(output2).toBe(true)})test('should validate URLs with wildcards', () => {const mockInput1 = 'https://supabase*.com'- const output1 = domainRegex.test(mockInput1)+ const output1 = urlRegex.test(mockInput1)expect(output1).toBe(true)const mockInput2 = 'https://supabase.com/*'- const output2 = domainRegex.test(mockInput2)+ const output2 = urlRegex.test(mockInput2)expect(output2).toBe(true)const mockInput3 = 'https://new-*-domain.com/*'- const output3 = domainRegex.test(mockInput3)+ const output3 = urlRegex.test(mockInput3)expect(output3).toBe(true)const mockInput4 = 'https://new-*-domain.com/*/*/*'- const output4 = domainRegex.test(mockInput4)+ const output4 = urlRegex.test(mockInput4)expect(output4).toBe(true)const mockInput5 = 'https://sub-*-domain.new-*-domain.com/*/*/*'- const output5 = domainRegex.test(mockInput5)+ const output5 = urlRegex.test(mockInput5)expect(output5).toBe(true)})test('should invalidate invalid URLs', () => {const mockInput1 = 'supabase'- const output1 = domainRegex.test(mockInput1)+ const output1 = urlRegex.test(mockInput1)expect(output1).toBe(false)const mockInput2 = 'mailto:[email protected]'- const output2 = domainRegex.test(mockInput2)+ const output2 = urlRegex.test(mockInput2)expect(output2).toBe(false)const mockInput4 = 'hello world.com'- const output4 = domainRegex.test(mockInput4)+ const output4 = urlRegex.test(mockInput4)expect(output4).toBe(false)const mockInput5 = '[email protected]'- const output5 = domainRegex.test(mockInput5)+ const output5 = urlRegex.test(mockInput5)expect(output5).toBe(false)})})