Allow empty usernames for BasicAuth
The RFCs around basic authentication don't explicitly disallow empty usernames. On the other hand usernames containing colons are, as colons are used to separate the username from the password.
This commit is contained in:
committed by
Rob Winch
parent
abe4420006
commit
4dee333a75
@@ -46,9 +46,9 @@ public class BasicAuthorizationInterceptor implements ClientHttpRequestIntercept
|
||||
* @param username the username to use
|
||||
* @param password the password to use
|
||||
*/
|
||||
public BasicAuthorizationInterceptor(String username, @Nullable String password) {
|
||||
Assert.hasLength(username, "Username must not be empty");
|
||||
this.username = username;
|
||||
public BasicAuthorizationInterceptor(@Nullable String username, @Nullable String password) {
|
||||
Assert.doesNotContain(username, ":", "Username must not contain a colon");
|
||||
this.username = (username != null ? username : "");
|
||||
this.password = (password != null ? password : "");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user