Polish BasicAuthenticationConverter
This reverts to the old behavior from BasicAuthenticationFilter. Specifically, if a token has an empty password, it still parses a username and an empty String password. Issue gh-7025
This commit is contained in:
@@ -99,4 +99,16 @@ public class BasicAuthenticationConverterTests {
|
||||
converter.convert(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertWhenEmptyPassword() {
|
||||
String token = "rod:";
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
|
||||
UsernamePasswordAuthenticationToken authentication = converter.convert(request);
|
||||
|
||||
verify(authenticationDetailsSource).buildDetails(any());
|
||||
assertThat(authentication).isNotNull();
|
||||
assertThat(authentication.getName()).isEqualTo("rod");
|
||||
assertThat(authentication.getCredentials()).isEqualTo("");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user