openshift / openshift/oauth-server

Groups gets deleted on multi-IdP setup

Open Beginner friendly
#240 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
26
Forks
76
Avg merge
1d 18h
Merged PRs (30d)
6

Description

We are currently hitting a very subtle bug regarding a multi-IdP Setup (Keycloak, LDAP):

When a user logs in via Keycloak all non-existing groups are created due to group-claims. Now if the same user logs in via LDAP after the first login (same account, mappingMethod: add) all groups that where created by the keycloak IdP are deleted if the user is the only user in that group.

I identified this section:
https://github.com/openshift/oauth-server/blob/f892602b822782e0080abc70c6cd1d178f11e684/pkg/groupmapper/groupmapper.go#L136-L143

The group cleanup check is above the IdP annotation check, most likely leading to this problem.

I know that this is an edge-case but can hit quite randomly and forces us to work around it. My customers and I would really appreciate a fix.

How to reproduce:

  • add an OAuth and a LDAP IdP to Openshift (both are binding to the same Openshift User with mappingMethod: add)
  • add automated group propagation using claims to the OAuth IdP
  • login with an user that has at least one group using the OAuth IdP
    • groups is created as expected
  • logout and login with the same user using the LDAP IdP
  • now the group is deleted

Notes:

  • If another user is added to the group (for whatever reason) it is not deleted
  • If the group is created manually or via ldap sync this does not happen
  • If 2 OAuth IdPs are used and both IdP Tokens contain the same groups, there should be no problem
  • This behavior points to a bug rather than a security feature.
  • Simply swapping the order of the checks should fix this edge-case.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg/groupmapper/groupmapper.go around lines 136-143, where group cleanup is checked relative to the IdP annotation. Reproduce the Keycloak and LDAP login sequence with mappingMethod: add, then verify that groups created from Keycloak claims remain after the LDAP login. Done means the described multi-IdP flow no longer deletes a group when its only member is the shared user.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.