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

transport: Accept international email address when making auth headers #5178

Merged
merged 1 commit into from
Feb 17, 2023

Conversation

chrisbobbe
Copy link
Contributor

Anders points out on CZO [1] that non-ASCII UTF-8 characters are now
allowed in email addresses:

From RFC 6532 §3.2:
“The preceding changes mean that the following constructs now
allow UTF-8: … 4. Domains.”

So, we need to accept those characters. Otherwise, you could have a
valid email address and be unable to make any authenticated API
requests in the app.

Use our handy helper function for base64 encoding that accepts UTF-8
as input.

[1] https://chat.zulip.org/#narrow/stream/378-api-design/topic/Non-ASCII.20email.2Fapi_key.3F/near/1300579

@chrisbobbe chrisbobbe added severe: crash The app quits, or stops responding. a-i18n Translation, localization, internationalization labels Dec 22, 2021
@chrisbobbe chrisbobbe requested a review from gnprice December 22, 2021 21:47
@chrisbobbe chrisbobbe force-pushed the pr-utf8-auth-headers branch from fca7a84 to 128e3c8 Compare February 9, 2023 21:04
@chrisbobbe
Copy link
Contributor Author

Just rebased, resolving a conflict in url-test.js.

The base64.encode function requires all the code points in its input
to be in the range U+0000..U+00FF.  Effectively it requires that it
can type-pun the string as a string of bytes, because the Base64
encoding itself is defined on sequences of bytes.

But email addresses aren't restricted to that range, and haven't
been for a long time.  RFC 6532, "Internationalized Email Headers",
dates to 2012.  So some users have email addresses containing
code points outside that range, and we should handle them so that
those users are able to use the app.

Here in the HTTP basic-auth header, one is generally supposed to do
so (though the spec stops short of quite mandating this) by encoding
the user-id and password -- which for Zulip means the user's email
and API key -- in UTF-8, and then Base64-encoding those bytes.
And indeed that's what the Zulip server expects.  See discussion:
  https://chat.zulip.org/#narrow/stream/378-api-design/topic/Non-ASCII.20email.2Fapi_key.3F/near/1300660

So do that here.

[greg: wrote new commit message]
@gnprice gnprice force-pushed the pr-utf8-auth-headers branch from 128e3c8 to aa470d2 Compare February 17, 2023 23:04
@gnprice gnprice merged commit aa470d2 into zulip:main Feb 17, 2023
@gnprice
Copy link
Member

gnprice commented Feb 17, 2023

Thanks! Wrote a new commit message, and merging.

@chrisbobbe
Copy link
Contributor Author

Thank you!

@chrisbobbe chrisbobbe deleted the pr-utf8-auth-headers branch February 17, 2023 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-i18n Translation, localization, internationalization severe: crash The app quits, or stops responding.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants