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

LDAP admin right after first login #2855

Closed
shomodj opened this issue Mar 18, 2016 · 10 comments
Closed

LDAP admin right after first login #2855

shomodj opened this issue Mar 18, 2016 · 10 comments
Labels
🔨 enhancement Make it better, faster status: needs feedback Tell me more about it

Comments

@shomodj
Copy link

shomodj commented Mar 18, 2016

When using LDAP with admin filter gogs will create a "local clone" LDAP user with admin parameter (modules/login.go:296) but if the user is not in the admin group at the time of the first login he/she is created without admin privileges.

But if you add that user later in admin group in LDAP, gogs will check if user is in admin group but it will not sync the data, so user will never be admin even if you add it in LDAP later.

Now this is a common case in big companies, first you create an user in LDAP, and then admin rights are added later per managers approval.

@unknwon unknwon added 🔨 enhancement Make it better, faster 🙇‍♂️ help wanted Need your help labels Mar 18, 2016
@jaydio
Copy link

jaydio commented Apr 4, 2016

This is indeed a problem. The admin filter should be applied on-demand meaning every time a user logs in. That's a typical use case for accessing a directory service as its optimized for read access.

@lafriks
Copy link
Contributor

lafriks commented May 6, 2016

Partially my pull request #3062 that does sync users with LDAP fixes it

@jonlundy
Copy link
Contributor

I have checked the LDAP logs when authenticating. It actually makes a query with the admin filter at the time of every login. But does not appear to use that result.

@jonlundy
Copy link
Contributor

I did a bit of digging. It looks like it's doing the LDAP search and returns IsAdmin in the result to func LoginViaLDAP in models/login_source.go but this function does not check if the user is already there and just blindly calls func CreateUser in models/user.go. I suppose if it were possible to attempt calling func UpdateUser it would fix this issue?

@unknwon
Copy link
Member

unknwon commented Mar 29, 2017

@jonlundy good point..!

@DMW007
Copy link

DMW007 commented May 13, 2017

That's a real problem which confused me too. Seems like there are currently only to ways to work around this bug:

  1. Manually add the admin permission. An acceptable workaround, but make the great LDAP filter for this relatively useless, since you have to change permissions on two places. This can result in errors, when someone forget it.
  2. Deleting the user in gogs: Not a real solution at all, since the user is already using Gogs

@unknwon unknwon added status: needs feedback Tell me more about it and removed 🙇‍♂️ help wanted Need your help labels May 21, 2017
@unknwon unknwon added this to the 0.12 milestone May 21, 2017
@unknwon
Copy link
Member

unknwon commented May 21, 2017

This is claimed to be fixed by merging #4405, please help test on develop branch.

@unknwon unknwon closed this as completed Jun 10, 2017
@matthijsvdr
Copy link

Is this working for anyone?
When i add an admin filter it always returns this error:

[ERROR] [...kg/auth/ldap/ldap.go:304 SearchEntry()] LDAP: Admin search failed: 0 entries

This even happens when the admin filter is the same as the user filter

User filter works, admin does not

user: (&(uid=%s)(memberOf=cn=users,cn=groups,cn=accounts,dc=EXAMPLE,dc=COM))
admin: (&(uid=%s)(memberOf=cn=admins,cn=groups,cn=accounts,dc=EXAMPLE,dc=COM))

@unknwon
Copy link
Member

unknwon commented Jun 27, 2017

@matthijsvdr hi, based on the https://gogs.io/docs/features/authentication, I think currently admin filter does not recognize %s placeholder.

@matthijsvdr
Copy link

@unknwon a that sucks :(

@unknwon unknwon removed this from the 0.13 milestone Nov 26, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 enhancement Make it better, faster status: needs feedback Tell me more about it
Projects
None yet
Development

No branches or pull requests

7 participants