Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new authentication backend for case-insensitive emails #31

Merged
merged 8 commits into from
Apr 2, 2015

Conversation

cbg
Copy link

@cbg cbg commented Mar 25, 2015

This is a possible solution to #11.

# In settings.py
AUTHENTICATION_BACKENDS = ('authtools.backends.CaseInsensitiveEmailBackend',)
"""
def authenticate(self, username=None, password=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an app that requires me to pass in the request to the authenticate calls.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rockymeza Are you saying this because of the method signature?

If so, django handles the TypeError https://github.com/django/django/blob/master/django/contrib/auth/__init__.py#L69

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He wants the lower() to be called, though, so this should just be changed to be **credentials instead.

@cbg
Copy link
Author

cbg commented Mar 25, 2015

Updated

@cbg
Copy link
Author

cbg commented Mar 25, 2015

We also have a couple of options. This new backend assumes its user has already somehow enforced case-insensitivity of the email address usernames. We either need to add a note to the docstring of the backend, or simply disallow anyone from creating case-sensitive email address usernames (this would be done via UserCreationForm). Opinions welcome.

@pipermerriam
Copy link

Not sure I see any reasonable way to enforce this without some grossness. I'd lean towards the backend docstring and something in the docs.

@cbg
Copy link
Author

cbg commented Mar 26, 2015

I added a note of caution for potential users of this new backend.

A word of caution. Use of this backend presupposes a way to ensure that users cannot
create usernames that differ only in case (e.g., [email protected] and [email protected]). It is
advised that you use this backend in conjunction with the
EmailInsensitiveCreateUserForm provided in the forms module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nitpicky, but it would be nice to just provide the qualname for the form:

authtools.forms.EmailInsensitiveCreateUserForm

It's just so that I don't have to parse "the forms module"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants