-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Added LDAP authentication #110
Conversation
So far I've tested this against a FreeIPA running on Rocky 8 in ldap. I still need to test against Active Directory and in ldaps @perara can you tell me the following:
Thank you, |
Excellent work! Tell me when you feel this is ready to get pushed in, and I'll take it for a test ride. Have to set up some LDAP server to test it out. For your questions:
For example:
The above would enable the administrator to login using their LDAP account and to further map wg-manager roles to the corresponding LDAP roles. One could also have local username:password fallback, but in that case I would like the administrator to specify that through env variables such as:
For the latter, on initial setup, the user should be queried with a request to change the password on first login, but I suppose this belongs into its own issue. Again good work, and I'd love to see this get merged in when your done :D |
Hey,
So what I usually do is, all users that are authenticated using external systems don't have a password on the built in system. In that way, the built in authentication will always fail (assuming that the password is required on the login endpoint) and fallback to the external one, in this case LDAP. And we can also disable the password reset on users with password as NULL, since the password reset must happen on the external system.
I usually keep a built in system for 2 reasons:
Independently of the roles system, I think that the best way is to keep it simple, the Group/OU X on LDAP matches with the role/group X on wg-manager. This setting can either be set on the database or in the environment variables. Either way, we can merge this without the roles map and when the roles system is ready we do implementation.
Do you wann't me to change the variables from LDAP_* to AUTH_LDAP_* and add the AUTH_LOCAL_ENABLED? btw, this is already working with AD and ldaps |
If the builtin authentication fails, checks the username and password against a LDAP server Allow to create user without password since we don't store the user password inside the database. Every function that has the middleware.authengine decorator will be used as authentication engine. The order of the engines is based on the value of sequence, lower sequences go first
Ok so apart from the roles thing, this is ready for merge. I've squashed the commits into a single one. Also, as a side note, before trying, sync the master and dev branches, since the master has the fix to create users. If you want, there are the flags that I used to test this: FreeIPA: AUTH_LDAP_ENABLED="1" AUTH_LDAP_SERVER="ipa.wireguard.local" AUTH_LDAP_BASE="cn=users,cn=accounts,dc=wireguard,dc=local" AUTH_LDAP_FILTER="(uid=%s)" AUTH_LDAP_USER="uid=admin,cn=users,cn=accounts,dc=wireguard,dc=local" AUTH_LDAP_PASSWORD="adminpassword" AUTH_LDAP_SECURITY="SSL" AUTH_LDAP_SECURITY_VALID_CERTIFICATE="0" uvicorn main:app ActiveDirectory: AUTH_LDAP_DOMAIN="win" AUTH_LDAP_SERVER="1" AUTH_LDAP_SERVER="dc.win.wireguard.local" AUTH_LDAP_BASE="CN=Users,DC=win,DC=wireguard,DC=local" AUTH_LDAP_FILTER="(samAccountName=%s)" AUTH_LDAP_USER="win\wireguard" AUTH_LDAP_PASSWORD="P455sW0rd!" LDAP_ACTIVEDIRECTORY="1" AUTH_LDAP_SECURITY="SSL" AUTH_LDAP_SECURITY_VALID_CERTIFICATE="0" uvicorn main:app The AUTH_LDAP_SECURITY_VALID_CERTIFICATE can be set to 1 if you OS trusts the SSL cert for ldaps |
Excellent work! Merged it in! |
Added LDAP authentication
Added LDAP authentication
If the builtin authentication fails,
checks the username and password
againts a LDAP server