nitmir / django-cas-server

A Django Central Authentication Service server implementing the CAS Protocol 3.0 Specification
GNU General Public License v3.0
132 stars 44 forks source link

Tips when using a custom Django User #62

Closed opobla closed 4 years ago

opobla commented 4 years ago

Hi!

I have extended the Django User Model from AbstractUser to create a custom one to suit my needs. One of them is that there is no username. Instead, the only credentials for my users will be email and password.

I have seen that at least DjangoAuthUser and so AuthUser strongly depends on a "username". The main goal of my project is to provide a CAS implementation, so I am wondering whether should I revert to the original Django User and try to overcome the username/email problem there somehow, or try to make the adjustments in django-cas-server. Can you give me any advice about this?

Thanks a lot. Óscar

nitmir commented 4 years ago

Hi The auth classes are designed to be extensible and for django-cas-server to be able to use pretty much any backend. Just write your own class inheriting from AuthUser using the email address instead of username and you should be good. Django-cas-server do not depend on the Django user model.

The username transmitted to the auth class is whatever the user typed in the login form.

opobla commented 4 years ago

Thanks @nitmir

Yes, I see now. I could also extend the default DjangoAuthUser and override the __init__ method, changing just the attribute used to find the user.