Skip to content

Commit b2ce9af

Browse files
Merge pull request #13345 from rhamilto/OCPBUGS-23248
OCPBUGS-23125: add access review for impersonate
2 parents 78189a2 + 7379f76 commit b2ce9af

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

frontend/packages/console-dynamic-plugin-sdk/src/api/common-types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ type K8sVerb =
101101
| 'patch'
102102
| 'delete'
103103
| 'deletecollection'
104-
| 'watch';
104+
| 'watch'
105+
| 'impersonate';
105106

106107
enum BadgeType {
107108
DEV = 'Dev Preview',

frontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export type K8sVerb =
7878
| 'patch'
7979
| 'delete'
8080
| 'deletecollection'
81-
| 'watch';
81+
| 'watch'
82+
| 'impersonate';
8283

8384
export type AccessReviewResourceAttributes = {
8485
group?: string;

frontend/public/components/RBAC/bindings.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ const menuActions = ({ subjectIndex, subjects }, startImpersonate) => {
146146
actions.unshift(() => ({
147147
label: i18next.t('public~Impersonate {{kind}} "{{name}}"', subject),
148148
callback: () => startImpersonate(subject.kind, subject.name),
149+
// Must use API group authorization.k8s.io, NOT user.openshift.io
150+
// See https://kubernetes.io/docs/reference/access-authn-authz/authentication/#user-impersonation
151+
accessReview: {
152+
group: 'authorization.k8s.io',
153+
resource: subject.kind === 'Group' ? 'groups' : 'users',
154+
name: subject.name,
155+
verb: 'impersonate',
156+
},
149157
}));
150158
}
151159

frontend/public/components/user.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ const UserKebab_: React.FC<UserKebabProps & UserKebabDispatchProps> = ({
3535
const impersonateAction: KebabAction = (kind: K8sKind, obj: UserKind) => ({
3636
label: t('public~Impersonate User {{name}}', obj.metadata),
3737
callback: () => startImpersonate('User', obj.metadata.name),
38+
// Must use API group authorization.k8s.io, NOT user.openshift.io
39+
// See https://kubernetes.io/docs/reference/access-authn-authz/authentication/#user-impersonation
40+
accessReview: {
41+
group: 'authorization.k8s.io',
42+
resource: 'users',
43+
name: obj.metadata.name,
44+
verb: 'impersonate',
45+
},
3846
});
3947
return (
4048
<ResourceKebab
@@ -218,6 +226,14 @@ const UserDetailsPage_: React.FC<UserDetailsPageProps & UserKebabDispatchProps>
218226
const impersonateAction: KebabAction = (kind: K8sKind, obj: UserKind) => ({
219227
label: t('public~Impersonate User {{name}}', obj.metadata),
220228
callback: () => startImpersonate('User', obj.metadata.name),
229+
// Must use API group authorization.k8s.io, NOT user.openshift.io
230+
// See https://kubernetes.io/docs/reference/access-authn-authz/authentication/#user-impersonation
231+
accessReview: {
232+
group: 'authorization.k8s.io',
233+
resource: 'users',
234+
name: obj.metadata.name,
235+
verb: 'impersonate',
236+
},
221237
});
222238
return (
223239
<DetailsPage

0 commit comments

Comments
 (0)