DoodleScheduling / keycloak-controller

Keycloak realm reconciliation for kubernetes
Apache License 2.0
5 stars 0 forks source link

Is it possible to change implementation for groups ? #192

Closed Neferites closed 7 months ago

Neferites commented 7 months ago

Hello First of all, i'm grateful for this well-designed controller :). I'm facing an issue with groups not being imported.

Group structure :

groups:
  - name: my-group
    path: /my-group
    clientRoles:
      my-first-realm:
        - impersonation
        - view-users
      my-second-realm:
        - view-users
        - impersonation

Describe the change

For now, groups are defined by : Groups []string `json:"groups,omitempty"` From Keycloak api doc, group representation consist of maps, strings, array and subgroups. https://www.keycloak.org/docs-api/21.0.1/rest-api/index.html#_grouprepresentation

Current situation

Groups are : Groups []string `json:"groups,omitempty"`

Should

Groups should be : Groups []GroupRepresentation `json:"groups,omitempty"`

Additional context

Add any other context about the problem here.

raffis commented 7 months ago

Yes this indeed looks like a bug, thanks for reporting.

y3lousso commented 7 months ago

I think the issue was not completly fixed. When running the new version 2.2.0 and using groups: string[], I am correctly getting this error:

cannot unmarshal string into Go struct field KeycloakAPIRealm.items.spec.realm.groups of type v1beta1.KeycloakAPIGroup\n"}

Nonetheless, when I use the proper object structure

groups:
  - name: group1
    path: /group1
    clientRoles:
      role1:
        - impersonation
        - view-users
      role2:
        - impersonation
        - view-users

I get: strict decoding error: unknown field "spec.realm.groups[0].clientRoles", unknown field "spec.realm.groups[0].name", unknown field "spec.realm.groups[0].path"

cf https://www.keycloak.org/docs-api/24.0.1/javadocs/org/keycloak/representations/idm/GroupRepresentation.html

raffis commented 7 months ago

I can't reproduce this. Are you certain you are running the latest version as well as updated crds? How did you deploy the release?

Please try with a new realm also.

y3lousso commented 7 months ago

The issue was with upgrading the CRDs, I did not know that Helm does not reinstall CRDs if it already existed 😓 Helm doc: https://helm.sh/docs/topics/charts/#limitations-on-crds

Thanks for the help 👍