Skip to content

Commit f4a6dd1

Browse files
authored
feat: add MachineAccount support to PolicyBinding subjects with mandatory namespace validation (#552)
Related to: - datum-cloud/enhancements#129
2 parents d20be39 + f858aed commit f4a6dd1

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

config/crd/bases/iam/iam.miloapis.com_policybindings.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,15 @@ spec:
140140
items:
141141
description: |-
142142
Subject contains a reference to the object or user identities a role binding applies to.
143-
This can be a User or Group.
143+
This can be a User, Group, or MachineAccount.
144144
properties:
145145
kind:
146146
description: Kind of object being referenced. Values defined
147147
in Kind constants.
148148
enum:
149149
- User
150150
- Group
151+
- MachineAccount
151152
type: string
152153
name:
153154
description: |-
@@ -157,8 +158,8 @@ spec:
157158
type: string
158159
namespace:
159160
description: |-
160-
Namespace of the referenced object. If DNE, then for an SA it refers to the PolicyBinding resource's namespace.
161-
For a User or Group, it is ignored.
161+
Namespace of the referenced object.
162+
If not specified for a Group, User or MachineAccount, it is ignored.
162163
type: string
163164
uid:
164165
description: UID of the referenced object. Optional for system

docs/api/iam.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ This can be a reference to a Role custom resource.
18401840

18411841

18421842
Subject contains a reference to the object or user identities a role binding applies to.
1843-
This can be a User or Group.
1843+
This can be a User, Group, or MachineAccount.
18441844

18451845
<table>
18461846
<thead>
@@ -1857,7 +1857,7 @@ This can be a User or Group.
18571857
<td>
18581858
Kind of object being referenced. Values defined in Kind constants.<br/>
18591859
<br/>
1860-
<i>Enum</i>: User, Group<br/>
1860+
<i>Enum</i>: User, Group, MachineAccount<br/>
18611861
</td>
18621862
<td>true</td>
18631863
</tr><tr>
@@ -1873,8 +1873,8 @@ users.<br/>
18731873
<td><b>namespace</b></td>
18741874
<td>string</td>
18751875
<td>
1876-
Namespace of the referenced object. If DNE, then for an SA it refers to the PolicyBinding resource's namespace.
1877-
For a User or Group, it is ignored.<br/>
1876+
Namespace of the referenced object.
1877+
If not specified for a Group, User or MachineAccount, it is ignored.<br/>
18781878
</td>
18791879
<td>false</td>
18801880
</tr><tr>

pkg/apis/iam/v1alpha1/policybinding_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ type RoleReference struct {
1616
}
1717

1818
// Subject contains a reference to the object or user identities a role binding applies to.
19-
// This can be a User or Group.
19+
// This can be a User, Group, or MachineAccount.
2020
// +k8s:deepcopy-gen=true
2121
// +kubebuilder:validation:XValidation:rule="(self.kind == 'Group' && has(self.name) && self.name.startsWith('system:')) || (has(self.uid) && size(self.uid) > 0)",message="UID is required for all subjects except system groups (groups with names starting with 'system:')"
2222
type Subject struct {
2323
// Kind of object being referenced. Values defined in Kind constants.
2424
// +kubebuilder:validation:Required
25-
// +kubebuilder:validation:Enum=User;Group
25+
// +kubebuilder:validation:Enum=User;Group;MachineAccount
2626
Kind string `json:"kind"`
2727
// Name of the object being referenced. A special group name of
2828
// "system:authenticated-users" can be used to refer to all authenticated
2929
// users.
3030
// +kubebuilder:validation:Required
3131
Name string `json:"name"`
32-
// Namespace of the referenced object. If DNE, then for an SA it refers to the PolicyBinding resource's namespace.
33-
// For a User or Group, it is ignored.
32+
// Namespace of the referenced object.
33+
// If not specified for a Group, User or MachineAccount, it is ignored.
3434
// +kubebuilder:validation:Optional
3535
Namespace string `json:"namespace,omitempty"`
3636
// UID of the referenced object. Optional for system groups (groups with names starting with "system:").

0 commit comments

Comments
 (0)