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

More LDAP auth patches #1669

Merged
merged 6 commits into from
Jan 4, 2025
Merged

Conversation

marschap
Copy link
Contributor

@marschap marschap commented Jan 3, 2025

Hi,

here's another round of LDAP auth patches
They deal with issues not dealt with in the previous round:

  • avoid code duplication by calculating attributes to query in __init__()

  • allow using LDAP authentication also to servers that do not know the memberOf attribute
    by querying it only if ldap_load_groups is True

  • introduce config option ldap_groups_attribute that allows us to configure the groups attribute name
    instead of having it being hard coded to memberOf

  • get rid of ldap_load_groups config option. - having ldap_groups_attribute being unset
    resp. being set to a specific attribute name has the exact same effect

  • stop fiddling around with getting the RDN value of the groups attributes returned,
    and instead use the LDAP modules' helper functions foreseen for this purpose.
    In addition, this gives us a bit more flexibility with the ldap_groups_attribute: we can use attribute with non-DN syntax too.
    As radicale does not rely on on the DN syntax, but only takes the RDN value anyway, this is no limitation, but a real extension

    Please consider incorporating them into mainline radicale

Remove code duplication by factoring out the calculation of the
LDAP query attributes out of _login2() resp. _login3() into __init__().
Ask for the 'memberOf' attribute to be returned in the user query only
if 'ldap_load_groups' is set to True.

This fixes the issue that currently LDAP authentication can only be used on
LDAP servers that know this non-standard (it's an Active Directory extension)
attribute.
Other LDAP servers either do not necessarily have the group memberships
stored in the user object (e.g. OpenLDAP), or use different attributes for
this purpose (e.g. Novell eDirectory uses 'groupMembership')
@pbiering pbiering added this to the 3.4.0 milestone Jan 3, 2025
@pbiering pbiering added the auth:ldap Authentication LDAP label Jan 3, 2025
DOCUMENTATION.md Outdated
@@ -932,14 +932,20 @@ The LDAP attribute whose value shall be used as the user name after successful a

Default: not set, i.e. the login name given is used directly.

##### ldap_load_groups
#### ldap_groups_attribute
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have 5x #, please fix also current buggy entry:

#### ldap_user_attribute

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also extend the changelog

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done - thanks for the cross-check

This attribute is supposed to hold the group membership information
if the config option 'ldap_load_groups' is True.
If not given, it defaults to 'memberOf' for Active Directory.

Introducing this options allows one to use radicale's LDAP auth with groups
even on LDAP servers that keep their group memberships in a different attribute
than 'memberOf', e.g. Novell eDirectory which uses 'groupMembership'.
The same effect can be achieved using the option 'ldap_groups_attribute' alone,
if it's default becomes unset instead of 'memberOf'

Benefit: one config option less to deal with.

While at it, also fix header level for 'ldap_user_attribute' in documentation.
Use helper methods from the LDAP modules to get individual elements
(like in our case the RDN value) out of attributes with DN syntax
in a standard compliant way instead fiddling around ourselves.

If these methods fail, fall back to using the whole attribute value,
which allows us to also use attributes with non-DN syntax for groups
and permissions.
@marschap marschap force-pushed the more-LDAPauth-patches branch from 2c297c7 to d6c4e64 Compare January 3, 2025 19:50
@pbiering
Copy link
Collaborator

pbiering commented Jan 3, 2025

Please add changelog entry related to changed option

Copy link
Collaborator

@pbiering pbiering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Collaborator

@pbiering pbiering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

@pbiering pbiering merged commit c853ec4 into Kozea:master Jan 4, 2025
19 checks passed
@marschap marschap deleted the more-LDAPauth-patches branch January 4, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth:ldap Authentication LDAP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants