Skip to content

Commit 577a02f

Browse files
zmotsoSergK
authored andcommitted
feat: Add the ability to add client roles to KeycloakRealmUser (#135)
1 parent 361b2a5 commit 577a02f

18 files changed

+684
-224
lines changed

api/v1/keycloakclient_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ type ClientRole struct {
219219
// ClientID is a client ID.
220220
ClientID string `json:"clientId"`
221221

222-
// Roles is a list of client roles names assigned to service account.
222+
// Roles is a list of client roles names assigned to user.
223223
// +nullable
224224
// +optional
225225
Roles []string `json:"roles,omitempty"`

api/v1/keycloakrealmuser_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ type KeycloakRealmUserSpec struct {
4545
// +optional
4646
Roles []string `json:"roles,omitempty"`
4747

48+
// ClientRoles is a list of client roles assigned to user.
49+
// +nullable
50+
// +optional
51+
ClientRoles []ClientRole `json:"clientRoles,omitempty"`
52+
4853
// Groups is a list of groups assigned to user.
4954
// +nullable
5055
// +optional

api/v1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/v1.edp.epam.com_keycloakclients.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ spec:
600600
type: string
601601
roles:
602602
description: Roles is a list of client roles names assigned
603-
to service account.
603+
to user.
604604
items:
605605
type: string
606606
nullable: true

config/crd/bases/v1.edp.epam.com_keycloakrealmgroups.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ spec:
6767
type: string
6868
roles:
6969
description: Roles is a list of client roles names assigned
70-
to service account.
70+
to user.
7171
items:
7272
type: string
7373
nullable: true

config/crd/bases/v1.edp.epam.com_keycloakrealmusers.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ spec:
5050
description: Attributes is a map of user attributes.
5151
nullable: true
5252
type: object
53+
clientRoles:
54+
description: ClientRoles is a list of client roles assigned to user.
55+
items:
56+
properties:
57+
clientId:
58+
description: ClientID is a client ID.
59+
type: string
60+
roles:
61+
description: Roles is a list of client roles names assigned
62+
to user.
63+
items:
64+
type: string
65+
nullable: true
66+
type: array
67+
required:
68+
- clientId
69+
type: object
70+
nullable: true
71+
type: array
5372
email:
5473
description: Email is a user email.
5574
type: string

deploy-templates/crds/v1.edp.epam.com_keycloakclients.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ spec:
600600
type: string
601601
roles:
602602
description: Roles is a list of client roles names assigned
603-
to service account.
603+
to user.
604604
items:
605605
type: string
606606
nullable: true

deploy-templates/crds/v1.edp.epam.com_keycloakrealmgroups.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ spec:
6767
type: string
6868
roles:
6969
description: Roles is a list of client roles names assigned
70-
to service account.
70+
to user.
7171
items:
7272
type: string
7373
nullable: true

deploy-templates/crds/v1.edp.epam.com_keycloakrealmusers.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ spec:
5050
description: Attributes is a map of user attributes.
5151
nullable: true
5252
type: object
53+
clientRoles:
54+
description: ClientRoles is a list of client roles assigned to user.
55+
items:
56+
properties:
57+
clientId:
58+
description: ClientID is a client ID.
59+
type: string
60+
roles:
61+
description: Roles is a list of client roles names assigned
62+
to user.
63+
items:
64+
type: string
65+
nullable: true
66+
type: array
67+
required:
68+
- clientId
69+
type: object
70+
nullable: true
71+
type: array
5372
email:
5473
description: Email is a user email.
5574
type: string

docs/api.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,7 +3153,7 @@ ServiceAccount is a service account configuration.
31533153
<td><b>roles</b></td>
31543154
<td>[]string</td>
31553155
<td>
3156-
Roles is a list of client roles names assigned to service account.<br/>
3156+
Roles is a list of client roles names assigned to user.<br/>
31573157
</td>
31583158
<td>false</td>
31593159
</tr></tbody>
@@ -3876,7 +3876,7 @@ RealmRef is reference to Realm custom resource.
38763876
<td><b>roles</b></td>
38773877
<td>[]string</td>
38783878
<td>
3879-
Roles is a list of client roles names assigned to service account.<br/>
3879+
Roles is a list of client roles names assigned to user.<br/>
38803880
</td>
38813881
<td>false</td>
38823882
</tr></tbody>
@@ -6108,6 +6108,13 @@ KeycloakRealmUserSpec defines the desired state of KeycloakRealmUser.
61086108
Attributes is a map of user attributes.<br/>
61096109
</td>
61106110
<td>false</td>
6111+
</tr><tr>
6112+
<td><b><a href="#keycloakrealmuserspecclientrolesindex">clientRoles</a></b></td>
6113+
<td>[]object</td>
6114+
<td>
6115+
ClientRoles is a list of client roles assigned to user.<br/>
6116+
</td>
6117+
<td>false</td>
61116118
</tr><tr>
61126119
<td><b>email</b></td>
61136120
<td>string</td>
@@ -6247,6 +6254,40 @@ RealmRef is reference to Realm custom resource.
62476254
</table>
62486255

62496256

6257+
### KeycloakRealmUser.spec.clientRoles[index]
6258+
<sup><sup>[↩ Parent](#keycloakrealmuserspec)</sup></sup>
6259+
6260+
6261+
6262+
6263+
6264+
<table>
6265+
<thead>
6266+
<tr>
6267+
<th>Name</th>
6268+
<th>Type</th>
6269+
<th>Description</th>
6270+
<th>Required</th>
6271+
</tr>
6272+
</thead>
6273+
<tbody><tr>
6274+
<td><b>clientId</b></td>
6275+
<td>string</td>
6276+
<td>
6277+
ClientID is a client ID.<br/>
6278+
</td>
6279+
<td>true</td>
6280+
</tr><tr>
6281+
<td><b>roles</b></td>
6282+
<td>[]string</td>
6283+
<td>
6284+
Roles is a list of client roles names assigned to user.<br/>
6285+
</td>
6286+
<td>false</td>
6287+
</tr></tbody>
6288+
</table>
6289+
6290+
62506291
### KeycloakRealmUser.spec.passwordSecret
62516292
<sup><sup>[↩ Parent](#keycloakrealmuserspec)</sup></sup>
62526293

0 commit comments

Comments
 (0)