Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat(no-auth): added no auth frontend setup (#11218)

SagarRajput-7c0fe996e7a2a
diff --git a/frontend/src/AppRoutes/__tests__/Private.test.tsx b/frontend/src/AppRoutes/__tests__/Private.test.tsx
index a4a6f9e2db..ffdee88051 100644
--- a/frontend/src/AppRoutes/__tests__/Private.test.tsx
+++ b/frontend/src/AppRoutes/__tests__/Private.test.tsx
@@ -166,6 +166,7 @@ function createMockAppContext(
userPreferences: [],
hostsData: null,
isLoggedIn: true,
+ isPreflightLoading: false,
org: [{ createdAt: 0, id: 'org-id', displayName: 'Test Org' }],
isFetchingUser: false,
isFetchingActiveLicense: false,
diff --git a/frontend/src/AppRoutes/index.tsx b/frontend/src/AppRoutes/index.tsx
index a0d0fa73d0..83b9b5b846 100644
--- a/frontend/src/AppRoutes/index.tsx
+++ b/frontend/src/AppRoutes/index.tsx
@@ -59,6 +59,7 @@ function App(): JSX.Element {
isLoggedIn: isLoggedInState,
featureFlags,
org,
+ isPreflightLoading,
} = useAppContext();
const [routes, setRoutes] = useState<AppRoutes[]>(defaultRoutes);
const isAIAssistantEnabled = useIsAIAssistantEnabled();
@@ -386,6 +387,10 @@ function App(): JSX.Element {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isCloudUser, isEnterpriseSelfHostedUser]);
+ if (isPreflightLoading) {
+ return <Spinner tip="Loading..." />;
+ }
+
// if the user is in logged in state
if (isLoggedInState) {
// if the setup calls are loading then return a spinner
diff --git a/frontend/src/api/__tests__/interceptorRejected.no-auth.test.ts b/frontend/src/api/__tests__/interceptorRejected.no-auth.test.ts
new file mode 100644
index 0000000000..d4334bcb86
--- /dev/null
+++ b/frontend/src/api/__tests__/interceptorRejected.no-auth.test.ts
@@ -0,0 +1,72 @@
+import axios from 'axios';
+import { getIsNoAuthMode } from 'utils/noAuthMode';
+
+import { interceptorRejected } from '../index';
+
+jest.mock('utils/noAuthMode', () => ({
+ getIsNoAuthMode: jest.fn(),
+}));
+
+jest.mock('api/v2/sessions/rotate/post', () => ({
+ __esModule: true,
+ default: jest.fn(),
+}));
+
+jest.mock('AppRoutes/utils', () => ({
+ __esModule: true,
+ default: jest.fn(),
+}));
+
+jest.mock('../utils', () => ({
+ Logout: jest.fn(),
+}));
+
+// oxlint-disable-next-line typescript/no-require-imports typescript/no-var-requires
+const post = require('api/v2/sessions/rotate/post').default;
+// oxlint-disable-next-line typescript/no-require-imports typescript/no-var-requires
+const { Logout } = require('../utils');
+
+describe('interceptorRejected — no-auth mode', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ jest.spyOn(axios, 'isAxiosError').mockReturnValue(true);
+ });
+
+ it('does NOT call rotate or Logout when no-auth mode is enabled on 401', async () => {
+ (getIsNoAuthMode as jest.Mock).mockReturnValue(true);
+
+ const error = {
+ isAxiosError: true,
+ response: {
+ status: 401,
+ config: { url: '/dashboards', method: 'get' },
+ },
+ config: { url: '/dashboards', headers: {} },
+ };
+
+ await interceptorRejected(error as any).catch(() => {});
+
+ expect(post).not.toHaveBeenCalled();
+ expect(Logout).not.toHaveBeenCalled();
+ });
+
+ it('DOES attempt rotate when no-auth mode is disabled on 401', async () => {
+ (getIsNoAuthMode as jest.Mock).mockReturnValue(false);
+ (post as jest.Mock).mockResolvedValue({
+ data: { accessToken: 'a', refreshToken: 'b' },
+ });
+
+ const error = {
+ isAxiosError: true,
+ response: {
+ status: 401,
+ config: { url: '/dashboards', method: 'get' },
+ },
+ config: { url: '/dashboards', headers: {} },
+ };
+
+ await interceptorRejected(error as any).catch(() => {});
+
+ expect(post).toHaveBeenCalled();
+ });
+});
diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts
index 180868ee72..27e937848e 100644
--- a/frontend/src/api/index.ts
+++ b/frontend/src/api/index.ts
@@ -13,6 +13,7 @@ import { Events } from 'constants/events';
import { LOCALSTORAGE } from 'constants/localStorage';
import { getBasePath } from 'utils/basePath';
import { eventEmitter } from 'utils/getEventEmitter';
+import { getIsNoAuthMode } from 'utils/noAuthMode';
import apiV1, { apiAlertManager, apiV2, apiV3, apiV4, apiV5 } from './apiV1';
import { Logout } from './utils';
@@ -108,7 +109,10 @@ export const interceptorRejected = async (
if (axios.isAxiosError(value) && value.response) {
const { response } = value;
+ const isNoAuthMode = getIsNoAuthMode();
+
if (
+ !isNoAuthMode &&
response.status === 401 &&
// if the session rotate call or the create session errors out with 401 or the delete sessions call returns 401 then we do not retry!
response.config.url !== '/sessions/rotate' &&
@@ -140,16 +144,20 @@ export const interceptorRejected = async (
return await Promise.resolve(reResponse);
} catch (error) {
if ((error as AxiosError)?.response?.status === 401) {
- Logout();
+ void Logout();
}
}
} catch (error) {
- Logout();
+ void Logout();
}
}
- if (response.status === 401 && response.config.url === '/sessions/rotate') {
- Logout();
+ if (
+ !isNoAuthMode &&
+ response.status === 401 &&
+ response.config.url === '/sessions/rotate'
+ ) {
+ void Logout();
}
}
return await Promise.reject(value);
diff --git a/frontend/src/components/NoAuthBanner/NoAuthBanner.module.scss b/frontend/src/components/NoAuthBanner/NoAuthBanner.module.scss
new file mode 100644
index 0000000000..7486bfc0a2
--- /dev/null
+++ b/frontend/src/components/NoAuthBanner/NoAuthBanner.module.scss
@@ -0,0 +1,13 @@
+.banner {
+ height: var(--spacing-20);
+
+ a {
+ color: var(--callout-warning-title);
+ text-decoration: underline;
+
+ &:hover {
+ color: var(--callout-warning-title);
+ opacity: 0.8;
+ }
+ }
+}
diff --git a/frontend/src/components/NoAuthBanner/NoAuthBanner.tsx b/frontend/src/components/NoAuthBanner/NoAuthBanner.tsx
new file mode 100644
index 0000000000..190aac4b7c
--- /dev/null
+++ b/frontend/src/components/NoAuthBanner/NoAuthBanner.tsx
@@ -0,0 +1,26 @@
+import { PersistedAnnouncementBanner } from '@signozhq/ui/announcement-banner';
+
+import styles from './NoAuthBanner.module.scss';
+
+export function NoAuthBanner(): JSX.Element {
+ return (
+ <PersistedAnnouncementBanner
+ type="warning"
+ storageKey="no-auth-banner-v1"
+ testId="no-auth-banner"
+ className={styles.banner}
+ >
+ Impersonation mode: authentication is disabled. Anyone with access to this
+ instance has admin privileges.{' '}
+ <a
+ href="https://signoz.io/docs/manage/administrator-guide/configuration/no-auth-mode/"
+ target="_blank"
+ rel="noreferrer"
+ >
+ Learn more
+ </a>
+ </PersistedAnnouncementBanner>
+ );
+}
+
+export default NoAuthBanner;
diff --git a/frontend/src/components/NoAuthBanner/__tests__/NoAuthBanner.test.tsx b/frontend/src/components/NoAuthBanner/__tests__/NoAuthBanner.test.tsx
new file mode 100644
index 0000000000..69ca03577f
--- /dev/null
+++ b/frontend/src/components/NoAuthBanner/__tests__/NoAuthBanner.test.tsx
@@ -0,0 +1,24 @@
+import { render, screen } from 'tests/test-utils';
+
+import { NoAuthBanner } from '../NoAuthBanner';
+
+describe('NoAuthBanner', () => {
+ it('renders the no-auth message', () => {
+ render(<NoAuthBanner />);
+ expect(
+ screen.getByText(/Impersonation mode: authentication is disabled/i),
+ ).toBeInTheDocument();
+ });
+
+ it('renders with the warning test id', () => {
+ render(<NoAuthBanner />);
+ expect(screen.getByTestId('no-auth-banner')).toBeInTheDocument();
+ });
+
+ it('renders a docs link that opens in a new tab', () => {
+ render(<NoAuthBanner />);
+ const link = screen.getByRole('link', { name: /learn more/i });
+ expect(link).toHaveAttribute('target', '_blank');
+ expect(link).toHaveAttribute('rel', 'noreferrer');
+ });
+});
diff --git a/frontend/src/components/ServiceAccountDrawer/KeysTab.tsx b/frontend/src/components/ServiceAccountDrawer/KeysTab.tsx
index 2d246fa212..4d2af705af 100644
--- a/frontend/src/components/ServiceAccountDrawer/KeysTab.tsx
+++ b/frontend/src/components/ServiceAccountDrawer/KeysTab.tsx
@@ -1,7 +1,7 @@
import React, { useCallback, useMemo } from 'react';
import { KeyRound, X } from '@signozhq/icons';
import { Button } from '@signozhq/ui/button';
-import { Skeleton, Table } from 'antd';
+import { Skeleton, Table, Tooltip } from 'antd';
import type { ColumnsType } from 'antd/es/table/interface';
import type { ServiceaccounttypesGettableFactorAPIKeyDTO } from 'api/generated/services/sigNoz.schemas';
import AuthZTooltip from 'components/AuthZTooltip/AuthZTooltip';
@@ -110,28 +110,34 @@ function buildColumns({
onClick: (e): void => e.stopPropagation(),
style: { cursor: 'default' },
}),
- render: (_, record): JSX.Element => (
- <AuthZTooltip
- checks={[
- buildAPIKeyDeletePermission(record.id),
- buildSADetachPermission(accountId),
- ]}
- enabled={!isDisabled && !!accountId}
- >
- <Button
- variant="ghost"
- size="sm"
- color="destructive"
- disabled={isDisabled}
- onClick={(): void => {
- onRevokeClick(record.id);
- }}
- className="keys-tab__revoke-btn"
+ render: (_, record): JSX.Element => {
+ const tooltipTitle = isDisabled ? 'Service account disabled' : 'Revoke Key';
+ return (
+ <AuthZTooltip
+ checks={[
+ buildAPIKeyDeletePermission(record.id),
+ buildSADetachPermission(accountId),
+ ]}
+ enabled={!isDisabled && !!accountId}
>
- <X size={12} />
- </Button>
- </AuthZTooltip>
- ),
+ <Tooltip title={tooltipTitle}>
+ <Button
+ variant="ghost"
+ size="sm"
+ color="destructive"
+ disabled={isDisabled}
+ onClick={(e): void => {
+ e.stopPropagation();
+ onRevokeClick(record.id);
+ }}
+ className="keys-tab__revoke-btn"
+ >
+ <X size={12} />
+ </Button>
+ </Tooltip>
+ </AuthZTooltip>
+ );
+ },
},
];
}
diff --git a/frontend/src/container/Home/Home.tsx b/frontend/src/container/Home/Home.tsx
index a540d92761..ddfa2a85dc 100644
--- a/frontend/src/container/Home/Home.tsx
+++ b/frontend/src/container/Home/Home.tsx
@@ -18,6 +18,8 @@ import listUserPreferences from 'api/v1/user/preferences/list';
import updateUserPreferenceAPI from 'api/v1/user/preferences/name/update';
import Header from 'components/Header/Header';
import HeaderRightSection from 'components/HeaderRightSection/HeaderRightSection';
+import NoAuthBanner from 'components/NoAuthBanner/NoAuthBanner';
+import { getIsNoAuthMode } from 'utils/noAuthMode';
import { ENTITY_VERSION_V5 } from 'constants/app';
import { ORG_PREFERENCES } from 'constants/orgPreferences';
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
@@ -196,7 +198,7 @@ export default function Home(): JSX.Element {
const { mutate: updateUserPreference } = useMutation(updateUserPreferenceAPI, {
onSuccess: () => {
setUpdatingUserPreferences(false);
- refetchUserPreferences();
+ void refetchUserPreferences();
},
onError: () => {
setUpdatingUserPreferences(false);
@@ -204,7 +206,7 @@ export default function Home(): JSX.Element {
});
const handleWillDoThisLater = (): void => {
- logEvent('Welcome Checklist: Will do this later clicked', {});
+ void logEvent('Welcome Checklist: Will do this later clicked', {});
setUpdatingUserPreferences(true);
updateUserPreference({
@@ -271,11 +273,12 @@ export default function Home(): JSX.Element {
}, [metricsOnboardingData, handleUpdateChecklistDoneItem]);
useEffect(() => {
- logEvent('Homepage: Visited', {});
+ void logEvent('Homepage: Visited', {});
}, []);
return (
<div className="home-container">
+ {getIsNoAuthMode() && <NoAuthBanner />}
<div className="sticky-header">
<Header
leftComponent={
@@ -298,9 +301,9 @@ export default function Home(): JSX.Element {
autoAdjustOverflow
onOpenChange={(visible): void => {
if (visible) {
- logEvent('Welcome Checklist: Expanded', {});
+ void logEvent('Welcome Checklist: Expanded', {});
} else {
- logEvent('Welcome Checklist: Minimized', {});
+ void logEvent('Welcome Checklist: Minimized', {});
}
}}
content={renderWelcomeChecklistModal()}
@@ -353,7 +356,7 @@ export default function Home(): JSX.Element {
className="active-ingestion-card-actions"
onClick={(e: React.MouseEvent): void => {
// eslint-disable-next-line sonarjs/no-duplicate-string
- logEvent('Homepage: Ingestion Active Explore clicked', {
+ void logEvent('Homepage: Ingestion Active Explore clicked', {
source: 'Logs',
});
safeNavigate(ROUTES.LOGS_EXPLORER, {
@@ -362,7 +365,7 @@ export default function Home(): JSX.Element {
}}
onKeyDown={(e): void => {
if (e.key === 'Enter') {
- logEvent('Homepage: Ingestion Active Explore clicked', {
+ void logEvent('Homepage: Ingestion Active Explore clicked', {
source: 'Logs',
});
history.push(ROUTES.LOGS_EXPLORER);
@@ -396,7 +399,7 @@ export default function Home(): JSX.Element {
role="button"
tabIndex={0}
onClick={(e: React.MouseEvent): void => {
- logEvent('Homepage: Ingestion Active Explore clicked', {
+ void logEvent('Homepage: Ingestion Active Explore clicked', {
source: 'Traces',
});
safeNavigate(ROUTES.TRACES_EXPLORER, {
@@ -405,7 +408,7 @@ export default function Home(): JSX.Element {
}}
onKeyDown={(e): void => {
if (e.key === 'Enter') {
- logEvent('Homepage: Ingestion Active Explore clicked', {
+ void logEvent('Homepage: Ingestion Active Explore clicked', {
source: 'Traces',
});
history.push(ROUTES.TRACES_EXPLORER);
@@ -439,7 +442,7 @@ export default function Home(): JSX.Element {
role="button"
tabIndex={0}
onClick={(e: React.MouseEvent): void => {
- logEvent('Homepage: Ingestion Active Explore clicked', {
+ void logEvent('Homepage: Ingestion Active Explore clicked', {
source: 'Metrics',
});
safeNavigate(ROUTES.METRICS_EXPLORER, {
@@ -448,7 +451,7 @@ export default function Home(): JSX.Element {
}}
onKeyDown={(e): void => {
if (e.key === 'Enter') {
- logEvent('Homepage: Ingestion Active Explore clicked', {
+ void logEvent('Homepage: Ingestion Active Explore clicked', {
source: 'Metrics',
});
history.push(ROUTES.METRICS_EXPLORER);
@@ -496,7 +499,7 @@ export default function Home(): JSX.Element {
className="periscope-btn secondary"
prefix={<Wrench size={14} />}
onClick={(e: React.MouseEvent): void => {
- logEvent('Homepage: Explore clicked', {
+ void logEvent('Homepage: Explore clicked', {
source: 'Logs',
});
safeNavigate(ROUTES.LOGS_EXPLORER, {
@@ -513,7 +516,7 @@ export default function Home(): JSX.Element {
className="periscope-btn secondary"
prefix={<Wrench size={14} />}
onClick={(e: React.MouseEvent): void => {
- logEvent('Homepage: Explore clicked', {
+ void logEvent('Homepage: Explore clicked', {
source: 'Traces',
});
safeNavigate(ROUTES.TRACES_EXPLORER, {
@@ -530,7 +533,7 @@ export default function Home(): JSX.Element {
className="periscope-btn secondary"
prefix={<Wrench size={14} />}
onClick={(e: React.MouseEvent): void => {
- logEvent('Homepage: Explore clicked', {
+ void logEvent('Homepage: Explore clicked', {
source: 'Metrics',
});
safeNavigate(ROUTES.METRICS_EXPLORER_EXPLORER, {
@@ -569,7 +572,7 @@ export default function Home(): JSX.Element {
className="periscope-btn secondary"
prefix={<Plus size={14} />}
onClick={(e: React.MouseEvent): void => {
- logEvent('Homepage: Explore clicked', {
+ void logEvent('Homepage: Explore clicked', {
source: 'Dashboards',
});
safeNavigate(ROUTES.ALL_DASHBOARD, {
@@ -614,7 +617,7 @@ export default function Home(): JSX.Element {
className="periscope-btn secondary"
prefix={<Plus size={14} />}
onClick={(e: React.MouseEvent): void => {
- logEvent('Homepage: Explore clicked', {
+ void logEvent('Homepage: Explore clicked', {
source: 'Alerts',
});
safeNavigate(ROUTES.ALERTS_NEW, {
diff --git a/frontend/src/container/MembersSettings/MembersSettings.tsx b/frontend/src/container/MembersSettings/MembersSettings.tsx
index 2f9a566e7d..964d891776 100644
--- a/frontend/src/container/MembersSettings/MembersSettings.tsx
+++ b/frontend/src/container/MembersSettings/MembersSettings.tsx
@@ -21,7 +21,6 @@ const PAGE_SIZE = 20;
function MembersSettings(): JSX.Element {
const history = useHistory();
const urlQuery = useUrlQuery();
-
const pageParam = parseInt(urlQuery.get('page') ?? '1', 10);
const currentPage = Number.isNaN(pageParam) || pageParam < 1 ? 1 : pageParam;
@@ -146,7 +145,7 @@ function MembersSettings(): JSX.Element {
: `Deleted ⎯ ${deletedCount}`;
const handleInviteComplete = useCallback((): void => {
- refetchUsers();
+ void refetchUsers();
}, [refetchUsers]);
const handleRowClick = useCallback((member: MemberRow): void => {
@@ -158,7 +157,7 @@ function MembersSettings(): JSX.Element {
}, []);
const handleMemberEditComplete = useCallback((): void => {
- refetchUsers();
+ void refetchUsers();
}, [refetchUsers]);
return (
diff --git a/frontend/src/container/MySettings/UserInfo/index.tsx b/frontend/src/container/MySettings/UserInfo/index.tsx
index 6df030c1af..ecde821914 100644
--- a/frontend/src/container/MySettings/UserInfo/index.tsx
+++ b/frontend/src/container/MySettings/UserInfo/index.tsx
@@ -80,10 +80,10 @@ function UserInfo(): JSX.Element {
currentPassword === updatePassword;
const onSaveHandler = async (): Promise<void> => {
- logEvent('Account Settings: Name Updated', {
+ void logEvent('Account Settings: Name Updated', {
name: changedName,
});
- logEvent(
+ void logEvent(
'Account Settings: Name Updated',
{
name: changedName,
diff --git a/frontend/src/container/OnboardingV2Container/AddDataSource/AddDataSource.tsx b/frontend/src/container/OnboardingV2Container/AddDataSource/AddDataSource.tsx
index 7478fc4b3f..e5d0d123ff 100644
--- a/frontend/src/container/OnboardingV2Container/AddDataSource/AddDataSource.tsx
+++ b/frontend/src/container/OnboardingV2Container/AddDataSource/AddDataSource.tsx
@@ -209,7 +209,7 @@ function OnboardingAddDataSource(): JSX.Element {
};
useEffect(() => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.STARTED}`,
{},
);
@@ -253,7 +253,7 @@ function OnboardingAddDataSource(): JSX.Element {
setSelectedFramework(null);
setSelectedEnvironment(null);
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.DATA_SOURCE_SELECTED}`,
{
dataSource: dataSource.label,
@@ -276,7 +276,7 @@ function OnboardingAddDataSource(): JSX.Element {
};
const handleSelectFramework = (option: any): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.FRAMEWORK_SELECTED}`,
{
dataSource: selectedDataSource?.label,
@@ -309,7 +309,7 @@ function OnboardingAddDataSource(): JSX.Element {
selectedEnvironment: any,
baseURL?: string,
): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.ENVIRONMENT_SELECTED}`,
{
dataSource: selectedDataSource?.label,
@@ -351,7 +351,7 @@ function OnboardingAddDataSource(): JSX.Element {
groupDataSourcesByTags(filteredDataSources as Entity[]),
);
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.DATA_SOURCE_SEARCHED}`,
{
searchedDataSource: query,
@@ -485,7 +485,7 @@ function OnboardingAddDataSource(): JSX.Element {
};
const handleShowInviteTeamMembersModal = (): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.INVITE_TEAM_MEMBER_BUTTON_CLICKED}`,
{
dataSource: selectedDataSource?.label,
@@ -498,7 +498,7 @@ function OnboardingAddDataSource(): JSX.Element {
};
const handleSubmitDataSourceRequest = (): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.DATA_SOURCE_REQUESTED}`,
{
requestedDataSource: dataSourceRequest,
@@ -513,7 +513,7 @@ function OnboardingAddDataSource(): JSX.Element {
};
const handleRaiseRequest = (): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.DATA_SOURCE_REQUESTED}`,
{
requestedDataSource: searchQuery,
@@ -635,7 +635,7 @@ function OnboardingAddDataSource(): JSX.Element {
size={14}
className="onboarding-header-container-close-icon"
onClick={(e): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.CLOSE_ONBOARDING_CLICKED}`,
{
currentPage: setupStepItems[currentStep]?.title || '',
@@ -970,7 +970,7 @@ function OnboardingAddDataSource(): JSX.Element {
disabled={!selectedDataSource}
shape="round"
onClick={(e): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.CONFIGURED_PRODUCT}`,
{
dataSource: selectedDataSource?.label,
@@ -1038,7 +1038,7 @@ function OnboardingAddDataSource(): JSX.Element {
type="default"
shape="round"
onClick={(): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BACK_BUTTON_CLICKED}`,
{
dataSource: selectedDataSource?.label,
@@ -1057,7 +1057,7 @@ function OnboardingAddDataSource(): JSX.Element {
type="primary"
shape="round"
onClick={(e): void => {
- logEvent(
+ void logEvent(
`${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.BASE}: ${ONBOARDING_V3_ANALYTICS_EVENTS_MAP?.CONTINUE_BUTTON_CLICKED}`,
{
dataSource: selectedDataSource?.label,
diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx
index ccd59fb8c9..483741d55a 100644
--- a/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx
+++ b/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx
@@ -75,7 +75,7 @@ function AuthDomain(): JSX.Element {
{
onSuccess: () => {
toast.success('Domain deleted successfully');
- refetchAuthDomainListResponse();
+ void refetchAuthDomainListResponse();
hideDeleteModal();
},
onError: (error) => {
diff --git a/frontend/src/container/RoutingPolicies/__tests__/testUtils.ts b/frontend/src/container/RoutingPolicies/__tests__/testUtils.ts
index 69657470f5..a75987a08f 100644
--- a/frontend/src/container/RoutingPolicies/__tests__/testUtils.ts
+++ b/frontend/src/container/RoutingPolicies/__tests__/testUtils.ts
@@ -101,6 +101,7 @@ export function getAppContextMockState(
userPreferences: null,
hostsData: null,
isLoggedIn: false,
+ isPreflightLoading: false,
org: null,
isFetchingUser: false,
isFetchingActiveLicense: false,
diff --git a/frontend/src/container/SideNav/SideNav.styles.scss b/frontend/src/container/SideNav/SideNav.styles.scss
index 81e01e8de7..b5d8c8a6a8 100644
--- a/frontend/src/container/SideNav/SideNav.styles.scss
+++ b/frontend/src/container/SideNav/SideNav.styles.scss
@@ -1120,6 +1120,7 @@
.user-settings-dropdown-logout-section {
color: var(--danger-background);
+ pointer-events: auto;
}
}
}
diff --git a/frontend/src/container/SideNav/SideNav.tsx b/frontend/src/container/SideNav/SideNav.tsx
index 2ce7d82b2e..368d4f9bbe 100644
--- a/frontend/src/container/SideNav/SideNav.tsx
+++ b/frontend/src/container/SideNav/SideNav.tsx
@@ -408,7 +408,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
);
const handleReorderShortcutNavItems = (): void => {
- logEvent('Sidebar V2: Save shortcuts clicked', {
+ void logEvent('Sidebar V2: Save shortcuts clicked', {
shortcuts: tempPinnedMenuItems.map((item) => item.key),
});
setPinnedMenuItems(tempPinnedMenuItems);
@@ -436,7 +436,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
const isWorkspaceBlocked = trialInfo?.workSpaceBlock || false;
const onClickGetStarted = (event: MouseEvent): void => {
- logEvent('Sidebar: Menu clicked', {
+ void logEvent('Sidebar: Menu clicked', {
menuRoute: '/get-started',
menuLabel: 'Get Started',
});
@@ -651,7 +651,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
} else if (item) {
onClickHandler(item?.key as string, event);
}
- logEvent('Sidebar V2: Menu clicked', {
+ void logEvent('Sidebar V2: Menu clicked', {
menuRoute: item?.key,
menuLabel: item?.label,
});
@@ -794,7 +794,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
onTogglePin={
allowPin
? (item): void => {
- logEvent(
+ void logEvent(
`Sidebar V2: Menu item ${item.isPinned ? 'unpinned' : 'pinned'}`,
{
menuRoute: item.key,
@@ -841,7 +841,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
const event = (info as SidebarItem & { domEvent?: MouseEvent }).domEvent;
if (item && !('type' in item)) {
- logEvent('Help Popover: Item clicked', {
+ void logEvent('Help Popover: Item clicked', {
menuRoute: item.key,
menuLabel: String(item.label),
});
@@ -890,7 +890,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
menuLabel = item.label;
}
- logEvent('Settings Popover: Item clicked', {
+ void logEvent('Settings Popover: Item clicked', {
menuRoute: item?.key,
menuLabel,
});
@@ -927,7 +927,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
}
break;
case 'logout':
- Logout();
+ void Logout();
break;
default:
}
@@ -1081,7 +1081,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
<div
className="nav-section-title-icon reorder"
onClick={(): void => {
- logEvent('Sidebar V2: Manage shortcuts clicked', {});
+ void logEvent('Sidebar V2: Manage shortcuts clicked', {});
setIsReorderShortcutNavItemsModalOpen(true);
}}
>
@@ -1128,7 +1128,7 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
return;
}
const newCollapsedState = !isMoreMenuCollapsed;
- logEvent('Sidebar V2: More menu clicked', {
+ void logEvent('Sidebar V2: More menu clicked', {
action: isMoreMenuCollapsed ? 'expand' : 'collapse',
});
setIsMoreMenuCollapsed(newCollapsedState);
@@ -1234,14 +1234,14 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
open={isReorderShortcutNavItemsModalOpen}
closable
onCancel={(): void => {
- logEvent('Sidebar V2: Manage shortcuts dismissed', {});
+ void logEvent('Sidebar V2: Manage shortcuts dismissed', {});
hideReorderShortcutNavItemsModal();
}}
footer={[
<Button
key="cancel"
onClick={(): void => {
- logEvent('Sidebar V2: Manage shortcuts dismissed', {});
+ void logEvent('Sidebar V2: Manage shortcuts dismissed', {});
hideReorderShortcutNavItemsModal();
}}
className="periscope-btn cancel-btn secondary-btn"
diff --git a/frontend/src/container/SideNav/menuItems.tsx b/frontend/src/container/SideNav/menuItems.tsx
index 08c7232bbe..0139c7c17c 100644
--- a/frontend/src/container/SideNav/menuItems.tsx
+++ b/frontend/src/container/SideNav/menuItems.tsx
@@ -1,3 +1,5 @@
+import { MenuProps } from 'antd';
+import ROUTES from 'constants/routes';
import {
ArrowUpRight,
BarChart,
@@ -35,15 +37,13 @@ import {
Users,
Binoculars,
} from '@signozhq/icons';
-import { Style } from '@signozhq/design-tokens';
-import { MenuProps } from 'antd';
-import ROUTES from 'constants/routes';
import {
SecondaryMenuItemKey,
SettingsNavSection,
SidebarItem,
} from './sideNav.types';
+import { Style } from '@signozhq/design-tokens';
export const getStartedMenuItem = {
key: ROUTES.GET_STARTED,
diff --git a/frontend/src/pages/Settings/Settings.tsx b/frontend/src/pages/Settings/Settings.tsx
index ae2ecb869a..dc22f15784 100644
--- a/frontend/src/pages/Settings/Settings.tsx
+++ b/frontend/src/pages/Settings/Settings.tsx
@@ -321,7 +321,7 @@ function SettingsPage(): JSX.Element {
isDisabled={false}
showIcon={false}
onClick={(event): void => {
- logEvent('Settings V2: Menu clicked', {
+ void logEvent('Settings V2: Menu clicked', {
menuLabel: item.label,
menuRoute: item.key,
});
diff --git a/frontend/src/providers/App/App.tsx b/frontend/src/providers/App/App.tsx
index 925915d518..db737e72a6 100644
--- a/frontend/src/providers/App/App.tsx
+++ b/frontend/src/providers/App/App.tsx
@@ -13,8 +13,11 @@ import { useQuery } from 'react-query';
import getLocalStorageApi from 'api/browser/localstorage/get';
import setLocalStorageApi from 'api/browser/localstorage/set';
import { useGetHosts } from 'api/generated/services/zeus';
+import { useGetGlobalConfig } from 'api/generated/services/global';
import { useGetMyUser } from 'api/generated/services/users';
import listOrgPreferences from 'api/v1/org/preferences/list';
+import { clearAuthStorage } from 'utils/clearAuthStorage';
+import { getIsNoAuthMode, setNoAuthMode } from 'utils/noAuthMode';
import listUserPreferences from 'api/v1/user/preferences/list';
import getUserVersion from 'api/v1/version/get';
import { LOCALSTORAGE } from 'constants/localStorage';
@@ -70,11 +73,48 @@ export function AppProvider({ children }: PropsWithChildren): JSX.Element {
const [isLoggedIn, setIsLoggedIn] = useState<boolean>(
(): boolean => getLocalStorageApi(LOCALSTORAGE.IS_LOGGED_IN) === 'true',
);
+ const [isPreflightLoading, setIsPreflightLoading] = useState<boolean>(true);
const [org, setOrg] = useState<Organization[] | null>(null);
const [changelog, setChangelog] = useState<ChangelogSchema | null>(null);
const [showChangelogModal, setShowChangelogModal] = useState<boolean>(false);
+ // Pre-flight: discover auth mode from public global config.
+ // On success: in impersonation mode → clear stale tokens, force isLoggedIn=true,
+ // set noAuthMode singleton so the axios interceptor (outside React)
+ // can skip the rotate-logout chain.
+ // On failure: fail-safe to normal auth flow (treat as not no-auth).
+ const { data: globalConfigData, isLoading: isFetchingGlobalConfig } =
+ useGetGlobalConfig({
+ query: {
+ retry: 2,
+ retryDelay: 1000,
+ refetchOnWindowFocus: false,
+ staleTime: Infinity,
+ },
+ });
+
+ useEffect(() => {
+ if (isFetchingGlobalConfig) {
+ return;
+ }
+
+ const impersonationEnabled =
+ globalConfigData?.data?.identN?.impersonation?.enabled === true;
+
+ if (impersonationEnabled) {
+ clearAuthStorage();
+ setDefaultUser(getUserDefaults());
+ setLocalStorageApi(LOCALSTORAGE.IS_LOGGED_IN, 'true');
+ setNoAuthMode(true);
+ setIsLoggedIn(true);
+ } else {
+ setNoAuthMode(false);
+ }
+
+ setIsPreflightLoading(false);
+ }, [globalConfigData, isFetchingGlobalConfig]);
+
// fetcher for current user
// user will only be fetched if the user id and token is present
// if logged out and trying to hit any route none of these calls will trigger
@@ -366,6 +406,9 @@ export function AppProvider({ children }: PropsWithChildren): JSX.Element {
// global event listener for LOGOUT event to clean the app context state
useGlobalEventListener('LOGOUT', () => {
+ if (getIsNoAuthMode()) {
+ return;
+ } // logout is meaningless in no-auth; defensively no-op
setIsLoggedIn(false);
setDefaultUser(getUserDefaults());
setActiveLicense(null);
@@ -385,6 +428,7 @@ export function AppProvider({ children }: PropsWithChildren): JSX.Element {
orgPreferences,
hostsData,
isLoggedIn,
+ isPreflightLoading,
org,
isFetchingUser,
isFetchingActiveLicense,
@@ -425,6 +469,7 @@ export function AppProvider({ children }: PropsWithChildren): JSX.Element {
isLoggedIn,
hostsData,
hostsFetchError,
+ isPreflightLoading,
org,
orgPreferences,
activeLicenseRefetch,
diff --git a/frontend/src/providers/App/__tests__/App.test.tsx b/frontend/src/providers/App/__tests__/App.test.tsx
index 5b7940375f..2a6a020c10 100644
--- a/frontend/src/providers/App/__tests__/App.test.tsx
+++ b/frontend/src/providers/App/__tests__/App.test.tsx
@@ -2,6 +2,7 @@ import { ReactElement } from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { renderHook, waitFor } from '@testing-library/react';
import setLocalStorageApi from 'api/browser/localstorage/set';
+import { getIsNoAuthMode, setNoAuthMode } from 'utils/noAuthMode';
import { LOCALSTORAGE } from 'constants/localStorage';
import { SINGLE_FLIGHT_WAIT_TIME_MS } from 'hooks/useAuthZ/constants';
import { server } from 'mocks-server/server';
@@ -13,6 +14,7 @@ import { AppProvider, useAppContext } from '../App';
const MY_USER_URL = 'http://localhost/api/v2/users/me';
const MY_ORG_URL = 'http://localhost/api/v2/orgs/me';
+const GLOBAL_CONFIG_URL = 'http://localhost/api/v1/global/config';
jest.mock('constants/env', () => ({
ENVIRONMENT: { baseURL: 'http://localhost', wsURL: '' },
@@ -336,3 +338,126 @@ describe('AppProvider when authz/check fails', () => {
);
});
});
+
+describe('AppProvider no-auth preflight', () => {
+ beforeEach(() => {
+ queryClient.clear();
+ });
+
+ afterEach(() => {
+ setNoAuthMode(false);
+ });
+
+ it('sets noAuthMode singleton when impersonation is enabled', async () => {
+ server.use(
+ rest.get(GLOBAL_CONFIG_URL, (_, res, ctx) =>
+ res(
+ ctx.status(200),
+ ctx.json({
+ data: { identN: { impersonation: { enabled: true } } },
+ }),
+ ),
+ ),
+ );
+
+ const wrapper = createWrapper();
+ const { result } = renderHook(() => useAppContext(), { wrapper });
+
+ await waitFor(
+ () => {
+ expect(result.current.isPreflightLoading).toBe(false);
+ },
+ { timeout: 3000 },
+ );
+
+ expect(getIsNoAuthMode()).toBe(true);
+ });
+
+ it('leaves noAuthMode singleton false when impersonation is disabled', async () => {
+ server.use(
+ rest.get(GLOBAL_CONFIG_URL, (_, res, ctx) =>
+ res(
+ ctx.status(200),
+ ctx.json({
+ data: { identN: { impersonation: { enabled: false } } },
+ }),
+ ),
+ ),
+ );
+
+ const wrapper = createWrapper();
+ const { result } = renderHook(() => useAppContext(), { wrapper });
+
+ await waitFor(
+ () => {
+ expect(result.current.isPreflightLoading).toBe(false);
+ },
+ { timeout: 3000 },
+ );
+
+ expect(getIsNoAuthMode()).toBe(false);
+ });
+
+ it('clears stale auth tokens from localStorage and resets in-memory JWT state when impersonation is enabled', async () => {
+ setLocalStorageApi(LOCALSTORAGE.AUTH_TOKEN, 'stale-access-token');
+ setLocalStorageApi(LOCALSTORAGE.REFRESH_AUTH_TOKEN, 'stale-refresh-token');
+ setLocalStorageApi(LOCALSTORAGE.LOGGED_IN_USER_EMAIL, '[email protected]');
+ setLocalStorageApi(LOCALSTORAGE.LOGGED_IN_USER_NAME, 'Old Name');
+
+ server.use(
+ rest.get(GLOBAL_CONFIG_URL, (_, res, ctx) =>
+ res(
+ ctx.status(200),
+ ctx.json({
+ data: { identN: { impersonation: { enabled: true } } },
+ }),
+ ),
+ ),
+ );
+
+ const wrapper = createWrapper();
+ const { result } = renderHook(() => useAppContext(), { wrapper });
+
+ await waitFor(
+ () => {
+ expect(result.current.isPreflightLoading).toBe(false);
+ },
+ { timeout: 3000 },
+ );
+
+ // localStorage cleared
+ expect(localStorage.getItem(LOCALSTORAGE.AUTH_TOKEN)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.REFRESH_AUTH_TOKEN)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.LOGGED_IN_USER_EMAIL)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.LOGGED_IN_USER_NAME)).toBeNull();
+
+ // in-memory JWTs reset so stale tokens don't linger in context or React Query keys
+ expect(result.current.user.accessJwt).toBe('');
+ expect(result.current.user.refreshJwt).toBe('');
+ });
+
+ it('transitions isPreflightLoading from true to false once preflight resolves', async () => {
+ server.use(
+ rest.get(GLOBAL_CONFIG_URL, (_, res, ctx) =>
+ res(
+ ctx.status(200),
+ ctx.json({
+ data: { identN: { impersonation: { enabled: false } } },
+ }),
+ ),
+ ),
+ );
+
+ const wrapper = createWrapper();
+ const { result } = renderHook(() => useAppContext(), { wrapper });
+
+ expect(result.current.isPreflightLoading).toBe(true);
+
+ await waitFor(
+ () => {
+ expect(result.current.isPreflightLoading).toBe(false);
+ },
+ { timeout: 3000 },
+ );
+ });
+});
diff --git a/frontend/src/providers/App/types.ts b/frontend/src/providers/App/types.ts
index 614ec78b38..509978b72c 100644
--- a/frontend/src/providers/App/types.ts
+++ b/frontend/src/providers/App/types.ts
@@ -20,6 +20,7 @@ export interface IAppContext {
userPreferences: UserPreference[] | null;
hostsData: GetHosts200 | null;
isLoggedIn: boolean;
+ isPreflightLoading: boolean;
org: Organization[] | null;
isFetchingUser: boolean;
isFetchingActiveLicense: boolean;
diff --git a/frontend/src/tests/test-utils.tsx b/frontend/src/tests/test-utils.tsx
index b86ed8d34a..d1e61acb1f 100644
--- a/frontend/src/tests/test-utils.tsx
+++ b/frontend/src/tests/test-utils.tsx
@@ -243,6 +243,7 @@ export function getAppContextMock(
isFetchingOrgPreferences: false,
orgPreferencesFetchError: null,
isLoggedIn: true,
+ isPreflightLoading: false,
showChangelogModal: false,
updateUser: jest.fn(),
updateOrg: jest.fn(),
diff --git a/frontend/src/utils/__tests__/clearAuthStorage.test.ts b/frontend/src/utils/__tests__/clearAuthStorage.test.ts
new file mode 100644
index 0000000000..4d879dee2f
--- /dev/null
+++ b/frontend/src/utils/__tests__/clearAuthStorage.test.ts
@@ -0,0 +1,39 @@
+import { LOCALSTORAGE } from 'constants/localStorage';
+
+import { clearAuthStorage } from '../clearAuthStorage';
+
+describe('clearAuthStorage', () => {
+ beforeEach(() => {
+ localStorage.clear();
+ });
+
+ it('removes all auth-related localStorage keys', () => {
+ localStorage.setItem(LOCALSTORAGE.AUTH_TOKEN, 'access');
+ localStorage.setItem(LOCALSTORAGE.REFRESH_AUTH_TOKEN, 'refresh');
+ localStorage.setItem(LOCALSTORAGE.IS_LOGGED_IN, 'true');
+ localStorage.setItem(LOCALSTORAGE.LOGGED_IN_USER_EMAIL, '[email protected]');
+ localStorage.setItem(LOCALSTORAGE.LOGGED_IN_USER_NAME, 'old');
+ localStorage.setItem(LOCALSTORAGE.IS_IDENTIFIED_USER, 'true');
+ localStorage.setItem(LOCALSTORAGE.USER_ID, 'abc');
+
+ clearAuthStorage();
+
+ expect(localStorage.getItem(LOCALSTORAGE.AUTH_TOKEN)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.REFRESH_AUTH_TOKEN)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.IS_LOGGED_IN)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.LOGGED_IN_USER_EMAIL)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.LOGGED_IN_USER_NAME)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.IS_IDENTIFIED_USER)).toBeNull();
+ expect(localStorage.getItem(LOCALSTORAGE.USER_ID)).toBeNull();
+ });
+
+ it('preserves non-auth localStorage keys', () => {
+ localStorage.setItem(LOCALSTORAGE.THEME, 'dark');
+ localStorage.setItem(LOCALSTORAGE.AUTH_TOKEN, 'access');
+
+ clearAuthStorage();
+
+ expect(localStorage.getItem(LOCALSTORAGE.THEME)).toBe('dark');
+ expect(localStorage.getItem(LOCALSTORAGE.AUTH_TOKEN)).toBeNull();
+ });
+});
diff --git a/frontend/src/utils/clearAuthStorage.ts b/frontend/src/utils/clearAuthStorage.ts
new file mode 100644
index 0000000000..5101fb28ec
--- /dev/null
+++ b/frontend/src/utils/clearAuthStorage.ts
@@ -0,0 +1,16 @@
+import deleteLocalStorageKey from 'api/browser/localstorage/remove';
+import { LOCALSTORAGE } from 'constants/localStorage';
+
+const AUTH_KEYS: LOCALSTORAGE[] = [
+ LOCALSTORAGE.AUTH_TOKEN,
+ LOCALSTORAGE.REFRESH_AUTH_TOKEN,
+ LOCALSTORAGE.IS_LOGGED_IN,
+ LOCALSTORAGE.LOGGED_IN_USER_EMAIL,
+ LOCALSTORAGE.LOGGED_IN_USER_NAME,
+ LOCALSTORAGE.IS_IDENTIFIED_USER,
+ LOCALSTORAGE.USER_ID,
+];
+
+export const clearAuthStorage = (): void => {
+ AUTH_KEYS.forEach((key) => deleteLocalStorageKey(key));
+};
diff --git a/frontend/src/utils/noAuthMode.ts b/frontend/src/utils/noAuthMode.ts
new file mode 100644
index 0000000000..a5ca6225ee
--- /dev/null
+++ b/frontend/src/utils/noAuthMode.ts
@@ -0,0 +1,7 @@
+let _isNoAuthMode = false;
+
+export const setNoAuthMode = (value: boolean): void => {
+ _isNoAuthMode = value;
+};
+
+export const getIsNoAuthMode = (): boolean => _isNoAuthMode;