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

Unable able to connect to OpenLdap server #483

Open
chaslingl opened this issue Feb 28, 2024 · 17 comments
Open

Unable able to connect to OpenLdap server #483

chaslingl opened this issue Feb 28, 2024 · 17 comments

Comments

@chaslingl
Copy link

Hi,

My environment is running docker container for OpenLDAP (osixia/openldap:1.3.0), Zookeeper, Kafka (3.6.1).

  • copy kafka-ldap-integration-*.jar files to $KAFKA_HOME/libs
  • copy ldapconfig.yml to $KAFKA_HOME/config and set CLASSPATH
  • Able to ping and issue ldapserach command to query user from kafka broker container with non-secure ldap port 389
    my server.properties
    ...
    sasl.mechanism.inter.broker.protocol=PLAIN
    sasl.enabled.mechanisms=PLAIN
    listener.name.sasl_plaintext.plain.sasl.jaas.config=
    org.apache.kafka.common.security.plain.PlainLoginModule required
    username="uid=srvkafkabroker,ou=users,dc=security,dc=example,dc=com"
    password="broker";
    listener.name.sasl_plaintext.plain.sasl.server.callback.handler.class=
    com.ultratendency.kafka.ldap.authentication.SimpleLDAPAuthentication
    ldap.group.authorization.enable=false
    #authorizer.class.name=com.ultratendency.kafka.ldap.authorization.SimpleLDAPAuthorizer
    super.users=User:srvkafkabroker

Here is error from broker server.log
[2024-02-27 21:42:27,027] ERROR URI is not absolute - authentication and authorization will fail! (com.ultratendency.kafka.ldap.LDAPConfig)
[2024-02-27 21:42:27,052] INFO Bind and group caches are initialized (com.ultratendency.kafka.ldap.common.LDAPCache)
[2024-02-27 21:42:27,173] ERROR Authentication and authorization will fail! Exception when connecting to (,0) - null (com.ultratendency.kafka.ldap.common.LDAPBase)
[2024-02-27 21:42:27,174] ERROR No LDAP connection, cannot authenticate [=uid=srvkafkabroker,ou=users,dc=security,dc=example,dc=com,, =uid=srvkafkabroker,ou=users,dc=security,dc=example,dc=com,] and related password! (com.ultratendency.kafka.ldap.authentication.LDAPAuthentication)
[2024-02-27 21:42:27,176] ERROR Authentication End - authentication failed - user=uid=srvkafkabroker,ou=users,dc=security,dc=example,dc=com, status=denied (com.ultratendency.kafka.ldap.authentication.SimpleLDAPAuthentication)
[2024-02-27 21:42:27,177] INFO [SocketServer listenerType=ZK_BROKER, nodeId=1] Failed authentication with /xxx.xxx.xxx.xxx (channelId=xxx.xxx.xxx.xxx:9092-xxx.xxx.xxx.xxx:53812-0) (Authentication failed: Invalid username or password) (org.apache.kafka.common.network.Selector)

Thanks.

@julianbergner
Copy link

Hi,

can you share your ldapconfig.yaml, please? Is the host reachable from your broker container?

@chaslingl
Copy link
Author

chaslingl commented Feb 29, 2024 via email

@julianbergner
Copy link

julianbergner commented Feb 29, 2024

With host I meant the variable in the yaml with your value ldap.
Can you paste your ldapsearch command from your broker container, please?

Edit: Can the user which runs the broker access ldapconfig.yaml ? What are the file permissions?

@chaslingl
Copy link
Author

chaslingl commented Mar 1, 2024 via email

@julianbergner
Copy link

Can the user which runs the broker access ldapconfig.yaml ? What are the file permissions?

@chaslingl
Copy link
Author

Yes, container is running by root.
root@broker:/usr/local/kafka# ls -la config/ldapconfig.yml
-rwxr-xr-x 1 root root 773 Feb 27 21:30 config/ldapconfig.yml

@chaslingl
Copy link
Author

chaslingl commented Mar 1, 2024 via email

@chaslingl
Copy link
Author

chaslingl commented Mar 4, 2024 via email

@julianbergner
Copy link

Hi,

yes I assume that the ldapconfig.yml is not read correctly.
How do you start your broker service and how do you set the Classpath?

@chaslingl
Copy link
Author

chaslingl commented Mar 5, 2024 via email

@julianbergner
Copy link

can you share your docker file please?

@chaslingl
Copy link
Author

chaslingl commented Mar 6, 2024 via email

@chaslingl
Copy link
Author

chaslingl commented Mar 6, 2024 via email

@chaslingl
Copy link
Author

chaslingl commented Mar 8, 2024 via email

@julianbergner
Copy link

In fact, no.
I cannot reproduce your behaviour. When I am using your ldapconfig.yml and host an openldap container I am getting this log:

[2024-03-08 15:48:08,742] INFO file:/etc/kafka/ldapconfig.yaml read (com.ultratendency.kafka.ldap.LDAPConfig) [2024-03-08 15:48:08,742] INFO LDAPConfig for classpath is cached (com.ultratendency.kafka.ldap.LDAPConfig) [2024-03-08 15:48:08,751] INFO ldap configuration values: Config(host=ldap, port=389, connTimeout=60000, adminBaseDN=ou=users,dc=security,dc=example,dc=com, adminUid=uid, usrBaseDN=ou=users,dc=security,dc=example,dc=com, usrUid=uid, grpBaseDN=ou=groups,dc=security,dc=example,dc=com, grpUid=cn, grpAttrName=uniqueMember, usrCacheExpire=6, grpCacheExpire=6) (com.ultratendency.kafka.ldap.LDAPConfig) [2024-03-08 15:48:08,765] INFO Bind and group caches are initialized (com.ultratendency.kafka.ldap.common.LDAPCache)

@julianbergner
Copy link

julianbergner commented Mar 8, 2024

'ldap' is the hostname of ldap container. I ran the following ldapsearch command in 'broker' container @.:/usr/local/kafka# ldapsearch -x -H ldap://ldap:389 -b dc=example,dc=com -D "uid=srvkafkabroker,ou=users,dc=security,dc=example,dc=com" -w broker # extended LDIF # # LDAPv3 # base <dc=example,dc=com> with scope subtree # filter: (objectclass=) # requesting: ALL # # search result search: 2 result: 32 No such object # numResponses: 1 Thanks.

On Thu, Feb 29, 2024 at 5:32 PM Julian Bergner @.
> wrote: With host I meant the variable in the yaml with your value ldap. Can you paste your ldapsearch command from your broker container, please? — Reply to this email directly, view it on GitHub <#483 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQVN3FKTSZ4UYCDMFYVUIJTYV65BBAVCNFSM6AAAAABD6FFPE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZSGE2DOOJYGI . You are receiving this because you authored the thread.Message ID: @.**>

Btw: This ldapsearch throws an error. Shouldn't be related to the wrong ldap host, but still you have an ldap issues even without the library involved.

@chaslingl
Copy link
Author

chaslingl commented Mar 8, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants