Skip to content

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

feat: make publishable, secret api keys page front-and-center (#40751)

Stojan Dimitrovski34ca04300c19
diff --git a/apps/docs/content/guides/api/api-keys.mdx b/apps/docs/content/guides/api/api-keys.mdx
index 2fc13803347..6b32efd7ac1 100644
--- a/apps/docs/content/guides/api/api-keys.mdx
+++ b/apps/docs/content/guides/api/api-keys.mdx
@@ -117,7 +117,7 @@ The secret key is an improvement over the old JWT-based `service_role` key, and
Below are some starting guidelines on how to securely work with secret keys:
- Always work with secret keys on computers you fully own or control.
-- Use secure & encrypted send tools to share API keys with others (often provided by good password managers), but prefer the [API Keys](/dashboard/project/_/settings/api-keys/new) dashboard instead.
+- Use secure & encrypted send tools to share API keys with others (often provided by good password managers), but prefer the [API Keys](/dashboard/project/_/settings/api-keys) dashboard instead.
- Prefer encrypting them when stored in files or environment variables.
- Do not add in source control, especially for CI scripts and tools. Prefer using the tool's native secrets capability instead.
- Prefer using a separate secret key for each separate backend component of your application, so that if one is found to be vulnerable or to have leaked the key you will only need to change it and not all.
@@ -129,7 +129,7 @@ Below are some starting guidelines on how to securely work with secret keys:
Don't rush if this has happened, or you are suspecting it has. Make sure you have fully considered the situation and have remediated the root cause of the suspicion or vulnerability **first**. Consider using the [OWASP Risk Rating Methodology](https://owasp.org/www-community/OWASP_Risk_Rating_Methodology) as an easy way to identify the severity of the incident and to plan your next steps.
-Rotating a secret key (`sb_secret_...`) is easy and painless. Use the [API Keys](/dashboard/project/_/settings/api-keys/new) dashboard to create a new secret API key, then replace it with the compromised key. Once all components are using the new key, delete the compromised one.
+Rotating a secret key (`sb_secret_...`) is easy and painless. Use the [API Keys](/dashboard/project/_/settings/api-keys) dashboard to create a new secret API key, then replace it with the compromised key. Once all components are using the new key, delete the compromised one.
**Deleting a secret key is irreversible and once done it will be gone forever.**
@@ -154,7 +154,7 @@ As the publishable and secret keys are no longer JWT-based, there are some known
If you know or suspect that the JWT secret itself is leaked, refer to the section on [rotating the JWT](#what-to-do-if-a-secret-key-or-servicerole-has-been-leaked-or-compromised).
-If the JWT secret is secure, prefer substituting the `service_role` JWT-based key with a new secret key which you can create in the [API Keys](/dashboard/project/_/settings/api-keys/new) dashboard. This will prevent downtime for your application.
+If the JWT secret is secure, prefer substituting the `service_role` JWT-based key with a new secret key which you can create in the [API Keys](/dashboard/project/_/settings/api-keys) dashboard. This will prevent downtime for your application.
### Can I still use my old `anon` and `service-role` API keys after enabling the publishable and secret keys?
@@ -162,7 +162,7 @@ Yes. This allows you to transition between the API keys with zero downtime by gr
### How do I deactivate the `anon` and `service_role` JWT-based API keys after moving to publishable and secret keys?
-You can do this in the [API Keys](/dashboard/project/_/settings/api-keys/new) dashboard. To prevent downtime in your application's components, use the last used indicators on the page to confirm that these are no longer used before deactivating.
+You can do this in the [API Keys](/dashboard/project/_/settings/api-keys) dashboard. To prevent downtime in your application's components, use the last used indicators on the page to confirm that these are no longer used before deactivating.
You can re-activate them should you need to.
diff --git a/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx b/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx
index b466ba23c72..8ee3779dcc5 100644
--- a/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx
+++ b/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx
@@ -9,13 +9,13 @@ const ApiKeysLayout = ({ children }: PropsWithChildren) => {
const navigationItems = [
{
- label: 'API Keys',
- href: `/project/${projectRef}/settings/api-keys/new`,
+ label: 'Publishable and secret API keys',
+ href: `/project/${projectRef}/settings/api-keys`,
id: 'new-keys',
},
{
- label: 'Legacy API Keys',
- href: `/project/${projectRef}/settings/api-keys`,
+ label: 'Legacy anon, service_role API keys',
+ href: `/project/${projectRef}/settings/api-keys/legacy`,
id: 'legacy-keys',
},
]
diff --git a/apps/studio/next.config.js b/apps/studio/next.config.js
index 8fd06b57628..78783e6833b 100644
--- a/apps/studio/next.config.js
+++ b/apps/studio/next.config.js
@@ -159,6 +159,11 @@ const nextConfig = {
destination: '/project/:ref/storage/files/buckets/:bucketId',
permanent: true,
},
+ {
+ permanent: true,
+ source: '/project/:ref/settings/api-keys/new',
+ destination: '/project/:ref/settings/api-keys',
+ },
{
source: '/project/:ref/settings/storage',
destination: '/project/:ref/storage/files/settings',
diff --git a/apps/studio/pages/project/[ref]/settings/api-keys/index.tsx b/apps/studio/pages/project/[ref]/settings/api-keys/index.tsx
index 373744e4511..99e475e2c9d 100644
--- a/apps/studio/pages/project/[ref]/settings/api-keys/index.tsx
+++ b/apps/studio/pages/project/[ref]/settings/api-keys/index.tsx
@@ -1,25 +1,34 @@
+import {
+ ApiKeysCreateCallout,
+ ApiKeysFeedbackBanner,
+} from 'components/interfaces/APIKeys/ApiKeysIllustrations'
+import { useApiKeysVisibility } from 'components/interfaces/APIKeys/hooks/useApiKeysVisibility'
+import { PublishableAPIKeys } from 'components/interfaces/APIKeys/PublishableAPIKeys'
+import { SecretAPIKeys } from 'components/interfaces/APIKeys/SecretAPIKeys'
import ApiKeysLayout from 'components/layouts/APIKeys/APIKeysLayout'
import DefaultLayout from 'components/layouts/DefaultLayout'
import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'
-import { DisplayApiSettings } from 'components/ui/ProjectSettings/DisplayApiSettings'
-import { ToggleLegacyApiKeysPanel } from 'components/ui/ProjectSettings/ToggleLegacyApiKeys'
-import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
+import { DisableInteraction } from 'components/ui/DisableInteraction'
import type { NextPageWithLayout } from 'types'
+import { Separator } from 'ui'
-const ApiKeysLegacyPage: NextPageWithLayout = () => {
- const { projectSettingsShowDisableLegacyApiKeys } = useIsFeatureEnabled([
- 'project_settings:show_disable_legacy_api_keys',
- ])
+const ApiKeysNewPage: NextPageWithLayout = () => {
+ const { shouldDisableUI, canInitApiKeys } = useApiKeysVisibility()
return (
<>
- <DisplayApiSettings showTitle={false} showNotice={false} />
- {projectSettingsShowDisableLegacyApiKeys && <ToggleLegacyApiKeysPanel />}
+ {canInitApiKeys && <ApiKeysCreateCallout />}
+ <ApiKeysFeedbackBanner />
+ <DisableInteraction disabled={shouldDisableUI} className="flex flex-col gap-8">
+ <PublishableAPIKeys />
+ <Separator />
+ <SecretAPIKeys />
+ </DisableInteraction>
</>
)
}
-ApiKeysLegacyPage.getLayout = (page) => (
+ApiKeysNewPage.getLayout = (page) => (
<DefaultLayout>
<SettingsLayout>
<ApiKeysLayout>{page}</ApiKeysLayout>
@@ -27,4 +36,4 @@ ApiKeysLegacyPage.getLayout = (page) => (
</DefaultLayout>
)
-export default ApiKeysLegacyPage
+export default ApiKeysNewPage
diff --git a/apps/studio/pages/project/[ref]/settings/api-keys/legacy.tsx b/apps/studio/pages/project/[ref]/settings/api-keys/legacy.tsx
new file mode 100644
index 00000000000..a7b2cde1fbd
--- /dev/null
+++ b/apps/studio/pages/project/[ref]/settings/api-keys/legacy.tsx
@@ -0,0 +1,26 @@
+import ApiKeysLayout from 'components/layouts/APIKeys/APIKeysLayout'
+import DefaultLayout from 'components/layouts/DefaultLayout'
+import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'
+import { DisplayApiSettings } from 'components/ui/ProjectSettings/DisplayApiSettings'
+import { ToggleLegacyApiKeysPanel } from 'components/ui/ProjectSettings/ToggleLegacyApiKeys'
+import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
+import type { NextPageWithLayout } from 'types'
+
+const ApiKeysLegacyPage: NextPageWithLayout = () => {
+ return (
+ <>
+ <DisplayApiSettings showTitle={false} showNotice={false} />
+ <ToggleLegacyApiKeysPanel />
+ </>
+ )
+}
+
+ApiKeysLegacyPage.getLayout = (page) => (
+ <DefaultLayout>
+ <SettingsLayout>
+ <ApiKeysLayout>{page}</ApiKeysLayout>
+ </SettingsLayout>
+ </DefaultLayout>
+)
+
+export default ApiKeysLegacyPage
diff --git a/apps/studio/pages/project/[ref]/settings/api-keys/new.tsx b/apps/studio/pages/project/[ref]/settings/api-keys/new.tsx
deleted file mode 100644
index 99e475e2c9d..00000000000
--- a/apps/studio/pages/project/[ref]/settings/api-keys/new.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import {
- ApiKeysCreateCallout,
- ApiKeysFeedbackBanner,
-} from 'components/interfaces/APIKeys/ApiKeysIllustrations'
-import { useApiKeysVisibility } from 'components/interfaces/APIKeys/hooks/useApiKeysVisibility'
-import { PublishableAPIKeys } from 'components/interfaces/APIKeys/PublishableAPIKeys'
-import { SecretAPIKeys } from 'components/interfaces/APIKeys/SecretAPIKeys'
-import ApiKeysLayout from 'components/layouts/APIKeys/APIKeysLayout'
-import DefaultLayout from 'components/layouts/DefaultLayout'
-import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'
-import { DisableInteraction } from 'components/ui/DisableInteraction'
-import type { NextPageWithLayout } from 'types'
-import { Separator } from 'ui'
-
-const ApiKeysNewPage: NextPageWithLayout = () => {
- const { shouldDisableUI, canInitApiKeys } = useApiKeysVisibility()
-
- return (
- <>
- {canInitApiKeys && <ApiKeysCreateCallout />}
- <ApiKeysFeedbackBanner />
- <DisableInteraction disabled={shouldDisableUI} className="flex flex-col gap-8">
- <PublishableAPIKeys />
- <Separator />
- <SecretAPIKeys />
- </DisableInteraction>
- </>
- )
-}
-
-ApiKeysNewPage.getLayout = (page) => (
- <DefaultLayout>
- <SettingsLayout>
- <ApiKeysLayout>{page}</ApiKeysLayout>
- </SettingsLayout>
- </DefaultLayout>
-)
-
-export default ApiKeysNewPage