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

feat: endpoint for imapd to authenticate against#5295

Merged
merged 3 commits into from Mar 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
fix: be stricter in matching User
  • Loading branch information
rjsparks committed Mar 13, 2023
commit aebd8dc7aa2d5f4d7ad2e46c3ecc2da09a05abc9
10 changes: 5 additions & 5 deletions ietf/api/views.py
Expand Up @@ -414,15 +414,15 @@ def directauth(request):
if not is_valid_token("ietf.api.views.directauth", authtoken):
return HttpResponse(json.dumps(dict(result="failure",reason="invalid authtoken")), content_type='application/json')

user = User.objects.filter(username__iexact=username).first()
# The following would be consistent with auth everywhere else in the app, but until we can map users well
user_query = User.objects.filter(username__iexact=username)

# Matching email would be consistent with auth everywhere else in the app, but until we can map users well
# in the imap server, people's annotations are associated with a very specific login.
# If we get a second user of this API, add an "allow_any_email" argument.
# if not user:
# user = Email.objects.filter(address__iexact=username).first().person.user


# Note well that we are using user.username, not what was passed to the API.
if user and authenticate(username = user.username, password = password):
if user_query.count() == 1 and authenticate(username = user_query.first().username, password = password):
return HttpResponse(json.dumps(dict(result="success")), content_type='application/json')

return HttpResponse(json.dumps(dict(result="failure", reason="authentication failed")), content_type='application/json')
Expand Down