allegro / allegro/ralph

PROTOCOL_ERROR while authenticating

Aperta
#3,579 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
2.5k
Fork
593
Merge medio
2g 9h
PR unite (30g)
6

Descrizione

Good morning,

I'm stuck with the LDAP authentication, Ralph is able to map users from the requested group, but not authenticate them. I have a stunnel connected to the LDAP server using certs, and in the Ralph's conf, the bind user and password.

I had to change in base.py user for person the LDAP_SERVER_OBJECT_USER_CLASS attribute, otherwise, no successful search was performed.

### Steps to reproduce
ralph ldap_sync
[12:57:15] DEBUG Populating Django user b'a.usera'
[12:57:16] WARNING Caught LDAPError while authenticating b'a.usera': PROTOCOL_ERROR({'msgtype': 111, 'msgid': 2, 'result': 2, 'desc': 'Protocol error', 'ctrls': []},)
[12:57:16] DEBUG Populating Django user b'b.userb'
[12:57:17] WARNING Caught LDAPError while authenticating b'b.userb': PROTOCOL_ERROR({'msgtype': 111, 'msgid': 2, 'result': 2, 'desc': 'Protocol error', 'ctrls': []},)
[12:57:17] DEBUG Populating Django user b'c.userc'
[12:57:18] WARNING Caught LDAPError while authenticating b'c.userc': PROTOCOL_ERROR({'msgtype': 111, 'msgid': 2, 'result': 2, 'desc': 'Protocol error', 'ctrls': []},)
[12:57:18] DEBUG Populating Django user b'd.userd'
[12:57:19] WARNING Caught LDAPError while authenticating b'd.userd': PROTOCOL_ERROR({'msgtype': 111, 'msgid': 2, 'result': 2, 'desc': 'Protocol error', 'ctrls': []},)

What I see in the LDAP server log, is that the query is successful when I see the bind user, but for any reason, the query is not well requested to the LDAP server:

Search of the Group's members:

LDAP search with (&(objectClass=person)(&(memberOf=CN=inventory,OU=Groups,dc=acme,dc=com))) successful. | Search successful

And now, the weird story:

LDAP bind with "user" successful. | Bind successful
LDAP bind with "" successful. | Bind successful

Both searches, have the same timestamp. Same behaviour for the 4 users, a couple of searches, one with the bindUser and the other without.

### Expected behavior

Authentication successful

### Actual behavior

I've tried several configurations I found in Gitter, but no one solve this issue.

This is the LDAP's snippet in prod.py:

from django_auth_ldap.config import LDAPSearch
from django_auth_ldap.config import GroupOfNamesType
from django_auth_ldap.config import PosixGroupType

DEBUG = bool_from_env('RALPH_DEBUG', False)

AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
LOGGING['loggers']['django_auth_ldap'] = {
'handlers': ['file','console'],
'propagate': True,
'level': 'DEBUG',
}

# LDAP Config - Server
AUTH_LDAP_SERVER_URI = "ldap://stunnel:1636"
AUTH_LDAP_BIND_DN = "user"
AUTH_LDAP_BIND_PASSWORD = "secret"
AUTH_LDAP_PROTOCOL_VERSION = 3

AUTH_LDAP_GROUP_MAPPING = {
'cn=inventory,ou=Groups,dc=acme,dc=com': "inventory"
}

# LDAP Config - User
AUTH_LDAP_USER_USERNAME_ATTR = "uid"
AUTH_LDAP_USER_OBJECT_CLASS = "posixAccount"
AUTH_LDAP_USER_SEARCH_BASE = "ou=xx,ou=Internal,ou=Users,dc=acme,dc=com"

#AUTH_LDAP_USER_SEARCH_FILTER = '(&(objectClass={0})({1}=%(user)s))'.format(
AUTH_LDAP_USER_SEARCH_FILTER = '(&(objectClass=*)({0}=%(person)s)'.format(
AUTH_LDAP_USER_OBJECT_CLASS,
AUTH_LDAP_USER_USERNAME_ATTR
)

AUTH_LDAP_USER_FILTER = '(&(memberOf=CN=inventory,OU=Groups,dc=acme,dc=com))'

AUTH_LDAP_USER_SEARCH = LDAPSearch(
AUTH_LDAP_USER_SEARCH_BASE,
ldap.SCOPE_SUBTREE,
AUTH_LDAP_USER_SEARCH_FILTER
)

AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail",
}

# LDAP Config - Groups
AUTH_LDAP_MIRROR_GROUPS = True
AUTH_LDAP_GROUP_TYPE = PosixGroupType(name_attr="cn")
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
"cn=inventory,ou=Groups,dc=acme,dc=com",
ldap.SCOPE_SUBTREE,
'(objectClass=posixGroup)'
)

AUTH_LDAP_REQUIRE_GROUP = "cn=inventory,ou=Groups,dc=acme,dc=com"

AUTH_LDAP_USER_FLAGS_BY_GROUP = {
'is_superuser': 'cn=it,ou=Groups,dc=acme,dc=com'
}

AUTH_LDAP_FIND_GROUP_PERMS = True

### Environment

* Ralph version: 20201006.2
* Operating system: Ubuntu 18.04
* Method of installation: Docker

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.