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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(authz): add fine-grained authorization for notification channels (#12975)
Ashwin Bhatkal67de630d03a0
diff --git a/cmd/authz.go b/cmd/authz.goindex 0265f8af43..70395fc821 100644--- a/cmd/authz.go+++ b/cmd/authz.go@@ -93,18 +93,19 @@ func runGenerateAuthz(_ context.Context) error {registry := coretypes.NewRegistry()allowedResources := map[string]bool{- coretypes.NewResourceRef(coretypes.ResourceServiceAccount).String(): true,- coretypes.NewResourceRef(coretypes.ResourceRole).String(): true,- coretypes.NewResourceRef(coretypes.ResourceMetaResourceFactorAPIKey).String(): true,- coretypes.NewResourceRef(coretypes.ResourceMetaResourceDashboard).String(): true,- coretypes.NewResourceRef(coretypes.ResourceMetaResourceLicense).String(): true,- coretypes.NewResourceRef(coretypes.ResourceMetaResourceSubscription).String(): true,- coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceLogs).String(): true,- coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceTraces).String(): true,- coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceMetrics).String(): true,- coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceMeterMetrics).String(): true,- coretypes.NewResourceRef(coretypes.ResourceMetaResourceQuickFilter).String(): true,- coretypes.NewResourceRef(coretypes.ResourceMetaResourceSavedView).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceServiceAccount).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceRole).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceMetaResourceFactorAPIKey).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceMetaResourceDashboard).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceMetaResourceLicense).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceMetaResourceSubscription).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceLogs).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceTraces).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceMetrics).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceTelemetryResourceMeterMetrics).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceMetaResourceQuickFilter).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceMetaResourceSavedView).String(): true,+ coretypes.NewResourceRef(coretypes.ResourceMetaResourceNotificationChannel).String(): true,}allowedTypes := map[string]bool{}diff --git a/frontend/.storybook/preview.tsx b/frontend/.storybook/preview.tsxindex 78444c0846..6196207cfc 100644--- a/frontend/.storybook/preview.tsx+++ b/frontend/.storybook/preview.tsx@@ -119,7 +119,7 @@ const preview: Preview = {'Planned Downtime','Routing Policies','Channels',- ['List', 'New', 'Edit'],+ ['List', 'List Authz', 'New', 'New Authz', 'Edit', 'Edit Authz'],],'Dashboards',[diff --git a/frontend/public/locales/en-GB/channels.json b/frontend/public/locales/en-GB/channels.jsonindex d0bf9385f2..30b4347499 100644--- a/frontend/public/locales/en-GB/channels.json+++ b/frontend/public/locales/en-GB/channels.json@@ -11,6 +11,7 @@"loading_channels_message": "Loading Channels..","page_title_create": "New Notification Channel","page_title_edit": "Edit Notification Channel",+ "page_title_view": "View Notification Channel","button_save_channel": "Save","button_test_channel": "Test","button_return": "Back",@@ -137,4 +138,4 @@"api_key_required": "API Key is mandatory","to_required": "To field is mandatory","channel_name_required": "Channel name is mandatory"-}\ No newline at end of file+}diff --git a/frontend/public/locales/en/channels.json b/frontend/public/locales/en/channels.jsonindex f11b166b29..3668ba568d 100644--- a/frontend/public/locales/en/channels.json+++ b/frontend/public/locales/en/channels.json@@ -12,6 +12,7 @@"loading_channels_message": "Loading Channels..","page_title_create": "New Notification Channel","page_title_edit": "Edit Notification Channel",+ "page_title_view": "View Notification Channel","button_save_channel": "Save","button_test_channel": "Test","button_return": "Back",@@ -198,4 +199,4 @@"api_key_required": "API Key is mandatory","to_required": "To field is mandatory","channel_name_required": "Channel name is mandatory"-}\ No newline at end of file+}diff --git a/frontend/src/AppRoutes/__tests__/Private.test.tsx b/frontend/src/AppRoutes/__tests__/Private.test.tsxindex ac2cc57575..0edc1cba97 100644--- a/frontend/src/AppRoutes/__tests__/Private.test.tsx+++ b/frontend/src/AppRoutes/__tests__/Private.test.tsx@@ -1451,10 +1451,9 @@ describe('PrivateRoute', () => {await assertRedirectsTo(ROUTES.UN_AUTHORIZED);});- it('should redirect VIEWER from /alerts/channels/new (ADMIN only)', async () => {- // After moving channels under /alerts, CHANNELS_NEW ('/alerts/channels/new')- // is an exact, ADMIN-only route with no overlapping non-exact ALL_CHANNELS- // route to match last, so a VIEWER is now correctly redirected.+ it('lets a VIEWER reach /alerts/channels/new, which authz then gates', () => {+ // CHANNELS_NEW runs on fine-grained authz, so the router no longer decides+ // on the role: the page's own guard denies when `create` is not granted.renderPrivateRoute({initialRoute: ROUTES.CHANNELS_NEW,appContext: {@@ -1463,7 +1462,7 @@ describe('PrivateRoute', () => {},});- await assertRedirectsTo(ROUTES.UN_AUTHORIZED);+ assertStaysOnRoute(ROUTES.CHANNELS_NEW);});it('should allow EDITOR to access /get-started-with-signoz-cloud route', () => {@@ -1547,6 +1546,11 @@ describe('PrivateRoute', () => {keyof typeof routeWithInitialAuthZSupport,AuthzRouteCase> = {+ CHANNELS_NEW: { path: ROUTES.CHANNELS_NEW, deniedRoles: DENIED_ROLES },+ CHANNELS_EDIT: {+ path: ROUTES.CHANNELS_EDIT.replace(':channelId', 'channel-id-1'),+ deniedRoles: DENIED_ROLES,+ },ALL_DASHBOARD: { path: ROUTES.ALL_DASHBOARD, deniedRoles: DENIED_ROLES },DASHBOARD: {path: ROUTES.DASHBOARD.replace(':dashboardId', 'dashboard-id-1'),diff --git a/frontend/src/container/FormAlertChannels/FormAlertChannels.module.scss b/frontend/src/container/FormAlertChannels/FormAlertChannels.module.scssindex bc49be2050..752ee942b2 100644--- a/frontend/src/container/FormAlertChannels/FormAlertChannels.module.scss+++ b/frontend/src/container/FormAlertChannels/FormAlertChannels.module.scss@@ -15,6 +15,13 @@min-width: 0;}+.fields {+ border: 0;+ padding: 0;+ margin: 0;+ min-width: 0;+}+.actions {display: flex;align-items: center;@@ -23,3 +30,9 @@padding: var(--spacing-4) 0;border-top: 1px solid var(--l1-border);}++// TODO: @AshwinBhatkal to be removed once textarea is in signoz ui components+.fields :global(textarea:disabled) {+ opacity: 0.5;+ cursor: not-allowed;+}diff --git a/frontend/src/container/FormAlertChannels/index.tsx b/frontend/src/container/FormAlertChannels/index.tsxindex d7d767ac95..a100f530f7 100644--- a/frontend/src/container/FormAlertChannels/index.tsx+++ b/frontend/src/container/FormAlertChannels/index.tsx@@ -8,6 +8,8 @@ import {ChannelFormValues,ChannelKind,} from 'container/CreateAlertChannels/types';+import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';+import type { BrandedPermission } from 'lib/authz/hooks/useAuthZ/types';import EmailSettings from './Settings/Email';import GoogleChatSettings from './Settings/GoogleChat';@@ -47,6 +49,9 @@ function FormAlertChannels({savingState,testingState,editing = false,+ readOnly = false,+ saveChecks = [],+ testChecks = [],}: FormAlertChannelsProps): JSX.Element {const { t } = useTranslation('channels');const {@@ -85,76 +90,84 @@ function FormAlertChannels({return (<FormProvider {...form}><form className={styles.form}>- <div className={styles.cards}>- <FormCard title={t('section_general')}>- <FormField- label={t('field_channel_name')}- help={editing ? t('help_channel_name_immutable') : undefined}- error={errors.name?.message}- htmlFor="channel-name"- required- >- <Input- id="channel-name"- data-testid="channel-name-textbox"- disabled={editing}- aria-required- {...register('name')}- />- </FormField>+ {/* the @signozhq inputs take no disabled context and the settings+ still render antd textareas; the fieldset turns off both. */}+ <fieldset className={styles.fields} disabled={readOnly}>+ <div className={styles.cards}>+ <FormCard title={t('section_general')}>+ <FormField+ label={t('field_channel_name')}+ help={editing ? t('help_channel_name_immutable') : undefined}+ error={errors.name?.message}+ htmlFor="channel-name"+ required+ >+ <Input+ id="channel-name"+ data-testid="channel-name-textbox"+ disabled={editing}+ aria-required+ {...register('name')}+ />+ </FormField>- <FormField label={t('field_send_resolved')}>- <Controller- control={control}- name="sendResolved"- render={({ field }): JSX.Element => (- <Switch- color="primary"- textPlacement="right"- testId="field-send-resolved-checkbox"- value={!!field.value}- onChange={field.onChange}- />- )}- />- </FormField>+ <FormField label={t('field_send_resolved')}>+ <Controller+ control={control}+ name="sendResolved"+ render={({ field }): JSX.Element => (+ <Switch+ color="primary"+ textPlacement="right"+ testId="field-send-resolved-checkbox"+ value={!!field.value}+ onChange={field.onChange}+ />+ )}+ />+ </FormField>- <FormField label={t('field_channel_type')} htmlFor="channel-type">- <SelectSimple- id="channel-type"- items={CHANNEL_TYPE_OPTIONS}- value={type}- disabled={editing}- onChange={(value): void => onTypeChangeHandler(value as ChannelKind)}- testId="channel-type-select"- />- </FormField>- </FormCard>+ <FormField label={t('field_channel_type')} htmlFor="channel-type">+ <SelectSimple+ id="channel-type"+ items={CHANNEL_TYPE_OPTIONS}+ value={type}+ disabled={editing}+ onChange={(value): void => onTypeChangeHandler(value as ChannelKind)}+ testId="channel-type-select"+ />+ </FormField>+ </FormCard>- {renderSettings()}- </div>+ {renderSettings()}+ </div>+ </fieldset><div className={styles.actions}>- <Button- variant="solid"- color="primary"- size="md"- testId="save-channel-button"- loading={savingState}- onClick={onSaveHandler}- >- {t('button_save_channel')}- </Button>- <Button- variant="outlined"- color="secondary"- size="md"- testId="test-channel-button"- loading={testingState}- onClick={onTestHandler}- >- {t('button_test_channel')}- </Button>+ <AuthZTooltip checks={saveChecks}>+ <Button+ variant="solid"+ color="primary"+ size="md"+ testId="save-channel-button"+ loading={savingState}+ onClick={onSaveHandler}+ >+ {t('button_save_channel')}+ </Button>+ </AuthZTooltip>+ <AuthZTooltip checks={testChecks}>+ <Button+ variant="outlined"+ color="secondary"+ size="md"+ testId="test-channel-button"+ loading={testingState}+ onClick={onTestHandler}+ >+ {t('button_test_channel')}+ </Button>+ </AuthZTooltip></div></form></FormProvider>@@ -171,10 +184,19 @@ interface FormAlertChannelsProps {savingState: boolean;// editing indicates if the form is opened in edit modeediting?: boolean;+ /** The reader has `read` but not `update`, so the fields render disabled. */+ readOnly?: boolean;+ /** Gates saving; a denial disables the button and names the missing scope. */+ saveChecks?: BrandedPermission[];+ /** Gates a test send, which the API allows with `create`. */+ testChecks?: BrandedPermission[];}FormAlertChannels.defaultProps = {editing: undefined,+ readOnly: false,+ saveChecks: [],+ testChecks: [],};export default FormAlertChannels;diff --git a/frontend/src/container/FormAlertRules/BasicInfo.tsx b/frontend/src/container/FormAlertRules/BasicInfo.tsxindex 44a189a542..8021e9b7df 100644--- a/frontend/src/container/FormAlertRules/BasicInfo.tsx+++ b/frontend/src/container/FormAlertRules/BasicInfo.tsx@@ -7,8 +7,7 @@ import logEvent from 'api/common/logEvent';import { ALERTS_DATA_SOURCE_MAP } from 'constants/alerts';import ROUTES from 'constants/routes';import { useChannelOptions } from 'hooks/notificationChannels/useChannelOptions';-import useComponentPermission from 'hooks/useComponentPermission';-import { useAppContext } from 'providers/App/App';+import { useNotificationChannelCollectionPermissions } from 'hooks/notificationChannels/useNotificationChannelCollectionPermissions';import { AlertTypes } from 'types/api/alerts/alertTypes';import { AlertDef, Labels } from 'types/api/alerts/def';import APIError from 'types/api/error';@@ -52,11 +51,8 @@ function BasicInfo({refetch,} = useChannelOptions();- const { user } = useAppContext();- const [addNewChannelPermission] = useComponentPermission(- ['add_new_channel'],- user.role,- );+ const { canCreate: addNewChannelPermission } =+ useNotificationChannelCollectionPermissions();const [shouldBroadCastToAllChannels, setShouldBroadCastToAllChannels] =useState(false);diff --git a/frontend/src/container/FormAlertRules/ChannelSelect/index.tsx b/frontend/src/container/FormAlertRules/ChannelSelect/index.tsxindex 9eef852405..0616b755dc 100644--- a/frontend/src/container/FormAlertRules/ChannelSelect/index.tsx+++ b/frontend/src/container/FormAlertRules/ChannelSelect/index.tsx@@ -2,10 +2,9 @@ import { ReactNode } from 'react';import { useTranslation } from 'react-i18next';import { Plus } from '@signozhq/icons';import { Select, Spin } from 'antd';-import { ChannelOption } from 'hooks/notificationChannels/useChannelOptions';-import useComponentPermission from 'hooks/useComponentPermission';+import { useNotificationChannelCollectionPermissions } from 'hooks/notificationChannels/useNotificationChannelCollectionPermissions';import { useNotifications } from 'hooks/useNotifications';-import { useAppContext } from 'providers/App/App';+import { ChannelOption } from 'hooks/notificationChannels/useChannelOptions';import APIError from 'types/api/error';import { StyledCreateChannelOption, StyledSelect } from './styles';@@ -53,11 +52,8 @@ function ChannelSelect({});}- const { user } = useAppContext();- const [addNewChannelPermission] = useComponentPermission(- ['add_new_channel'],- user.role,- );+ const { canCreate: addNewChannelPermission } =+ useNotificationChannelCollectionPermissions();const renderOptions = (): ReactNode[] => {const children: ReactNode[] = [];diff --git a/frontend/src/container/RolesSettings/hooks/__tests__/useRolePermissions.test.ts b/frontend/src/container/RolesSettings/hooks/__tests__/useRolePermissions.test.tsindex 97d6b19759..66af7272c9 100644--- a/frontend/src/container/RolesSettings/hooks/__tests__/useRolePermissions.test.ts+++ b/frontend/src/container/RolesSettings/hooks/__tests__/useRolePermissions.test.ts@@ -329,7 +329,7 @@ describe('transformTransactionGroupsToResourcePermissions', () => {it('returns all resources from RESOURCE_ORDER even with empty transaction groups', () => {const result = transformTransactionGroupsToResourcePermissions([]);- expect(result).toHaveLength(12);+ expect(result).toHaveLength(13);expect(result.map((r) => r.resourceKind)).toStrictEqual(['factor-api-key','dashboard',@@ -337,6 +337,7 @@ describe('transformTransactionGroupsToResourcePermissions', () => {'logs','meter-metrics','metrics',+ 'notification-channel','quick-filter','role','saved-view',@@ -423,7 +424,7 @@ describe('createEmptyRolePermissions', () => {it('creates permissions for all resources in RESOURCE_ORDER', () => {const result = createEmptyRolePermissions();- expect(result).toHaveLength(12);+ expect(result).toHaveLength(13);expect(result.map((r) => r.resourceKind)).toStrictEqual(['factor-api-key','dashboard',@@ -431,6 +432,7 @@ describe('createEmptyRolePermissions', () => {'logs','meter-metrics','metrics',+ 'notification-channel','quick-filter','role','saved-view',diff --git a/frontend/src/container/RolesSettings/permissions.config.ts b/frontend/src/container/RolesSettings/permissions.config.tsindex ed4f193f4e..cf7b947c80 100644--- a/frontend/src/container/RolesSettings/permissions.config.ts+++ b/frontend/src/container/RolesSettings/permissions.config.ts@@ -1,5 +1,6 @@import {Bot,+ Cable,ChartLine,DraftingCompass,FileKey,@@ -104,6 +105,15 @@ export const RESOURCE_PANELS: Record<AuthZResource, ResourcePanelConfig> = {'Type saved view ID, separate multiple with comma or space',docsAnchor: 'saved-view',},+ 'notification-channel': {+ label: 'Notification Channels',+ description:+ 'Destinations for alert notifications, such as Slack, PagerDuty, webhooks, etc.',+ icon: Cable,+ selectorPlaceholder:+ 'Type notification channel ID, separate multiple with comma or space',+ docsAnchor: 'notification-channel',+ },logs: {label: 'Logs',description: 'Log data collected across the workspace.',diff --git a/frontend/src/hooks/notificationChannels/useNotificationChannelCollectionPermissions.ts b/frontend/src/hooks/notificationChannels/useNotificationChannelCollectionPermissions.tsnew file mode 100644index 0000000000..258f047e00--- /dev/null+++ b/frontend/src/hooks/notificationChannels/useNotificationChannelCollectionPermissions.ts@@ -0,0 +1,39 @@+import {+ NotificationChannelCreatePermission,+ NotificationChannelListPermission,+} from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';+import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';++export interface NotificationChannelCollectionPermissions {+ canList: boolean;+ canCreate: boolean;+ /** A test send is gated on `create` against the wildcard. */+ canTest: boolean;+ isLoading: boolean;+ /**+ * The check itself failed. Callers should fall open (behave as before authz+ * and let the API decide) rather than treat an outage as a denial.+ */+ hasError: boolean;+}++// Module-level so the useQueries identity stays stable across renders.+const CHECKS = [+ NotificationChannelListPermission,+ NotificationChannelCreatePermission,+];++/** Collection-level notification channel permissions (wildcard selector). */+export function useNotificationChannelCollectionPermissions(): NotificationChannelCollectionPermissions {+ const { isGranted, isLoading, error } = useAuthZ(CHECKS);++ const canCreate = isGranted(NotificationChannelCreatePermission);++ return {+ canList: isGranted(NotificationChannelListPermission),+ canCreate,+ canTest: canCreate,+ isLoading,+ hasError: !!error,+ };+}diff --git a/frontend/src/hooks/notificationChannels/useNotificationChannelPermissions.ts b/frontend/src/hooks/notificationChannels/useNotificationChannelPermissions.tsnew file mode 100644index 0000000000..75df38c346--- /dev/null+++ b/frontend/src/hooks/notificationChannels/useNotificationChannelPermissions.ts@@ -0,0 +1,67 @@+import { useMemo } from 'react';+import {+ buildNotificationChannelDeletePermission,+ buildNotificationChannelReadPermission,+ buildNotificationChannelUpdatePermission,+} from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';+import type { BrandedPermission } from 'lib/authz/hooks/useAuthZ/types';+import { useAuthZ } from 'lib/authz/hooks/useAuthZ/useAuthZ';++export interface NotificationChannelPermissions {+ canRead: boolean;+ canUpdate: boolean;+ canDelete: boolean;+ canEdit: boolean;+ isLoading: boolean;+ /** The check failed: callers fall open and let the API decide. */+ hasError: boolean;+ readPermission: BrandedPermission;+ updatePermission: BrandedPermission;+ deletePermission: BrandedPermission;+ editChecks: BrandedPermission[];+}++/** Pass `enabled: false` while the id is unknown, so no check fires against an empty selector. */+export function useNotificationChannelPermissions(+ channelId: string,+ options?: { enabled?: boolean },+): NotificationChannelPermissions {+ const enabled = options?.enabled ?? true;++ const { readPermission, updatePermission, deletePermission } = useMemo(+ () => ({+ readPermission: buildNotificationChannelReadPermission(channelId),+ updatePermission: buildNotificationChannelUpdatePermission(channelId),+ deletePermission: buildNotificationChannelDeletePermission(channelId),+ }),+ [channelId],+ );++ const checks = useMemo(+ () => [readPermission, updatePermission, deletePermission],+ [readPermission, updatePermission, deletePermission],+ );++ const { isGranted, isLoading, error } = useAuthZ(checks, { enabled });++ const canRead = isGranted(readPermission);+ const canUpdate = isGranted(updatePermission);++ const editChecks = useMemo(+ () => [readPermission, updatePermission],+ [readPermission, updatePermission],+ );++ return {+ canRead,+ canUpdate,+ canDelete: isGranted(deletePermission),+ canEdit: canRead && canUpdate,+ isLoading,+ hasError: !!error,+ readPermission,+ updatePermission,+ deletePermission,+ editChecks,+ };+}diff --git a/frontend/src/lib/authz/hooks/useAuthZ/permissions.type.ts b/frontend/src/lib/authz/hooks/useAuthZ/permissions.type.tsindex b5f22658c2..0a54f009cb 100644--- a/frontend/src/lib/authz/hooks/useAuthZ/permissions.type.ts+++ b/frontend/src/lib/authz/hooks/useAuthZ/permissions.type.ts@@ -18,6 +18,11 @@ export default {type: 'metaresource',allowedVerbs: ['create', 'delete', 'list', 'read', 'update'],},+ {+ kind: 'notification-channel',+ type: 'metaresource',+ allowedVerbs: ['create', 'delete', 'list', 'read', 'update'],+ },{kind: 'quick-filter',type: 'metaresource',diff --git a/frontend/src/lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions.ts b/frontend/src/lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions.tsnew file mode 100644index 0000000000..6d89d8669f--- /dev/null+++ b/frontend/src/lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions.ts@@ -0,0 +1,25 @@+import { buildPermission } from '../utils';+import type { BrandedPermission } from '../types';++// Collection-level. Wildcard selector required for correct response key matching.+export const NotificationChannelListPermission = buildPermission(+ 'list',+ 'notification-channel:*',+);+// The test endpoint is gated on `create` against the wildcard, since a test send+// persists nothing and the channel need not exist.+export const NotificationChannelCreatePermission = buildPermission(+ 'create',+ 'notification-channel:*',+);++// Resource-level. Requires a specific channel id.+export const buildNotificationChannelReadPermission = (+ id: string,+): BrandedPermission => buildPermission('read', `notification-channel:${id}`);+export const buildNotificationChannelUpdatePermission = (+ id: string,+): BrandedPermission => buildPermission('update', `notification-channel:${id}`);+export const buildNotificationChannelDeletePermission = (+ id: string,+): BrandedPermission => buildPermission('delete', `notification-channel:${id}`);diff --git a/frontend/src/pages/AlertList/Channels/stories/Channels.stories.tsx b/frontend/src/pages/AlertList/Channels/stories/Channels.stories.tsxindex fd4dfa9f90..7b6b3c9fe8 100644--- a/frontend/src/pages/AlertList/Channels/stories/Channels.stories.tsx+++ b/frontend/src/pages/AlertList/Channels/stories/Channels.stories.tsx@@ -21,7 +21,7 @@ const pageStory = storyMocks(channelsMocks, { layout: 'app' });*/const meta = {title: 'Pages/Alerts/Channels/List',- tags: ['play'],+ tags: ['authz', 'play'],component: AlertList,...pageStory,parameters: { ...pageStory.parameters },diff --git a/frontend/src/pages/AlertList/Channels/stories/authz/Channels.authz.stories.tsx b/frontend/src/pages/AlertList/Channels/stories/authz/Channels.authz.stories.tsxnew file mode 100644index 0000000000..cd98b4543c--- /dev/null+++ b/frontend/src/pages/AlertList/Channels/stories/authz/Channels.authz.stories.tsx@@ -0,0 +1,178 @@+import type { Meta, StoryObj } from '@storybook/react-vite';+import { expect, screen, userEvent, within } from 'storybook/test';++import { storyMocks } from '@/storybook/controls/defineStoryMocks';+import type { PageStoryArgs } from '@/storybook/runtime/resolveStory';++import {+ CREATE,+ DELETE,+ expectDisabled,+ LIST,+ NOTIFICATION_CHANNEL,+ PAGE_LOAD,+ READ,+ UPDATE,+} from '../../../stories/channelAuthz';+import { channelsMocks } from '../Channels.stories.mocks';++import AlertList from '../../../index';++type ChannelsArgs = PageStoryArgs<typeof channelsMocks>;++const pageStory = storyMocks(channelsMocks, { layout: 'app' });++/**+ * The channels list with one permission missing at a time. Every story here is+ * an admin denied exactly what its name says. `list` decides whether the tab+ * renders at all, `create` the New channel button, and the rest are checked per+ * row, when its Actions menu is opened.+ *+ * Route: `/alerts?tab=Channels`.+ */+const meta = {+ title: 'Pages/Alerts/Channels/List Authz',+ tags: ['authz', 'play'],+ component: AlertList,+ ...pageStory,+ parameters: { ...pageStory.parameters },+} satisfies Meta<ChannelsArgs>;++export default meta;++type Story = StoryObj<ChannelsArgs>;++const openRowMenu = async (canvasElement: HTMLElement): Promise<void> => {+ const [trigger] = await within(canvasElement).findAllByRole(+ 'button',+ { name: /^Actions for/ },+ PAGE_LOAD,+ );++ await userEvent.click(trigger);+ await screen.findByRole('menu', undefined, PAGE_LOAD);+};++/** The label itself waits on the row's permission check, so look it up async. */+const rowAction = (name: string): Promise<HTMLElement> =>+ screen.findByRole('menuitem', { name }, PAGE_LOAD);++/**+ * The denial takes the place of the table. The header and its filters stay, as+ * on dashboards, and go inert: the tab says why it is empty rather than+ * vanishing.+ */+export const NoList: Story = {+ args: { revoked: [LIST] },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await canvas.findByText(/is not authorized/, undefined, PAGE_LOAD);+ await expectDisabled(await canvas.findByTestId('channels-search'));+ },+};++/** The list is intact and New channel stays in the header, locked. */+export const NoCreate: Story = {+ args: { revoked: [CREATE] },+ play: async ({ canvasElement }) => {+ await expectDisabled(+ await within(canvasElement).findByTestId(+ 'channels-create',+ undefined,+ PAGE_LOAD,+ ),+ );+ },+};++/**+ * The list does not gate opening a channel: the row action reads View whether+ * or not the permission is held, as it does on dashboards, and the edit page+ * is what denies. Holding the label steady also keeps it from flipping once a+ * late check answers.+ */+export const NoReadOrUpdate: Story = {+ args: { revoked: [READ, UPDATE] },+ play: async ({ canvasElement }) => {+ await openRowMenu(canvasElement);+ await expectDisabled(await rowAction('View'), false);+ await expect(+ screen.queryByRole('menuitem', { name: 'Edit' }),+ ).not.toBeInTheDocument();+ },+};++/** Delete is locked in the row menu; View and View JSON stay open. */+export const NoDelete: Story = {+ args: { revoked: [DELETE] },+ play: async ({ canvasElement }) => {+ await openRowMenu(canvasElement);+ await expectDisabled(await rowAction('Delete'));+ await expectDisabled(await rowAction('View'), false);+ await expectDisabled(await rowAction('View JSON'), false);+ },+};++/**+ * Everything but listing: the channels are in view, New channel is locked, and+ * a row offers View and a locked Delete.+ */+export const ReadOnly: Story = {+ args: { revoked: [CREATE, UPDATE, DELETE] },+ play: async ({ canvasElement }) => {+ await expectDisabled(+ await within(canvasElement).findByTestId(+ 'channels-create',+ undefined,+ PAGE_LOAD,+ ),+ );+ await openRowMenu(canvasElement);+ await rowAction('View');+ await expectDisabled(await rowAction('Delete'));+ },+};++/** No channel permission at all, which is the tab with nothing on it to use. */+export const NoChannelAccess: Story = {+ args: { revoked: NOTIFICATION_CHANNEL },+ play: NoList.play,+};++/**+ * The table holds a skeleton until the permission check answers, so the list+ * does not flash in before a denial takes it away.+ */+export const CheckLoading: Story = {+ args: { authzState: 'loading' },+ play: async ({ canvasElement }) => {+ await new Promise((resolve) => {+ setTimeout(resolve, 1500);+ });+ await expect(+ canvasElement.querySelector('.ant-skeleton'),+ ).toBeInTheDocument();+ },+};++/**+ * The permission check failing rather than denying: the tab renders and every+ * action stays open, so the API decides.+ */+export const CheckFailed: Story = {+ args: { authzState: 'error' },+ // The mocked check intentionally fails; the resulting console error is the+ // point of the story, not a regression.+ parameters: { allowConsoleErrors: true },+ play: async ({ canvasElement }) => {+ await expectDisabled(+ await within(canvasElement).findByTestId(+ 'channels-create',+ undefined,+ PAGE_LOAD,+ ),+ false,+ );+ },+};diff --git a/frontend/src/pages/AlertList/ChannelsEdit/stories/ChannelsEdit.stories.tsx b/frontend/src/pages/AlertList/ChannelsEdit/stories/ChannelsEdit.stories.tsxindex cd174a7062..f020d9c330 100644--- a/frontend/src/pages/AlertList/ChannelsEdit/stories/ChannelsEdit.stories.tsx+++ b/frontend/src/pages/AlertList/ChannelsEdit/stories/ChannelsEdit.stories.tsx@@ -1,5 +1,5 @@import type { Meta, StoryObj } from '@storybook/react-vite';-import { expect, screen, userEvent, within } from 'storybook/test';+import { expect, screen, userEvent, waitFor, within } from 'storybook/test';import { storyMocks } from '@/storybook/controls/defineStoryMocks';import type { PageStoryArgs } from '@/storybook/runtime/resolveStory';@@ -20,7 +20,7 @@ const pageStory = storyMocks(channelsEditMocks, { layout: 'app' });*/const meta = {title: 'Pages/Alerts/Channels/Edit',- tags: ['play'],+ tags: ['authz', 'play'],component: AlertList,...pageStory,parameters: { ...pageStory.parameters },@@ -64,13 +64,21 @@ export const TestChannelFailure: Story = {// the point of the story, not a regression.parameters: { allowConsoleErrors: true },play: async ({ canvasElement }): Promise<void> => {- await userEvent.click(- await within(canvasElement).findByTestId(- 'test-channel-button',- undefined,- untilLoaded,- ),+ const test = await within(canvasElement).findByTestId(+ 'test-channel-button',+ undefined,+ untilLoaded,);++ // the button is disabled while its permission check is in flight, so a+ // click any earlier lands on nothing. It signals that through+ // aria-disabled, which toBeEnabled does not read.+ await waitFor(+ () => expect(test).toHaveAttribute('aria-disabled', 'false'),+ untilLoaded,+ );+ await userEvent.click(test);+await screen.findByText('Storybook forced channel failure');},};diff --git a/frontend/src/pages/AlertList/ChannelsEdit/stories/authz/ChannelsEdit.authz.stories.tsx b/frontend/src/pages/AlertList/ChannelsEdit/stories/authz/ChannelsEdit.authz.stories.tsxnew file mode 100644index 0000000000..8df2fe35fb--- /dev/null+++ b/frontend/src/pages/AlertList/ChannelsEdit/stories/authz/ChannelsEdit.authz.stories.tsx@@ -0,0 +1,146 @@+import type { Meta, StoryObj } from '@storybook/react-vite';+import { expect, within } from 'storybook/test';++import { storyMocks } from '@/storybook/controls/defineStoryMocks';+import type { PageStoryArgs } from '@/storybook/runtime/resolveStory';++import {+ CREATE,+ DELETE,+ expectDisabled,+ NOTIFICATION_CHANNEL,+ PAGE_LOAD,+ READ,+ UPDATE,+} from '../../../stories/channelAuthz';+import { channelsEditMocks } from '../ChannelsEdit.stories.mocks';++import AlertList from '../../../index';++type ChannelsEditArgs = PageStoryArgs<typeof channelsEditMocks>;++const pageStory = storyMocks(channelsEditMocks, { layout: 'app' });++/**+ * One channel's settings with one permission missing at a time. Every story+ * here is an admin denied exactly what its name says. The page mounts on `read`+ * alone, `update` decides whether it is editable, and a test send is gated on+ * `create` against the collection, not on the channel.+ *+ * Route: `/alerts/channels/edit/:id`.+ */+const meta = {+ title: 'Pages/Alerts/Channels/Edit Authz',+ tags: ['authz', 'play'],+ component: AlertList,+ ...pageStory,+ parameters: { ...pageStory.parameters },+} satisfies Meta<ChannelsEditArgs>;++export default meta;++type Story = StoryObj<ChannelsEditArgs>;++const DENIED_PAGE = 'Uh-oh! You are not authorized';++/** The page refuses to render, and the denial names the channel's `read`. */+export const NoRead: Story = {+ args: { revoked: [READ] },+ play: async ({ canvasElement }) => {+ await within(canvasElement).findByText(DENIED_PAGE, undefined, PAGE_LOAD);+ await expect(+ within(canvasElement).queryByTestId('save-channel-button'),+ ).not.toBeInTheDocument();+ },+};++/**+ * Reading is enough to open the page, so losing `update` alone leaves it+ * standing read-only: the fields go disabled and Save is locked, not hidden.+ */+export const NoUpdate: Story = {+ args: { revoked: [UPDATE] },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await expectDisabled(+ await canvas.findByTestId('save-channel-button', undefined, PAGE_LOAD),+ );+ await expectDisabled(await canvas.findByTestId('slack-channel-textbox'));+ },+};++/**+ * A test send is a create on the collection, so the Test button is locked+ * while saving the channel still works.+ */+export const NoCreate: Story = {+ args: { revoked: [CREATE] },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await expectDisabled(+ await canvas.findByTestId('test-channel-button', undefined, PAGE_LOAD),+ );+ await expectDisabled(+ await canvas.findByTestId('save-channel-button', undefined, PAGE_LOAD),+ false,+ );+ },+};++/**+ * The viewer: `read` and nothing else. The page opens, every field is off, and+ * both Save and Test are locked rather than hidden.+ */+export const ReadOnly: Story = {+ args: { revoked: [UPDATE, CREATE, DELETE] },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await expectDisabled(+ await canvas.findByTestId('save-channel-button', undefined, PAGE_LOAD),+ );+ await expectDisabled(await canvas.findByTestId('test-channel-button'));+ await expectDisabled(await canvas.findByTestId('slack-channel-textbox'));+ },+};++/** No channel permission at all: the page is denied before the form exists. */+export const NoChannelAccess: Story = {+ args: { revoked: NOTIFICATION_CHANNEL },+ play: NoRead.play,+};++/** The page holds on its loader until the permission check answers. */+export const CheckLoading: Story = {+ args: { authzState: 'loading' },+ play: async ({ canvasElement }) => {+ await new Promise((resolve) => {+ setTimeout(resolve, 1500);+ });+ await expect(+ within(canvasElement).queryByTestId('save-channel-button'),+ ).not.toBeInTheDocument();+ },+};++/**+ * The permission check failing rather than denying: the form renders editable+ * and the API decides on save.+ */+export const CheckFailed: Story = {+ args: { authzState: 'error' },+ // The mocked check intentionally fails; the resulting console error is the+ // point of the story, not a regression.+ parameters: { allowConsoleErrors: true },+ play: async ({ canvasElement }) => {+ const save = await within(canvasElement).findByTestId(+ 'save-channel-button',+ undefined,+ PAGE_LOAD,+ );++ await expectDisabled(save, false);+ },+};diff --git a/frontend/src/pages/AlertList/ChannelsNew/stories/ChannelsNew.stories.tsx b/frontend/src/pages/AlertList/ChannelsNew/stories/ChannelsNew.stories.tsxindex 280f1fe3d5..3668c1dd1d 100644--- a/frontend/src/pages/AlertList/ChannelsNew/stories/ChannelsNew.stories.tsx+++ b/frontend/src/pages/AlertList/ChannelsNew/stories/ChannelsNew.stories.tsx@@ -19,7 +19,7 @@ const pageStory = storyMocks(channelsNewMocks, { layout: 'app' });*/const meta = {title: 'Pages/Alerts/Channels/New',- tags: ['play'],+ tags: ['authz', 'play'],component: AlertList,...pageStory,parameters: { ...pageStory.parameters },diff --git a/frontend/src/pages/AlertList/ChannelsNew/stories/authz/ChannelsNew.authz.stories.tsx b/frontend/src/pages/AlertList/ChannelsNew/stories/authz/ChannelsNew.authz.stories.tsxnew file mode 100644index 0000000000..8f71d42568--- /dev/null+++ b/frontend/src/pages/AlertList/ChannelsNew/stories/authz/ChannelsNew.authz.stories.tsx@@ -0,0 +1,92 @@+import type { Meta, StoryObj } from '@storybook/react-vite';+import { expect, within } from 'storybook/test';++import { storyMocks } from '@/storybook/controls/defineStoryMocks';+import type { PageStoryArgs } from '@/storybook/runtime/resolveStory';++import {+ CREATE,+ expectDisabled,+ NOTIFICATION_CHANNEL,+ PAGE_LOAD,+} from '../../../stories/channelAuthz';+import { channelsNewMocks } from '../ChannelsNew.stories.mocks';++import AlertList from '../../../index';++type ChannelsNewArgs = PageStoryArgs<typeof channelsNewMocks>;++const pageStory = storyMocks(channelsNewMocks, { layout: 'app' });++/**+ * The new channel form without `create`. Creating a channel and testing one+ * are the same permission, on the collection, so there is no state between+ * the form and the denial.+ *+ * Route: `/alerts/channels/new`.+ */+const meta = {+ title: 'Pages/Alerts/Channels/New Authz',+ tags: ['authz', 'play'],+ component: AlertList,+ ...pageStory,+ parameters: { ...pageStory.parameters },+} satisfies Meta<ChannelsNewArgs>;++export default meta;++type Story = StoryObj<ChannelsNewArgs>;++/** The page refuses to render, and the denial names `create`. */+export const NoCreate: Story = {+ args: { revoked: [CREATE] },+ play: async ({ canvasElement }) => {+ await within(canvasElement).findByText(+ 'Uh-oh! You are not authorized',+ undefined,+ PAGE_LOAD,+ );+ await expect(+ within(canvasElement).queryByTestId('save-channel-button'),+ ).not.toBeInTheDocument();+ },+};++/** No channel permission at all, which denies on the same `create` check. */+export const NoChannelAccess: Story = {+ args: { revoked: NOTIFICATION_CHANNEL },+ play: NoCreate.play,+};++/** The page holds on its loader until the permission check answers. */+export const CheckLoading: Story = {+ args: { authzState: 'loading' },+ play: async ({ canvasElement }) => {+ await new Promise((resolve) => {+ setTimeout(resolve, 1500);+ });+ await expect(+ within(canvasElement).queryByTestId('save-channel-button'),+ ).not.toBeInTheDocument();+ },+};++/**+ * The permission check failing rather than denying: the form renders and the+ * API decides on save.+ */+export const CheckFailed: Story = {+ args: { authzState: 'error' },+ // The mocked check intentionally fails; the resulting console error is the+ // point of the story, not a regression.+ parameters: { allowConsoleErrors: true },+ play: async ({ canvasElement }) => {+ const save = await within(canvasElement).findByTestId(+ 'save-channel-button',+ undefined,+ PAGE_LOAD,+ );++ await expectDisabled(save, false);+ },+};diff --git a/frontend/src/pages/AlertList/NotificationChannels/NotificationChannels.module.scss b/frontend/src/pages/AlertList/NotificationChannels/NotificationChannels.module.scssindex a6e1e3278e..9fa0bfccc8 100644--- a/frontend/src/pages/AlertList/NotificationChannels/NotificationChannels.module.scss+++ b/frontend/src/pages/AlertList/NotificationChannels/NotificationChannels.module.scss@@ -135,6 +135,10 @@);}+.guardInset {+ margin-inline: var(--spacing-8);+}+.paginationContainer {padding-right: var(--spacing-12);height: 62px;diff --git a/frontend/src/pages/AlertList/NotificationChannels/NotificationChannels.tsx b/frontend/src/pages/AlertList/NotificationChannels/NotificationChannels.tsxindex 6fdd96466c..a7a08cb7bd 100644--- a/frontend/src/pages/AlertList/NotificationChannels/NotificationChannels.tsx+++ b/frontend/src/pages/AlertList/NotificationChannels/NotificationChannels.tsx@@ -1,9 +1,9 @@import { useCallback, useEffect, useMemo, useState } from 'react';import { Plus, Search } from '@signozhq/icons';-import { Button } from '@signozhq/ui/button';import { Input } from '@signozhq/ui/input';import { SelectSimple } from '@signozhq/ui/select';import { Typography } from '@signozhq/ui/typography';+import { Skeleton } from 'antd';import logEvent from 'api/common/logEvent';import ErrorEmptyState from 'components/Alerts/ErrorEmptyState';import NoResultsEmptyState from 'components/Alerts/NoResultsEmptyState';@@ -12,6 +12,14 @@ import { useCalculatedPageSize } from 'components/TanStackTableView/useCalculateimport { useTableParams } from 'components/TanStackTableView/useTableParams';import TextToolTip from 'components/TextToolTip';import { useUrlSearchState } from 'hooks/useUrlSearchState';+import AuthZButton from 'lib/authz/components/AuthZButton/AuthZButton';+import { useNotificationChannelCollectionPermissions } from 'hooks/notificationChannels/useNotificationChannelCollectionPermissions';+import { AuthZGuardContent } from 'lib/authz/components/AuthZGuard/AuthZGuardContent';+import PermissionDeniedCallout from 'lib/authz/components/PermissionDeniedCallout/PermissionDeniedCallout';+import {+ NotificationChannelCreatePermission,+ NotificationChannelListPermission,+} from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';import { parseAsString, useQueryState } from 'nuqs';import { useTimezone } from 'providers/Timezone';@@ -36,6 +44,8 @@ const QUERY_PARAMS_CONFIG = {limit: 'limit',} as const;+const CREATE_CHECKS = [NotificationChannelCreatePermission];+const LIST_CHECKS = [NotificationChannelListPermission];const DEFAULT_PAGE = 1;const DEFAULT_LIMIT = 10;@@ -79,6 +89,7 @@ function NotificationChannels(): JSX.Element {[setKind, setPage],);+ const { canList } = useNotificationChannelCollectionPermissions();const { channels, total, isFetching, isError, refetch } = useChannelsData({search: debouncedSearch,kind,@@ -168,7 +179,8 @@ function NotificationChannels(): JSX.Element {url="https://signoz.io/docs/setup-alerts-notification/"urlText="Learn More"/>- <Button+ <AuthZButton+ checks={CREATE_CHECKS}variant="solid"color="primary"size="md"@@ -177,7 +189,7 @@ function NotificationChannels(): JSX.Element {testId="channels-create">New channel- </Button>+ </AuthZButton></div><div className={styles.filtersRow}>@@ -186,6 +198,7 @@ function NotificationChannels(): JSX.Element {placeholder="Search by channel name"value={searchText}onChange={handleSearchChange}+ disabled={!canList}suffix={<Search size={14} className={styles.searchIcon} />}testId="channels-search"/>@@ -194,6 +207,7 @@ function NotificationChannels(): JSX.Element {items={KIND_FILTER_OPTIONS}value={kind}onChange={handleKindChange}+ disabled={!canList}withPortal={false}testId="channels-kind-filter"/>@@ -201,40 +215,59 @@ function NotificationChannels(): JSX.Element {</header><div ref={containerRef} className={styles.tableContainer}>- {isError ? (- <ErrorEmptyState- title="Failed to load notification channels"- onRefresh={refetch}- />- ) : isEmpty && hasActiveFilters ? (- <NoResultsEmptyState- title="No matching channels"- subtitle="No notification channels match your search. Try adjusting your search criteria."- onClear={handleClearFilters}- clearButtonText="Clear Search"- />- ) : (- <TanStackTable<Channel>- data={channels}- columns={columnsWithActions}- isLoading={isFetching}- getRowKey={(row): string => row.id}- getItemKey={(row): string => row.id}- columnStorageKey="notification-channels-columns"- enableQueryParams={QUERY_PARAMS_CONFIG}- onRowClick={handleRowClick}- onRowClickNewTab={handleRowClickNewTab}- pagination={{- total,- calculatedPageSize,- onLimitChange: setLimit,- showTotalCount: true,- }}- paginationClassname={styles.paginationContainer}- enableAlternatingRowColors- plainTextCellLineClamp={1}- />- )}+ {/* Fails closed, unlike the guard's default: the fetch is gated on the+ same check, so falling open would render an empty table shell with+ no reason given. The header and filters stay, as on dashboards. */}+ <AuthZGuardContent+ checks={LIST_CHECKS}+ onFailRenderContent={false}+ fallback={({ deniedPermissions }): JSX.Element => (+ <PermissionDeniedCallout+ deniedPermissions={deniedPermissions}+ className={styles.guardInset}+ />+ )}+ fallbackOnLoading={+ <div className={styles.guardInset}>+ <Skeleton active paragraph={{ rows: 6 }} />+ </div>+ }+ >+ {isError ? (+ <ErrorEmptyState+ title="Failed to load notification channels"+ onRefresh={refetch}+ />+ ) : isEmpty && hasActiveFilters ? (+ <NoResultsEmptyState+ title="No matching channels"+ subtitle="No notification channels match your search. Try adjusting your search criteria."+ onClear={handleClearFilters}+ clearButtonText="Clear Search"+ />+ ) : (+ <TanStackTable<Channel>+ data={channels}+ columns={columnsWithActions}+ isLoading={isFetching}+ getRowKey={(row): string => row.id}+ getItemKey={(row): string => row.id}+ columnStorageKey="notification-channels-columns"+ enableQueryParams={QUERY_PARAMS_CONFIG}+ onRowClick={handleRowClick}+ onRowClickNewTab={handleRowClickNewTab}+ pagination={{+ total,+ calculatedPageSize,+ onLimitChange: setLimit,+ showTotalCount: true,+ }}+ paginationClassname={styles.paginationContainer}+ enableAlternatingRowColors+ plainTextCellLineClamp={1}+ />+ )}+ </AuthZGuardContent></div>{jsonChannel && (diff --git a/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelForm.test.tsx b/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelForm.test.tsxindex 102b160fd1..200cdf26f1 100644--- a/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelForm.test.tsx+++ b/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelForm.test.tsx@@ -1,3 +1,4 @@+import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';import { server } from 'mocks-server/server';import { render, screen } from 'tests/test-utils';@@ -8,6 +9,7 @@ const FIND = { timeout: 5000 };describe('ChannelForm', () => {beforeEach(() => {window.history.replaceState({}, '', '/');+ server.use(setupAuthzAdmin());});afterEach(() => {diff --git a/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelFormPrefill.test.tsx b/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelFormPrefill.test.tsxindex 64581a0cf7..3628b4f74b 100644--- a/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelFormPrefill.test.tsx+++ b/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelFormPrefill.test.tsx@@ -1,3 +1,4 @@+import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';import { server } from 'mocks-server/server';import { rest } from 'msw';import { render, screen } from 'tests/test-utils';@@ -190,6 +191,7 @@ const CASES: PrefillCase[] = [describe('ChannelForm prefill', () => {beforeEach(() => {window.history.replaceState({}, '', '/');+ server.use(setupAuthzAdmin());});afterEach(() => {diff --git a/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelFormSave.test.tsx b/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelFormSave.test.tsxindex 030e988219..67b17c8350 100644--- a/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelFormSave.test.tsx+++ b/frontend/src/pages/AlertList/NotificationChannels/__tests__/ChannelFormSave.test.tsx@@ -1,3 +1,8 @@+import {+ AUTHZ_CHECK_URL,+ setupAuthzAdmin,+ setupAuthzGrantByPrefix,+} from 'lib/authz/utils/authz-test-utils';import { server } from 'mocks-server/server';import { rest } from 'msw';import { render, screen, userEvent, waitFor } from 'tests/test-utils';@@ -10,6 +15,7 @@ const TEST_TIMEOUT = 20000;describe('ChannelForm save', () => {beforeEach(() => {window.history.replaceState({}, '', '/');+ server.use(setupAuthzAdmin());});afterEach(() => {@@ -43,7 +49,12 @@ describe('ChannelForm save', () => {screen.getByTestId('webhook-url-textbox'),'https://hooks.slack.com/services/T/B/X',);- await user.click(screen.getByTestId('save-channel-button'));+ const save = screen.getByTestId('save-channel-button');+ await waitFor(+ () => expect(save).toHaveAttribute('aria-disabled', 'false'),+ FIND,+ );+ await user.click(save);await waitFor(() => expect(onDone).toHaveBeenCalled(), FIND);@@ -88,7 +99,12 @@ describe('ChannelForm save', () => {const user = userEvent.setup({ delay: null, pointerEventsCheck: 0 });await user.clear(screen.getByTestId('slack-channel-textbox'));await user.type(screen.getByTestId('slack-channel-textbox'), '#changed');- await user.click(screen.getByTestId('save-channel-button'));+ const save = screen.getByTestId('save-channel-button');+ await waitFor(+ () => expect(save).toHaveAttribute('aria-disabled', 'false'),+ FIND,+ );+ await user.click(save);await waitFor(() => expect(onDone).toHaveBeenCalled(), FIND);@@ -103,6 +119,65 @@ describe('ChannelForm save', () => {TEST_TIMEOUT,);+ it(+ 'opens read-only, with saving disabled rather than hidden, when update is denied',+ async () => {+ server.use(setupAuthzGrantByPrefix('read', 'list'));++ render(<ChannelForm channelId="3" onDone={jest.fn()} />);++ await screen.findByTestId('channel-name-textbox', {}, FIND);++ // the whole form goes disabled once the denial lands+ await waitFor(+ () => expect(screen.getByTestId('slack-channel-textbox')).toBeDisabled(),+ FIND,+ );++ const save = screen.getByTestId('save-channel-button');+ await waitFor(+ () => expect(save).toHaveAttribute('aria-disabled', 'true'),+ FIND,+ );+ expect(save).toHaveAttribute(+ 'data-denied-permissions',+ expect.stringContaining('update'),+ );+ expect(screen.getByTestId('test-channel-button')).toHaveAttribute(+ 'aria-disabled',+ 'true',+ );+ },+ TEST_TIMEOUT,+ );++ it(+ 'stays editable when the permission check itself fails',+ async () => {+ // a failed check is an outage, not a denial: locking the form on one+ // would read as "no permission" every time the batch misses+ server.use(+ rest.post(AUTHZ_CHECK_URL, (_, res, ctx) => res(ctx.status(500))),+ );++ render(<ChannelForm channelId="3" onDone={jest.fn()} />);++ // Save is disabled while the checks are in flight and settles once they+ // resolve, so waiting on it means the failure has landed+ const save = await screen.findByTestId('save-channel-button', {}, FIND);+ await waitFor(+ () => expect(save).toHaveAttribute('aria-disabled', 'false'),+ FIND,+ );++ expect(screen.getByTestId('slack-channel-textbox')).toBeEnabled();+ expect(+ screen.queryByTestId('channel-read-only-notice'),+ ).not.toBeInTheDocument();+ },+ TEST_TIMEOUT,+ );+it('explains a channel the v2 API cannot model instead of showing a blank form',async () => {diff --git a/frontend/src/pages/AlertList/NotificationChannels/__tests__/NotificationChannels.authz.test.tsx b/frontend/src/pages/AlertList/NotificationChannels/__tests__/NotificationChannels.authz.test.tsxnew file mode 100644index 0000000000..a0d1475fb6--- /dev/null+++ b/frontend/src/pages/AlertList/NotificationChannels/__tests__/NotificationChannels.authz.test.tsx@@ -0,0 +1,104 @@+import { NotificationChannelCreatePermission } from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';+import {+ setupAuthzAdmin,+ setupAuthzDeny,+ setupAuthzDenyAll,+ setupAuthzGrantByPrefix,+} from 'lib/authz/utils/authz-test-utils';+import { server } from 'mocks-server/server';+import { screen, userEvent, waitFor } from 'tests/test-utils';++import { renderChannels } from './renderChannels';++const FIND = { timeout: 5000 };+const TEST_TIMEOUT = 20000;++describe('Notification channels list - AuthZ', () => {+ beforeEach(() => {+ window.history.replaceState({}, '', '/');+ });++ afterEach(() => {+ jest.restoreAllMocks();+ server.resetHandlers();+ });++ it(+ 'replaces only the table when list is denied, keeping the header',+ async () => {+ server.use(setupAuthzDenyAll());++ renderChannels();++ await expect(+ screen.findByText(/not authorized/i, {}, FIND),+ ).resolves.toBeInTheDocument();+ // the page still loads: the search and the kind filter stay, inert,+ // the way the dashboards list keeps its filter zone+ expect(screen.getByTestId('channels-search')).toBeDisabled();+ expect(screen.getByTestId('channels-create')).toBeInTheDocument();+ },+ TEST_TIMEOUT,+ );++ it(+ 'disables creating when create is denied',+ async () => {+ server.use(setupAuthzDeny(NotificationChannelCreatePermission));++ renderChannels();++ await screen.findByText('Dummy-Channel', {}, FIND);+ await waitFor(+ () =>+ expect(screen.getByTestId('channels-create')).toHaveAttribute(+ 'aria-disabled',+ 'true',+ ),+ FIND,+ );+ },+ TEST_TIMEOUT,+ );++ it(+ 'opens the channel as a view, whatever the update permission says',+ async () => {+ server.use(setupAuthzAdmin());++ renderChannels();++ await screen.findByText('Dummy-Channel', {}, FIND);+ const user = userEvent.setup({ delay: null });+ await user.click(screen.getByTestId('channel-actions-3'));++ // the label never flips between Edit and View, so it cannot flash the+ // wrong one while the check is in flight+ await expect(+ screen.findByRole('menuitem', { name: 'View' }, FIND),+ ).resolves.toBeInTheDocument();+ },+ TEST_TIMEOUT,+ );++ it(+ 'offers View instead when the channel can only be read',+ async () => {+ server.use(setupAuthzGrantByPrefix('read', 'list'));++ renderChannels();++ await screen.findByText('Dummy-Channel', {}, FIND);+ const user = userEvent.setup({ delay: null });+ await user.click(screen.getByTestId('channel-actions-3'));++ await expect(+ screen.findByRole('menuitem', { name: 'View' }, FIND),+ ).resolves.toBeInTheDocument();+ expect(+ screen.queryByRole('menuitem', { name: 'Edit' }),+ ).not.toBeInTheDocument();+ },+ TEST_TIMEOUT,+ );+});diff --git a/frontend/src/pages/AlertList/NotificationChannels/__tests__/NotificationChannels.test.tsx b/frontend/src/pages/AlertList/NotificationChannels/__tests__/NotificationChannels.test.tsxindex 6fa0949757..5f7b7c7fb7 100644--- a/frontend/src/pages/AlertList/NotificationChannels/__tests__/NotificationChannels.test.tsx+++ b/frontend/src/pages/AlertList/NotificationChannels/__tests__/NotificationChannels.test.tsx@@ -1,3 +1,4 @@+import { setupAuthzAdmin } from 'lib/authz/utils/authz-test-utils';import { server } from 'mocks-server/server';import { screen, userEvent, waitFor } from 'tests/test-utils';@@ -11,6 +12,7 @@ describe('Notification channels list', () => {// search, filter and page live in the url, so one test's filter would// otherwise still be applied in the nextwindow.history.replaceState({}, '', '/');+ server.use(setupAuthzAdmin());});afterEach(() => {@@ -82,9 +84,17 @@ describe('Notification channels list', () => {// also fire the row click and route to the edit screenexpect(window.location.pathname).not.toContain('/channels/edit/');- await user.click(- await screen.findByRole('menuitem', { name: 'Delete' }, FIND),+ // Delete stays disabled until the per-channel permission check resolves+ const deleteItem = await screen.findByRole(+ 'menuitem',+ { name: 'Delete' },+ FIND,);+ await waitFor(+ () => expect(deleteItem).not.toHaveAttribute('aria-disabled', 'true'),+ FIND,+ );+ await user.click(deleteItem);// the shared destructive confirmation, the one dashboards also use. The// name sits in its own element, so the sentence spans several nodes.diff --git a/frontend/src/pages/AlertList/NotificationChannels/components/ChannelActionsMenu/ChannelActionsMenu.authz.test.tsx b/frontend/src/pages/AlertList/NotificationChannels/components/ChannelActionsMenu/ChannelActionsMenu.authz.test.tsxnew file mode 100644index 0000000000..ca32b247f9--- /dev/null+++ b/frontend/src/pages/AlertList/NotificationChannels/components/ChannelActionsMenu/ChannelActionsMenu.authz.test.tsx@@ -0,0 +1,104 @@+import { AlertmanagertypesListedNotificationChannelDTO } from 'api/generated/services/sigNoz.schemas';+import { buildNotificationChannelDeletePermission } from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';+import {+ AUTHZ_CHECK_URL,+ setupAuthzDeny,+} from 'lib/authz/utils/authz-test-utils';+import { server } from 'mocks-server/server';+import { rest } from 'msw';+import { render, screen, userEvent, waitFor } from 'tests/test-utils';++import ChannelActionsMenu from './ChannelActionsMenu';++const FIND = { timeout: 5000 };+const BATCH_SETTLE_MS = 250;++const CHANNEL = {+ id: '3',+ name: 'ops-slack',+ displayName: 'ops slack',+ kind: 'slack',+ createdAt: '2026-01-01T00:00:00Z',+ updatedAt: '2026-01-01T00:00:00Z',+} as AlertmanagertypesListedNotificationChannelDTO;++/** Selectors every authz check asked about, in the order they were requested. */+function recordSelectors(): string[] {+ const selectors: string[] = [];+ server.use(+ rest.post(AUTHZ_CHECK_URL, async (req, res, ctx) => {+ const body = (await req.json()) as { object: { selector: string } }[];+ selectors.push(...body.map((check) => check.object.selector));+ return res(+ ctx.status(200),+ ctx.json({+ status: 'success',+ data: body.map((check) => ({ ...check, authorized: true })),+ }),+ );+ }),+ );+ return selectors;+}++describe('ChannelActionsMenu - AuthZ', () => {+ afterEach(() => {+ jest.restoreAllMocks();+ server.resetHandlers();+ });++ it('disables deleting when delete is denied', async () => {+ server.use(setupAuthzDeny(buildNotificationChannelDeletePermission('3')));++ render(+ <ChannelActionsMenu+ channel={CHANNEL}+ onOpen={jest.fn()}+ onDelete={jest.fn()}+ onViewJson={jest.fn()}+ />,+ );++ const user = userEvent.setup({ delay: null });+ await user.click(await screen.findByTestId('channel-actions-3', {}, FIND));++ const deleteRow = await screen.findByText('Delete', {}, FIND);+ // a row still waiting on its check reads as loading, not denied+ await waitFor(+ () => expect(document.querySelector('[data-loading]')).toBeNull(),+ FIND,+ );+ await waitFor(+ () => expect(deleteRow.closest('[data-disabled]')).not.toBeNull(),+ FIND,+ );+ });++ it('checks the channel only once its menu is opened', async () => {+ // the authz API caps one batch at 25 transactions, so a list that checked+ // three verbs for every row would start failing at eight channels+ const selectors = recordSelectors();++ render(+ <ChannelActionsMenu+ channel={CHANNEL}+ onOpen={jest.fn()}+ onDelete={jest.fn()}+ onViewJson={jest.fn()}+ />,+ );++ const trigger = await screen.findByTestId('channel-actions-3', {}, FIND);++ // useAuthZ coalesces checks over a 50ms window, so proving none were sent+ // means outlasting it+ await new Promise((resolve) => {+ setTimeout(resolve, BATCH_SETTLE_MS);+ });+ expect(selectors).toHaveLength(0);++ await userEvent.setup({ delay: null }).click(trigger);++ await waitFor(() => expect(selectors).toContain('3'), FIND);+ });+});diff --git a/frontend/src/pages/AlertList/NotificationChannels/components/ChannelActionsMenu/ChannelActionsMenu.tsx b/frontend/src/pages/AlertList/NotificationChannels/components/ChannelActionsMenu/ChannelActionsMenu.tsxindex 054e1b3de0..e877812f56 100644--- a/frontend/src/pages/AlertList/NotificationChannels/components/ChannelActionsMenu/ChannelActionsMenu.tsx+++ b/frontend/src/pages/AlertList/NotificationChannels/components/ChannelActionsMenu/ChannelActionsMenu.tsx@@ -1,4 +1,4 @@-import { useMemo } from 'react';+import { useCallback, useMemo, useState } from 'react';import { generatePath } from 'react-router-dom';import { useCopyToClipboard } from 'react-use';import {@@ -10,9 +10,11 @@ import {Trash2,} from '@signozhq/icons';import { Button } from '@signozhq/ui/button';-import { Dropdown, type DropdownItemType } from '@signozhq/ui/dropdown';import { toast } from '@signozhq/ui/sonner';import ROUTES from 'constants/routes';+import { useNotificationChannelPermissions } from 'hooks/notificationChannels/useNotificationChannelPermissions';+import AuthZDropdown from 'lib/authz/components/AuthZDropdown/AuthZDropdown';+import type { AuthZDropdownItemType } from 'lib/authz/components/AuthZDropdown/types';import { getAbsoluteUrl } from 'utils/basePath';import type { Channel } from '../../types';@@ -33,7 +35,14 @@ function ChannelActionsMenu({}: ChannelActionsMenuProps): JSX.Element {const [, setCopy] = useCopyToClipboard();- const menuItems = useMemo<DropdownItemType[]>(+ // A list of N channels would otherwise check its verbs per row on mount, for+ // menus nobody opened, and the authz API caps one batch at 25 transactions.+ const [hasOpened, setHasOpened] = useState(false);+ const { deletePermission } = useNotificationChannelPermissions(channel.id, {+ enabled: hasOpened,+ });++ const menuItems = useMemo<AuthZDropdownItemType[]>(() => [{type: 'item',@@ -76,13 +85,20 @@ function ChannelActionsMenu({value: 'delete',label: 'Delete',prefix: <Trash2 size={14} />,+ checks: [deletePermission],danger: true,onClick: (): void => onDelete(channel),},],- [channel, onOpen, onDelete, onViewJson, setCopy],+ [deletePermission, channel, onOpen, onDelete, onViewJson, setCopy],);+ const handleOpenChange = useCallback((open: boolean): void => {+ if (open) {+ setHasOpened(true);+ }+ }, []);+return (// the row itself opens the channel, so the actions keep their clicks// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions@@ -90,7 +106,13 @@ function ChannelActionsMenu({className={styles.actions}onClick={(event): void => event.stopPropagation()}>- <Dropdown items={menuItems} nativeButton align="end" side="bottom">+ <AuthZDropdown+ items={menuItems}+ nativeButton+ align="end"+ side="bottom"+ onOpenChange={handleOpenChange}+ ><Buttonvariant="outlined"color="secondary"@@ -101,7 +123,7 @@ function ChannelActionsMenu({><Ellipsis size={16} /></Button>- </Dropdown>+ </AuthZDropdown></div>);}diff --git a/frontend/src/pages/AlertList/NotificationChannels/components/ChannelForm/ChannelForm.tsx b/frontend/src/pages/AlertList/NotificationChannels/components/ChannelForm/ChannelForm.tsxindex 7a448d7933..8c7024ac17 100644--- a/frontend/src/pages/AlertList/NotificationChannels/components/ChannelForm/ChannelForm.tsx+++ b/frontend/src/pages/AlertList/NotificationChannels/components/ChannelForm/ChannelForm.tsx@@ -1,6 +1,8 @@import { useTranslation } from 'react-i18next';import { Callout } from '@signozhq/ui/callout';import Spinner from 'components/Spinner';+import { useNotificationChannelPermissions } from 'hooks/notificationChannels/useNotificationChannelPermissions';+import { NotificationChannelCreatePermission } from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';import ChannelFormBody from './ChannelFormBody';import styles from './ChannelForm.module.scss';@@ -15,6 +17,22 @@ function ChannelForm({ channelId, onDone }: ChannelFormProps): JSX.Element {const { t } = useTranslation('channels');const { draft, isLoading, loadError } = useChannelDraft(channelId);+ const {+ canEdit,+ isLoading: isPermissionLoading,+ hasError: permissionCheckFailed,+ editChecks,+ } = useNotificationChannelPermissions(channelId ?? '', {+ enabled: !!channelId,+ });+ const readOnly =+ !!channelId && !isPermissionLoading && !permissionCheckFailed && !canEdit;+ // Saving an existing channel needs read and update on it; creating one needs+ // create on the collection, which is also what a test send is gated on.+ const saveChecks = channelId+ ? editChecks+ : [NotificationChannelCreatePermission];+if (loadError) {return (<Callout@@ -38,6 +56,9 @@ function ChannelForm({ channelId, onDone }: ChannelFormProps): JSX.Element {draft={draft}target={channelId ? { mode: 'edit', channelId } : { mode: 'create' }}onDone={onDone}+ readOnly={readOnly}+ saveChecks={saveChecks}+ testChecks={[NotificationChannelCreatePermission]}/>);}diff --git a/frontend/src/pages/AlertList/NotificationChannels/components/ChannelForm/ChannelFormBody.tsx b/frontend/src/pages/AlertList/NotificationChannels/components/ChannelForm/ChannelFormBody.tsxindex 1a250f8559..ede440aa77 100644--- a/frontend/src/pages/AlertList/NotificationChannels/components/ChannelForm/ChannelFormBody.tsx+++ b/frontend/src/pages/AlertList/NotificationChannels/components/ChannelForm/ChannelFormBody.tsx@@ -1,5 +1,6 @@import FormAlertChannels from 'container/FormAlertChannels';import { ChannelFormState } from 'container/CreateAlertChannels/channelFormValues';+import type { BrandedPermission } from 'lib/authz/hooks/useAuthZ/types';import { ChannelFormTarget, useChannelFormState } from './useChannelFormState';@@ -7,12 +8,21 @@ interface ChannelFormBodyProps {draft: ChannelFormState;target: ChannelFormTarget;onDone: () => void;+ /** The reader has `read` but not `update`, so the fields render disabled. */+ readOnly: boolean;+ /** Gates saving; a denial disables the button and names the missing scope. */+ saveChecks: BrandedPermission[];+ /** Gates a test send, which the API allows with `create`. */+ testChecks: BrandedPermission[];}function ChannelFormBody({draft,target,onDone,+ readOnly,+ saveChecks,+ testChecks,}: ChannelFormBodyProps): JSX.Element {const { form, type, onTypeChange, onSave, onTest, isSaving, isTesting } =useChannelFormState({ draft, target, onDone });@@ -27,6 +37,9 @@ function ChannelFormBody({savingState={isSaving}testingState={isTesting}editing={target.mode === 'edit'}+ readOnly={readOnly}+ saveChecks={saveChecks}+ testChecks={testChecks}/>);}diff --git a/frontend/src/pages/AlertList/stories/channelAuthz.ts b/frontend/src/pages/AlertList/stories/channelAuthz.tsnew file mode 100644index 0000000000..dd6e442cdb--- /dev/null+++ b/frontend/src/pages/AlertList/stories/channelAuthz.ts@@ -0,0 +1,30 @@+import { expect, waitFor } from 'storybook/test';++export const LIST = 'list:notification-channel';+export const CREATE = 'create:notification-channel';+export const READ = 'read:notification-channel';+export const UPDATE = 'update:notification-channel';+export const DELETE = 'delete:notification-channel';++export const NOTIFICATION_CHANNEL = [LIST, CREATE, READ, UPDATE, DELETE];++/** The page loads its data and its permission check before anything settles. */+export const PAGE_LOAD = { timeout: 15_000 };++/**+ * A locked control can say so as `disabled`, `aria-disabled` or, on a dropdown+ * row, `data-disabled`. A field inside a disabled fieldset carries none of+ * them: the browser turns it off without touching its attributes.+ */+const isDisabled = (element: HTMLElement): boolean =>+ element.hasAttribute('disabled') ||+ element.getAttribute('aria-disabled') === 'true' ||+ element.hasAttribute('data-disabled') ||+ element.closest('[data-disabled]') !== null ||+ element.closest('fieldset[disabled]') !== null;++export const expectDisabled = (+ element: HTMLElement,+ disabled = true,+): Promise<void> =>+ waitFor(() => expect(isDisabled(element)).toBe(disabled), PAGE_LOAD);diff --git a/frontend/src/pages/ChannelsEdit/ChannelsEdit.module.scss b/frontend/src/pages/ChannelsEdit/ChannelsEdit.module.scssindex 78ac1ffaef..4c1d040b2b 100644--- a/frontend/src/pages/ChannelsEdit/ChannelsEdit.module.scss+++ b/frontend/src/pages/ChannelsEdit/ChannelsEdit.module.scss@@ -1,3 +1,7 @@+.loading {+ padding: var(--spacing-6);+}+.content {padding: 0 var(--spacing-6) var(--spacing-6);}diff --git a/frontend/src/pages/ChannelsEdit/index.tsx b/frontend/src/pages/ChannelsEdit/index.tsxindex e165dae64b..c7978cbce8 100644--- a/frontend/src/pages/ChannelsEdit/index.tsx+++ b/frontend/src/pages/ChannelsEdit/index.tsx@@ -1,7 +1,14 @@import { matchPath, Redirect, useLocation } from 'react-router-dom';+import { Skeleton } from 'antd';import ROUTES from 'constants/routes';+import { withAuthZPage } from 'lib/authz/components/withAuthZ/withAuthZPage';+import {+ buildNotificationChannelReadPermission,+ buildNotificationChannelUpdatePermission,+} from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';import ChannelsEditPage from './ChannelsEditPage';+import styles from './ChannelsEdit.module.scss';function ChannelsEdit(): JSX.Element {const { pathname } = useLocation();@@ -16,4 +23,23 @@ function ChannelsEdit(): JSX.Element {return <ChannelsEditPage channelId={channelId} />;}-export default ChannelsEdit;+const channelIdFromRoute = (router: {+ matchPath: <P extends Record<string, string>>(p: string) => P | null;+}): string =>+ router.matchPath<{ channelId: string }>(ROUTES.CHANNELS_EDIT)?.channelId ?? '';++export default withAuthZPage(ChannelsEdit, {+ // `read` alone opens the screen; `update` only decides whether it can be+ // saved, so it is warmed here and enforced on the save button.+ checks: (_props, router) => [+ buildNotificationChannelReadPermission(channelIdFromRoute(router)),+ ],+ preloadChecks: (_props, router) => [+ buildNotificationChannelUpdatePermission(channelIdFromRoute(router)),+ ],+ fallbackOnLoading: (+ <div className={styles.loading}>+ <Skeleton active paragraph={{ rows: 8 }} />+ </div>+ ),+});diff --git a/frontend/src/pages/ChannelsNew/index.tsx b/frontend/src/pages/ChannelsNew/index.tsxindex c4984543b1..0f623dcea6 100644--- a/frontend/src/pages/ChannelsNew/index.tsx+++ b/frontend/src/pages/ChannelsNew/index.tsx@@ -1,6 +1,9 @@+import { Skeleton } from 'antd';import AlertBreadcrumb from 'components/AlertBreadcrumb';import ROUTES from 'constants/routes';import history from 'lib/history';+import { withAuthZPage } from 'lib/authz/components/withAuthZ/withAuthZPage';+import { NotificationChannelCreatePermission } from 'lib/authz/hooks/useAuthZ/permissions/notification-channel.permissions';import ChannelForm from 'pages/AlertList/NotificationChannels/components/ChannelForm/ChannelForm';import styles from './styles.module.scss';@@ -25,4 +28,11 @@ function ChannelsNew(): JSX.Element {);}-export default ChannelsNew;+export default withAuthZPage(ChannelsNew, {+ checks: [NotificationChannelCreatePermission],+ fallbackOnLoading: (+ <div className={styles.loading}>+ <Skeleton active paragraph={{ rows: 8 }} />+ </div>+ ),+});diff --git a/frontend/src/pages/ChannelsNew/styles.module.scss b/frontend/src/pages/ChannelsNew/styles.module.scssindex 473750049f..258b9c2c33 100644--- a/frontend/src/pages/ChannelsNew/styles.module.scss+++ b/frontend/src/pages/ChannelsNew/styles.module.scss@@ -1,3 +1,7 @@+.loading {+ padding: var(--spacing-6);+}+.content {padding: 0 var(--spacing-6) var(--spacing-6);}diff --git a/frontend/src/utils/permission/index.ts b/frontend/src/utils/permission/index.tsindex 9e66817d3c..a5901f1c0f 100644--- a/frontend/src/utils/permission/index.ts+++ b/frontend/src/utils/permission/index.ts@@ -159,6 +159,8 @@ export const routePermission: Record<keyof typeof ROUTES, ROLES[]> = {* This prevents us from adding `ANONYMOUS` on the `routePermission`*/export const routeWithInitialAuthZSupport = {+ CHANNELS_NEW: true,+ CHANNELS_EDIT: true,ALL_DASHBOARD: true,DASHBOARD: true,DASHBOARD_PANEL_EDITOR: true,