Im using ldap for user authentication in django 2.0, and i need to create an endpoint to authenticate user from another application just passing the username to then redirect them. Isnt yet something to retrieve the raw password?
Asked
Active
Viewed 342 times
-1
-
Did you check [this](https://stackoverflow.com/a/9572182/5312750)? – Sachin Aug 30 '18 at 15:46
-
How are you planning on passing the username? And they would be creating a password not retrieving a password correct? – Braden Holt Aug 30 '18 at 15:48
-
Just an fyi, you generally don't retrieve a password, you supply a password and retrieve an ephemeral unique string / token. For instance, when a user authenticates to another application with Facebook they don't use a password. – Braden Holt Aug 30 '18 at 15:55
-
ldap3 requires raw password, I've set the endpoint (url and view) to be receiving the username as a request parameter and at the view, then proceed query the User model using the username parameter to authenticate the user. – Jcc.Sanabria Aug 30 '18 at 15:58
-
Is this only going to be happening once when the user registers? Or do you need the user to be able to login with this as well. – Braden Holt Aug 30 '18 at 16:03
-
login with this as well, the registration is automatically set at the first login – Jcc.Sanabria Aug 30 '18 at 16:08
-
Braden, do you have something to help me? -.- – Jcc.Sanabria Aug 30 '18 at 16:13
-
Have you tried looking at how Facebook does this?https://developers.facebook.com/docs/facebook-login / https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2 – Braden Holt Aug 30 '18 at 16:20
-
It is a nice security schema, but it is not what Im looking for or I need for this situation. This security layer could be in a future development phase. – Jcc.Sanabria Aug 30 '18 at 17:47
1 Answers
0
Using the **encrypt**
method imported from **django_cryptography.fields**
, define a password attribute for the model LdapProfile (model related to User to store the user profile on ldap) and then, use this password attribute in ldap.authenticate(username, password).
password = encrypt(models.CharField(
max_length=255,
null=True,
blank=True
))

Jcc.Sanabria
- 629
- 1
- 12
- 22