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

User Names with commas break email sending #9724

Open
Gunsmithy opened this issue May 14, 2024 · 0 comments
Open

User Names with commas break email sending #9724

Gunsmithy opened this issue May 14, 2024 · 0 comments

Comments

@Gunsmithy
Copy link
Contributor

Gunsmithy commented May 14, 2024

Describe the bug
It appears as though when a user's name contains a comma, such as when mapping an Azure AD name to their name in "FamilyName, GivenName" format, emails cannot be sent to the user. See the below stack trace for an example. Editing the user's name to remove the last name and comma fixed the emails. This occurs for both emails sent during the enrollment flow as well as when attempting to send via the user detail page. To be clear, this is the Name, not Username. Presumably other special characters can break this parsing too but I have not tested.

To Reproduce
Steps to reproduce the behavior:

  1. Have a user set up with a name such as "Smith, John"
  2. Click "Email recovery link" and select a flow
  3. See in the event log that an exception occurred and no email was sent

Expected behavior
I expect a user's name format to not impact the ability to send emails. If there are certain restrictions for names, then they should be restricted at user write, not after when trying to send an email. Is the user's name necessary for sending emails? Can we address to just their email address and omit the name?

Actually, after trying out copying an email address from Gmail, I got the following kind of text in my clipboard:
"email@redacted.com" <email@redacted.com>
So perhaps the name just needs to be put in quotes and those are missing?

Screenshots
If applicable, add screenshots to help explain your problem.

Logs

Stacktrace from authentik
Traceback (most recent call last):
  File "/ak-root/venv/lib/python3.12/site-packages/celery/app/trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/ak-root/venv/lib/python3.12/site-packages/celery/app/trace.py", line 736, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ak-root/venv/lib/python3.12/site-packages/celery/app/autoretry.py", line 38, in run
    return task._orig_run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/authentik/stages/email/tasks.py", line 89, in send_mail
    backend.send_messages([message_object])
  File "/ak-root/venv/lib/python3.12/site-packages/django/core/mail/backends/smtp.py", line 136, in send_messages
    sent = self._send(message)
           ^^^^^^^^^^^^^^^^^^^
  File "/ak-root/venv/lib/python3.12/site-packages/django/core/mail/backends/smtp.py", line 151, in _send
    sanitize_address(addr, encoding) for addr in email_message.recipients()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ak-root/venv/lib/python3.12/site-packages/django/core/mail/message.py", line 92, in sanitize_address
    raise ValueError(
builtins.ValueError: Invalid address; only Smith could be parsed from "Smith, John <email@redacted.com>"

Version and Deployment (please complete the following information):

  • authentik version: 2024.4.2
  • Deployment: helm

Additional context
Add any other context about the problem here.

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

No branches or pull requests

1 participant