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

Use UTF-8 encoding for client basic auth if requested #5845

Closed
mperktold opened this issue Dec 28, 2020 · 2 comments · Fixed by #5847
Closed

Use UTF-8 encoding for client basic auth if requested #5845

mperktold opened this issue Dec 28, 2020 · 2 comments · Fixed by #5847

Comments

@mperktold
Copy link

Jetty version: 9.4.35.v20201120
Java version: AdoptOpenJDK 11.0.9
OS type/version: Windows 10 64 bit

Description
When using the HttpClient with basic authentication, Jetty always encodes the credentials using ISO 8859:
https://github.com/eclipse/jetty.project/blob/cbdfaaa335904a7ecc2a7b20208de00f798a5e04/jetty-client/src/main/java/org/eclipse/jetty/client/util/BasicAuthentication.java#L89

While this is fine for a default charset, servers can use a special charset parameter of the WWW-Authenticate header to tell the client to encode the credentials using UTF-8, as specified here: https://tools.ietf.org/html/rfc7617#section-2.1

For being able to connect to servers that expect UTF-8, Jetty should honor the charset parameter.
Additionally, it should be possible to specify UTF-8 encoding when authenticating preemptively, e.g. by passing a Charset to the constructor of BasicResult.

sbordet added a commit that referenced this issue Dec 29, 2020
* Introduced get/setCharset in BasicAuthenticator on server-side.
* Looking for the "charset" parameter on the client-side, and if there, use it.
* Added test case.
* Code cleanups.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet
Copy link
Contributor

sbordet commented Dec 29, 2020

@mperktold can you try branch jetty-9.4.x-5845-basic_auth_charset to see if it works for you?

@mperktold
Copy link
Author

@sbordet works fine, thanks! 👍

sbordet added a commit that referenced this issue Dec 30, 2020
Don't use unicode sequences to please CheckStyle.

Signed-off-by: Simone Bordet <[email protected]>
sbordet added a commit that referenced this issue Dec 30, 2020
Disable CheckStyle check so that the unicode sequence in the test matches that in realm.properties.

Signed-off-by: Simone Bordet <[email protected]>
This was referenced Mar 10, 2021
This was referenced Mar 10, 2021
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 a pull request may close this issue.

2 participants