Skip to content

Instantly share code, notes, and snippets.

@yannbriancon
Last active June 10, 2019 18:31
Show Gist options
  • Save yannbriancon/63798c31fb4249b5e790a8f3625d6736 to your computer and use it in GitHub Desktop.
Save yannbriancon/63798c31fb4249b5e790a8f3625d6736 to your computer and use it in GitHub Desktop.
Update custom Django authentication backend to get the credentials from the query strings
import ...
class AuthenticationBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
# Get credentials from the query strings
username = request.GET.get('username')
password = request.GET.get('password')
# Check that the user can authenticate in the LDAP using its username and password
if get_LDAP_user(username, password) is None:
return None
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment