I'm creating a web services that use JWT Auth. I'm using django-rest-framework-jwt for that. I want my users could authenticate using their ldap accounts. I have found that there's a Django authentication backend that authenticates against an LDAP service. The function that does the authentication in django-rest-framework-jwt is coded like this :
def authenticate_credentials(self, payload):
try:
user_id = payload.get('user_id')
if user_id:
user = User.objects.get(pk=user_id, is_active=True)
else:
msg = 'Invalid payload'
raise exceptions.AuthenticationFailed(msg)
except User.DoesNotExist:
msg = 'Invalid signature'
raise exceptions.AuthenticationFailed(msg)
return user
The function looks in the User model to authenticate the user. I think that even if I setup the ldap backend, it will never work. Am I right? If yes what can I change to be able to use JWT Auth and be able to authenticate against LDAP service?