Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ldap-group-mapper fails when empty member: attribute is present #25883

Closed
1 task done
FAUSheppy opened this issue Jan 3, 2024 · 2 comments · Fixed by #26930
Closed
1 task done

ldap-group-mapper fails when empty member: attribute is present #25883

FAUSheppy opened this issue Jan 3, 2024 · 2 comments · Fixed by #26930
Assignees
Milestone

Comments

@FAUSheppy
Copy link

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

ldap

Describe the bug

This error occurs:


2024-01-03 21:00:15,793 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-2) Uncaught server error: java.lang.NullPointerException: Cannot invoke "org.keycloak.storage.ldap.idm.model.LDAPDn$RDN.getAttrValue(String)" because the return value of "org.keycloak.storage.ldap.idm.model.LDAPDn.getFirstRdn()" is null
	at org.keycloak.storage.ldap.mappers.membership.MembershipType$1.getLDAPMembersWithParent(MembershipType.java:66)
	at org.keycloak.storage.ldap.mappers.membership.MembershipType$1.getLDAPSubgroups(MembershipType.java:53)
	at org.keycloak.storage.ldap.mappers.membership.group.GroupLDAPStorageMapper.getLDAPSubgroups(GroupLDAPStorageMapper.java:152)
	at org.keycloak.storage.ldap.mappers.membership.group.GroupLDAPStorageMapper.convertGroupsToInternalRep(GroupLDAPStorageMapper.java:241)
	at org.keycloak.storage.ldap.mappers.membership.group.GroupLDAPStorageMapper.syncDataFromFederationProviderToKeycloak(GroupLDAPStorageMapper.java:177)
	at org.keycloak.services.resources.admin.UserStorageProviderResource.syncMapperData(UserStorageProviderResource.java:255)
	at org.keycloak.services.resources.admin.UserStorageProviderResource$quarkusrestinvoker$syncMapperData_7d7259fd8f486e4638b0a2f1d3b37905909372a0.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:840

when a empty member: attribute exists in the LDAP-group like this:

dn: cn=test,ou=groups,dc=example,dc=com
objectClass: groupOfNames
cn: test
member: 
member: uid=dev,ou=People,dc=example,dc=com

such a member may be automatically created by various tools for empty groups. It should not cause the whole import for ALL groups to fail (or the entire sync).

Version

23.0.3

Expected behavior

a) Nothing happens, an empty member is ignored (my opinion)
b) At least just skip the group and import the rest

Actual behavior

Whole sync/group import crashes with "unknown_error" in web-interface and the above error in the log.

How to Reproduce?

Create an empty group with via ldapmodify or something and see how this create an empty member: entry which is not removed once a member is added and cause the LDAP provide to crash during sync with the above error.

Anything else?

This Bug started to occur somewhere between 20.0.3 and 22.0.2. It definitely worked on 20.0.3.

@FAUSheppy FAUSheppy added kind/bug Categorizes a PR related to a bug status/triage labels Jan 3, 2024
@FAUSheppy FAUSheppy changed the title ldap-group-mapper fails when empty member: attributes is present ldap-group-mapper fails when empty member: attribute is present Jan 4, 2024
@lukas-staab
Copy link

lukas-staab commented Jan 13, 2024

I can confirm this behaviour in 23.0.3 and it might be an issue to me as well, right now all my openLDAP Groups have an empty member to ensure every (real) member can be removed without errors.

Edit: Only the Mapping modes READ_ONLY and LDAP_ONLY are faulty with empty members. IMPORT does not throw errors. I have configured the LDAP provider as read only.

@ahus1 ahus1 added this to the 24.0.0 milestone Jan 31, 2024
sguilhen added a commit to sguilhen/keycloak that referenced this issue Feb 9, 2024
…found within a group

Closes keycloak#25883

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
@sguilhen
Copy link
Contributor

sguilhen commented Feb 9, 2024

I confirm the bug - it was introduced by 7336ff0

I'm sending a PR with a fix - essentially changing the check order in MembershipType so that isDescendantOf is called first as that method returns false when an empty member is processed.

ahus1 pushed a commit that referenced this issue Feb 9, 2024
…found within a group

Closes #25883

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
sguilhen added a commit to sguilhen/keycloak that referenced this issue Feb 16, 2024
…found within a group

Closes keycloak#25883

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
(cherry picked from commit d3ae075)
ahus1 pushed a commit that referenced this issue Feb 16, 2024
…found within a group

Closes #25883

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
(cherry picked from commit d3ae075)
ahus1 pushed a commit to ahus1/keycloak that referenced this issue Mar 22, 2024
…found within a group

Closes keycloak#25883

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants