Skip to content
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

fix: UI part for logs RBAC - do not display the logs tab when no RBAC in place (#7211) #9828

Merged
merged 2 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ commands, and helps to troubleshoot the application state.
Argo CD is used to manage the critical infrastructure of multiple organizations, which makes security the top priority of the project. We've listened to
your feedback and introduced additional access control settings that control access to Kubernetes Pod logs and the new Web Terminal feature.

#### Known UI Issue for Pod Logs Access
#### Pod Logs UI

Currently, upon pressing the "LOGS" tab in pod view by users who don't have an explicit allow get logs policy, the red "unable to load data: Internal error" is received in the bottom of the screen, and "Failed to load data, please try again" is displayed.
Since 2.4.7, the LOGS tab in pod view is visible in the UI only for users with explicit allow get logs policy.

#### Known pod logs UI issue prior to 2.4.7

Upon pressing the "LOGS" tab in pod view by users who don't have an explicit allow get logs policy, the red "unable to load data: Internal error" is received in the bottom of the screen, and "Failed to load data, please try again" is displayed.

### OpenTelemetry Tracing Integration

Expand Down
8 changes: 6 additions & 2 deletions docs/operator-manual/upgrading/2.3-2.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ p, role:test-db-admins, applications, *, staging-db-admins/*, allow
p, role:test-db-admins, logs, get, staging-db-admins/*, allow
```

## Known UI issue
### Pod Logs UI

Currently, upon pressing the "LOGS" tab in pod view by users who don't have an explicit allow get logs policy, the red "unable to load data: Internal error" is received in the bottom of the screen, and "Failed to load data, please try again" is displayed.
Since 2.4.7, the LOGS tab in pod view is visible in the UI only for users with explicit allow get logs policy.

### Known pod logs UI issue prior to 2.4.7

Upon pressing the "LOGS" tab in pod view by users who don't have an explicit allow get logs policy, the red "unable to load data: Internal error" is received in the bottom of the screen, and "Failed to load data, please try again" is displayed.

## Test repo-server with its new dedicated Service Account

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {
const page = parseInt(new URLSearchParams(appContext.history.location.search).get('page'), 10) || 0;
const untilTimes = (new URLSearchParams(appContext.history.location.search).get('untilTimes') || '').split(',') || [];

const getResourceTabs = (node: ResourceNode, state: State, podState: State, events: Event[], extensionTabs: ResourceTabExtension[], tabs: Tab[], execEnabled: boolean) => {
const getResourceTabs = (
node: ResourceNode,
state: State,
podState: State,
events: Event[],
extensionTabs: ResourceTabExtension[],
tabs: Tab[],
execEnabled: boolean,
logsAllowed: boolean
) => {
if (!node || node === undefined) {
return [];
}
Expand Down Expand Up @@ -78,30 +87,32 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {

const onClickContainer = (group: any, i: number) => SelectNode(selectedNodeKey, group.offset + i, 'logs', appContext);

tabs = tabs.concat([
{
key: 'logs',
icon: 'fa fa-align-left',
title: 'LOGS',
content: (
<div className='application-details__tab-content-full-height'>
<PodsLogsViewer
podName={(state.kind === 'Pod' && state.metadata.name) || ''}
group={node.group}
kind={node.kind}
name={node.name}
namespace={podState.metadata.namespace}
applicationName={application.metadata.name}
containerName={AppUtils.getContainerName(podState, selectedNodeInfo.container)}
page={{number: page, untilTimes}}
setPage={pageData => appContext.navigation.goto('.', {page: pageData.number, untilTimes: pageData.untilTimes.join(',')})}
containerGroups={containerGroups}
onClickContainer={onClickContainer}
/>
</div>
)
}
]);
if (logsAllowed) {
tabs = tabs.concat([
{
key: 'logs',
icon: 'fa fa-align-left',
title: 'LOGS',
content: (
<div className='application-details__tab-content-full-height'>
<PodsLogsViewer
podName={(state.kind === 'Pod' && state.metadata.name) || ''}
group={node.group}
kind={node.kind}
name={node.name}
namespace={podState.metadata.namespace}
applicationName={application.metadata.name}
containerName={AppUtils.getContainerName(podState, selectedNodeInfo.container)}
page={{number: page, untilTimes}}
setPage={pageData => appContext.navigation.goto('.', {page: pageData.number, untilTimes: pageData.untilTimes.join(',')})}
containerGroups={containerGroups}
onClickContainer={onClickContainer}
/>
</div>
)
}
]);
}
if (execEnabled) {
tabs = tabs.concat([
{
Expand Down Expand Up @@ -250,8 +261,8 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {

const settings = await services.authService.settings();
const execEnabled = settings.execEnabled;

return {controlledState, liveState, events, podState, execEnabled};
const logsAllowed = await services.accounts.canI('logs', 'get', application.spec.project + '/' + application.metadata.name);
return {controlledState, liveState, events, podState, execEnabled, logsAllowed};
}}>
{data => (
<React.Fragment>
Expand Down Expand Up @@ -295,7 +306,8 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {
content: <ApplicationNodeInfo application={application} live={data.liveState} controlled={data.controlledState} node={selectedNode} />
}
],
data.execEnabled
data.execEnabled,
data.logsAllowed
)}
selectedTabKey={props.tab}
onTabSelected={selected => appContext.navigation.goto('.', {tab: selected}, {replace: true})}
Expand Down
4 changes: 4 additions & 0 deletions ui/src/app/shared/services/accounts-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ export class AccountsService {
public deleteToken(name: string, id: string): Promise<any> {
return requests.delete(`/account/${name}/token/${id}`);
}

public canI(resource: string, action: string, subresource: string): Promise<boolean> {
return requests.get(`/account/can-i/${resource}/${action}/${subresource}`).then(res => res.body.value === 'yes');
}
}