Django Windows Authentication problems

I am working on a new django site and I want to setup sso, which works through iis.
The problem is that the account gets named DomainName\Username.
When I go into the admin page and go to modify the account like make it a super user and or adjusting email address/ First Name/ Last it says that it contains an unauthorized character referencing the “” and having the domain name in it is not clean looking when you reference the user.
Any ideas how to remove the DomainName\ from the username?

Are you doing this through the REMOTE_USER facility in Django, or are you using a different mechanism for handling this?

Either way, I think you’ve got a couple different options.

If what you really want to do is remove the DomainName from the Django-version of the username, you could subclass RemoteUserMiddleware and replace the process_request method with one that strips the domain name from the beginning of the username.

Or, another option may be to subclass the User object with a custom user object that allows the back-slash (\) character to be valid in the username field.

(There may be other ways as well, but I can’t think of any at the moment.)

Ken

I am using REMOTE_USER, Ill have to look into creating a subclass for RemoteUserMiddleware.
Thanks for giving me a direction to look into.

I’d highly recommend Django-auth-ADFS for ADFS / SSO. :slight_smile:

thanks @JonasKs if that works it would be great as we are looking at setting up federated services for a while now for other softwares.

It works wonders! We use it for both Django front end and external React front ends, since it has Oauth2 auth with JWT tokens for DRF APIs, there’s no limitations. It works with Azure AD too.