Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 18, 2026. It is now read-only.

Improving the LDAP implementation#615

Merged
stonith404 merged 8 commits into
stonith404:mainfrom
WolverinDEV:ldap
Sep 27, 2024
Merged

Improving the LDAP implementation#615
stonith404 merged 8 commits into
stonith404:mainfrom
WolverinDEV:ldap

Conversation

@WolverinDEV
Copy link
Copy Markdown
Contributor

@WolverinDEV WolverinDEV commented Sep 25, 2024

This PR aims to address flaws encountered in the initial, rudimentary LDAP implementation. The following improvements have been made:

  • Added PV_LOG_LEVEL environment variable to set backend log level, enabling verbose output for better troubleshooting.
  • Implemented more verbose logging to help debug LDAP-related issues.
  • Relaxed the LDAP username regex to allow more flexibility.
  • Fixed issues with user logins containing special characters within the user's DN by switching to ldapts.
  • Made the "memberOf" and email attribute names configurable.
  • Properly handle email-like login credentials in LDAP (instead of completely disabling email login when LDAP is enabled).
  • sync LDAP users' emails properly (🐛 Bug Report: mail field for LDAP users is not saved #601).

With this PR, the remaining LDAP-related issues should either be resolved or significantly easier to troubleshoot.

@WolverinDEV WolverinDEV marked this pull request as ready for review September 26, 2024 06:07
@dnielso5
Copy link
Copy Markdown

As posted in #582 i can confirm this fixes the issues i was having.

Copy link
Copy Markdown
Owner

@stonith404 stonith404 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, that's great! Please see my other comment below.

Additionally, there was mentioned that setting an admin group doesn't work. For me the code looks fine, this is probably a configuration mistake, right?

? t("signup.input.username.placeholder")
: t("signin.input.email-or-username.placeholder")
}
label={t("signin.input.email-or-username")}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Because of const ldapUsername = dto.username || dto.email; in backend/src/auth/auth.service.ts the user can't sign in with email, just with an username that looks like an email. Shouldn't we display the label "Username" instead of "Email or username" in that case?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I have not had time to test the admin group login yet, that was regiolisas. The dev branch made it appear that a non signed in user could upload i had to revert back to the main branch. i dont have a test system only production. :(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because of const ldapUsername = dto.username || dto.email; in backend/src/auth/auth.service.ts the user can't sign in with email, just with an username that looks like an email. Shouldn't we display the label "Username" instead of "Email or username" in that case?

Well, good question. I think neither of the proposed solutions would be adequate, as we don't always know when someone uses LDAP if they are expecting to log in with a username or an email (like in the case of @Esperenza84, for example).

When looking at how GitLab handles this, they’ve taken a very clean approach by explicitly separating both types of login. Maybe that could be an applicable solution here as well?
image

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Oh, I mistakenly believed that signing in “normally” (without LDAP) is disabled when LDAP is enabled. However, I just realized that this isn’t the case. In such a scenario, it would be logical to display the “email or username” label.

The implementation of GitLab is indeed clean, but I believe we could create a separate pull request in the future if this feature is requested.

What do think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes absolutely, this seems to be out of the scope of this PR :)

@stonith404 stonith404 merged commit 3310fe5 into stonith404:main Sep 27, 2024
@stonith404
Copy link
Copy Markdown
Owner

Thanks again for your contribution :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants