Skip to content

PMM-13596 Add access control for logs and dump #807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 14, 2025
99 changes: 63 additions & 36 deletions public/app/core/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { GrafanaTheme2, LinkTarget } from '@grafana/data';
import { config } from '@grafana/runtime';
import { Icon, IconName, useStyles2 } from '@grafana/ui';
import { t } from 'app/core/internationalization';
import { isPmmAdmin } from 'app/percona/shared/helpers/permissions';

export interface FooterLink {
// @PERCONA - make target optional
Expand All @@ -17,42 +18,68 @@ export interface FooterLink {

export let getFooterLinks = (): FooterLink[] => {
// @PERCONA
return [
{
id: 'pmm-dump',
text: 'PMM Dump',
icon: 'brain',
url: '/graph/pmm-dump',
},
{
id: 'pmm-logs',
text: 'PMM Logs',
icon: 'download-alt',
url: '/logs.zip',
target: '_blank',
},
{
target: '_blank',
id: 'pmm-docs',
text: t('nav.help/documentation', 'Documentation'),
icon: 'document-info',
url: 'https://per.co.na/pmm_documentation',
},
{
target: '_blank',
id: 'support',
text: t('nav.help/support', 'Support'),
icon: 'question-circle',
url: 'https://per.co.na/pmm_support',
},
{
target: '_blank',
id: 'community',
text: t('nav.help/community', 'Community'),
icon: 'comments-alt',
url: 'https://per.co.na/pmm_community',
},
];
if (isPmmAdmin(config.bootData.user)) {
return [
{
id: 'pmm-dump',
text: 'PMM Dump',
icon: 'brain',
url: '/graph/pmm-dump',
},
{
id: 'pmm-logs',
text: 'PMM Logs',
icon: 'download-alt',
url: '/logs.zip',
target: '_blank',
},
{
target: '_blank',
id: 'pmm-docs',
text: t('nav.help/documentation', 'Documentation'),
icon: 'document-info',
url: 'https://per.co.na/pmm_documentation',
},
{
target: '_blank',
id: 'support',
text: t('nav.help/support', 'Support'),
icon: 'question-circle',
url: 'https://per.co.na/pmm_support',
},
{
target: '_blank',
id: 'community',
text: t('nav.help/community', 'Community'),
icon: 'comments-alt',
url: 'https://per.co.na/pmm_community',
},
];
} else {
return [
{
target: '_blank',
id: 'pmm-docs',
text: t('nav.help/documentation', 'Documentation'),
icon: 'document-info',
url: 'https://per.co.na/pmm_documentation',
},
{
target: '_blank',
id: 'support',
text: t('nav.help/support', 'Support'),
icon: 'question-circle',
url: 'https://per.co.na/pmm_support',
},
{
target: '_blank',
id: 'community',
text: t('nav.help/community', 'Community'),
icon: 'comments-alt',
url: 'https://per.co.na/pmm_community',
},
];
}
};

export function getVersionMeta(version: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ExportDataset: FC<GrafanaRouteComponentProps<{ type: string; id: string }>
const styles = useStyles2(getStyles);
const dispatch = useAppDispatch();
const { isLoading, services: fetchedServices } = useSelector(getServices);
const initialValues = useMemo<Partial<ExportDatasetProps>>(() => ({ load: true }), []);

const serviceNames = useMemo(
() =>
Expand Down Expand Up @@ -109,6 +110,7 @@ const ExportDataset: FC<GrafanaRouteComponentProps<{ type: string; id: string }>
<Page.Contents>
<Form
onSubmit={handleSubmit}
initialValues={initialValues}
render={({ handleSubmit, form }) => (
<form onSubmit={handleSubmit} className={styles.form}>
<PageToolbar title={Messages.breadCrumbTitle} onGoBack={handleGoBack}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ const PerconaNavigation: FC = () => {
updatedNavTree.push(PMM_ENVIRONMENT_OVERVIEW_PAGE);
}

// PMM Dump
const help = updatedNavTree.find((i) => i.id === 'help');
if (help) {
help.children = help.children || [];
help.children.push(PMM_DUMP_PAGE);

dispatch(updateNavIndex(PMM_DUMP_PAGE));
dispatch(updateNavIndex(help));
}

if (isPmmAdmin(config.bootData.user)) {
// PMM Dump
const help = updatedNavTree.find((i) => i.id === 'help');
if (help) {
help.children = help.children || [];
help.children.push(PMM_DUMP_PAGE);

dispatch(updateNavIndex(PMM_DUMP_PAGE));
dispatch(updateNavIndex(help));
}

if (result?.enableAccessControl) {
const cfg = cloneDeep(initialState).find((i) => i.id === 'cfg');

Expand Down
33 changes: 20 additions & 13 deletions public/app/routes/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ConfigureIRM } from 'app/features/gops/configuration-tracker/components
import { getRoutes as getPluginCatalogRoutes } from 'app/features/plugins/admin/routes';
import { getAppPluginRoutes } from 'app/features/plugins/routes';
import { getProfileRoutes } from 'app/features/profile/routes';
import { isPmmAdmin } from 'app/percona/shared/helpers/permissions';
import { AccessControlAction, DashboardRoutes } from 'app/types';

import { SafeDynamicImport } from '../core/components/DynamicImports/SafeDynamicImport';
Expand Down Expand Up @@ -787,19 +788,25 @@ export function getAppRoutes(): RouteDescriptor[] {
() => import(/* webpackChunkName: "DataTrailsPage"*/ 'app/features/trails/DataTrailsPage')
),
},
{
path: '/pmm-dump',
component: SafeDynamicImport(() => import(/* webpackChunkName: "PMMDump" */ 'app/percona/pmm-dump/PMMDump')),
},
{
path: '/pmm-dump/new',
component: SafeDynamicImport(
() =>
import(
/* webpackChunkName: "BackupInventoryPage" */ 'app/percona/pmm-dump/components/ExportDataset/ExportDataset'
)
),
},
...(isPmmAdmin(config.bootData.user)
? [
{
path: '/pmm-dump',
component: SafeDynamicImport(
() => import(/* webpackChunkName: "PMMDump" */ 'app/percona/pmm-dump/PMMDump')
),
},
{
path: '/pmm-dump/new',
component: SafeDynamicImport(
() =>
import(
/* webpackChunkName: "BackupInventoryPage" */ 'app/percona/pmm-dump/components/ExportDataset/ExportDataset'
)
),
},
]
: []),
...getPluginCatalogRoutes(),
...getSupportBundleRoutes(),
...getAlertingRoutes(),
Expand Down
Loading