allegro / allegro/ralph

LDAP Authentication with OpenLDAP and Ralph3

Offen
#3,077 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
2.5k
Forks
593
Ø Merge
2 T. 9 Std.
Gemergte PRs (30 T.)
6

Beschreibung

Hi there,

before I start to pull my hair off - I should really start to ask for help. So here I am and really thankful for any advice.

## What do I want to archive?
User Authentication using OpenLDAP

## What did I do?
Followed the manual from [here](https://ralph-ng.readthedocs.io/en/latest/installation/configuration/).

### modified ralph.settings.prod.py
...
from ralph.accounts.ldap import MappedGroupOfNamesType

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

...

# LDAP Config - Server
AUTH_LDAP_START_TLS = True
AUTH_LDAP_SERVER_URI = "ldap://ldap.company.domain"
AUTH_LDAP_BIND_DN = "uid=ldap-account,ou=systems,ou=people,dc=company,dc=domain"
AUTH_LDAP_BIND_PASSWORD = "mypassword"
AUTH_LDAP_PROTOCOL_VERSION = 3

# LDAP Config - User
AUTH_LDAP_USER_USERNAME_ATTR = "uid"
AUTH_LDAP_USER_OBJECT_CLASS = "posixAccount"
AUTH_LDAP_USER_SEARCH_BASE = "ou=people,dc=company,dc=domain"
AUTH_LDAP_USER_SEARCH_FILTER = '(&(objectClass={0})({1}=%(user)s))'.format(
AUTH_LDAP_USER_OBJECT_CLASS,
AUTH_LDAP_USER_USERNAME_ATTR
)

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",
"employee_id": "employeeNumber",
"location": "roomNumber",
"city": "st",
"company": "o",
"cost_center": "CostCenter",
}

# LDAP Config - Groups
AUTH_LDAP_MIRROR_GROUPS = True
AUTH_LDAP_GROUP_TYPE = MappedGroupOfNamesType(name_attr="cn")
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
"ou=groups,dc=company,dc=domain",
ldap.SCOPE_SUBTREE,
'(objectClass=groupOfNames)'
)
AUTH_LDAP_GROUP_MAPPING = {
'cn=employees,ou=global,ou=groups,dc=company,dc=domain': "active",
}

## Whats working?
The user is being created with all mapped Attributes from `AUTH_LDAP_USER_ATTR_MAP`.

## Whats not?
The group membership of the Ralph-Group `active` is **not** being set during the login process.

## What do you tried out?
I made several debug-related changes to Ralph and came to the conclusion, that `MappedGroupOfNamesType` seems to match against the `memberOf` Attribute of the LDAPUser. Which is not set in our environment (as mentioned in the Title, we use an OpenLDAP). So this might be not the solution.

`ralph ldap_sync` does also have no effect (no groups are synced).

I played arround with the `AUTH_LDAP_GROUP_TYPE = GroupOfNamesType(name_attr="cn")` setting and got all groups of my LDAP synced into Ralph. But then, I could not assign the user to the existing group `active`. If I set the attribute using `AUTH_LDAP_USER_FLAGS_BY_GROUP`, the Flag will got overridden by the signal `staff_superuser_populate`.

## Why are you ask in second person?
Thought it helps to structurize the setup. :P

Best Regards and thank you in advance,
Christopher

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.