Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(settings): prompt re-auth on project secret API keys page (#73030)

Tom Piccirello83326d56b5e9
diff --git a/frontend/src/scenes/settings/Settings.tsx b/frontend/src/scenes/settings/Settings.tsx
index 4e2f5c9ff221..c6b3f1b68bf6 100644
--- a/frontend/src/scenes/settings/Settings.tsx
+++ b/frontend/src/scenes/settings/Settings.tsx
@@ -165,13 +165,13 @@ export function Settings({
return () => clearTimeout(timer)
}, [selectedSectionId, isSearching])
- // Currently environment and project settings do not require periodic re-authentication,
- // though this is likely to change (see https://github.com/posthog/posthog/pull/22421).
- // In the meantime, we don't want a needless re-authentication modal:
- const AuthenticationAreaComponent =
- selectedLevel !== 'environment' && selectedLevel !== 'project'
- ? TimeSensitiveAuthenticationArea
- : React.Fragment
+ // Environment and project settings don't require periodic re-authentication by default,
+ // so we avoid a needless re-authentication modal (see https://github.com/posthog/posthog/pull/22421).
+ // The exception is sections that opt in via `requiresReauthentication` — e.g. credential
+ // management — which prompt on navigation like user- and organization-level settings do.
+ const requiresReauthentication =
+ (selectedLevel !== 'environment' && selectedLevel !== 'project') || !!selectedSection?.requiresReauthentication
+ const AuthenticationAreaComponent = requiresReauthentication ? TimeSensitiveAuthenticationArea : React.Fragment
const options: SettingOption[] = settingsInSidebar
? settings.map((s) => ({
diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsx
index 14679dde9dc7..87dacf9ccada 100644
--- a/frontend/src/scenes/settings/SettingsMap.tsx
+++ b/frontend/src/scenes/settings/SettingsMap.tsx
@@ -1569,6 +1569,7 @@ export const SETTINGS_MAP: SettingSection[] = [
id: 'environment-secret-api-keys',
title: 'Project secret API keys',
flag: 'PROJECT_SECRET_API_KEYS',
+ requiresReauthentication: true,
settings: [
{
id: 'environment-secret-api-keys',
diff --git a/frontend/src/scenes/settings/types.ts b/frontend/src/scenes/settings/types.ts
index a293467638a3..76d916dd71ed 100644
--- a/frontend/src/scenes/settings/types.ts
+++ b/frontend/src/scenes/settings/types.ts
@@ -337,4 +337,12 @@ export interface SettingSection extends Pick<Setting, 'flag'> {
* product's own configuration scene).
*/
hideFromNavigation?: boolean
+
+ /**
+ * When true, navigating to this section prompts for re-authentication if the sensitive
+ * session has expired — matching how user- and organization-level settings behave. Use for
+ * environment/project sections that manage credentials, which otherwise only surface the
+ * re-auth modal reactively when a write is attempted.
+ */
+ requiresReauthentication?: boolean
}