rancher / rancher

Complete container management platform
http://rancher.com
Apache License 2.0
23.14k stars 2.94k forks source link

[BUG] Users added by username in GenericOIDC auth provider do not have access to resources #46105

Open joesims22 opened 1 month ago

joesims22 commented 1 month ago

Rancher Server Setup

Information about the Cluster

Describe the bug When GenericOIDC(keycloak) auth provider is enabled, auth provider users that are added to a cluster/project by their username are not able to access resources upon logging in. Only if a user is added by their userID will they have access to resources upon logging in.

To Reproduce

  1. Install rancher v2.9-head
  2. Create a downstream cluster
  3. Enable GenericOIDC using keycloak
  4. In the downstream cluster add testuser2 as a Cluster Owner
  5. Login as testuser2 and observe the downstream cluster is not listed

Expected Result Users should be able to access resources when added by their username.

crobby commented 1 month ago

By default with keycloak as well as other oidc providers, the "sub" claim (which we use to form our principal ID) is populated with the ID of the user. It is possible to map a different value to the sub claim to make for a more user-friendly UX, but you do need to be careful to set it to something that is guaranteed to be unique (which username should be) and ideally immutable because if it changes and the user logs in, it will be seen as a new Rancher user.