Skip to content

Allow specifying the charset to use in ExchangeFilterFunctions#basicAuthentication#36777

Closed
kzander91 wants to merge 1 commit into
spring-projects:mainfrom
kzander91:basic-auth-charset
Closed

Allow specifying the charset to use in ExchangeFilterFunctions#basicAuthentication#36777
kzander91 wants to merge 1 commit into
spring-projects:mainfrom
kzander91:basic-auth-charset

Conversation

@kzander91
Copy link
Copy Markdown
Contributor

This PR adds support for specifying the charset to use for encoding the credentials in ExchangeFilterFunctions#basicAuthentication.

I recently noticed that the existing method uses ISO-8859-1 to encode the credentials. In my app, this caused authentication failures when calling an API protected by Spring Security with a password that contains multi-byte characters. Spring Security uses UTF-8 by default to decode the credentials (see https://github.com/spring-projects/spring-security/blob/ee35c2c9ccd9f57d279d6bdef61d21c750bef15e/web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationConverter.java#L49).

@kzander91 kzander91 force-pushed the basic-auth-charset branch 2 times, most recently from 5e02412 to 414a955 Compare May 11, 2026 10:40
@kzander91 kzander91 marked this pull request as draft May 11, 2026 10:41
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 11, 2026
@kzander91 kzander91 force-pushed the basic-auth-charset branch 3 times, most recently from 778a8a4 to d9b1843 Compare May 11, 2026 10:49
@kzander91 kzander91 marked this pull request as ready for review May 11, 2026 10:55
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label May 11, 2026
@sbrannen
Copy link
Copy Markdown
Member

Indeed, BasicAuthenticationInterceptor and HttpHeaders.encodeBasicAuth() both already support a Charset.

…uthentication.

Signed-off-by: Kai Zander <61500114+kzander91@users.noreply.github.com>
@kzander91 kzander91 force-pushed the basic-auth-charset branch from d9b1843 to d14e6a6 Compare May 11, 2026 11:26
@kzander91
Copy link
Copy Markdown
Contributor Author

kzander91 commented May 11, 2026

@sbrannen I just noticed that the new @since tag was incorrect, I have just pushed a fix (7.0 -> 7.1).

@sbrannen sbrannen self-assigned this May 11, 2026
@sbrannen sbrannen added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 11, 2026
@sbrannen sbrannen added this to the 7.0.8 milestone May 11, 2026
@sbrannen
Copy link
Copy Markdown
Member

@sbrannen I just noticed that the new @since tag was incorrect, I have just pushed a fix (7.0 -> 7.1).

We actually decided to include this in 7.0.x. 😉

sbrannen added a commit that referenced this pull request May 20, 2026
@sbrannen sbrannen closed this in 4bb20ea May 20, 2026
@sbrannen
Copy link
Copy Markdown
Member

This has been merged into 7.0.x and main in 4bb20ea and slightly revised in 1e843fd.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants