KEYCLOAK-5352 Basic Auth fails if password contains a ':'

This commit is contained in:
Xiaojian Liu 2017-11-07 21:24:09 -06:00 committed by Stian Thorgersen
parent e1af9f133f
commit 9ff22f596d
2 changed files with 5 additions and 5 deletions

View file

@ -71,11 +71,11 @@ public class BasicAuthRequestAuthenticator extends BearerTokenRequestAuthenticat
AccessTokenResponse atr=null;
try {
String userpw=new String(Base64.decode(tokenString));
log.debug("Username and password string for basic auth is: " + userpw);
int seperatorIndex = userpw.indexOf(":");
String user = userpw.substring(0, seperatorIndex);
String pw = userpw.substring(seperatorIndex + 1);
log.debug("user: " + user);
log.debug("pw: " + pw);
log.debug("Username for token is: " + user + ", password is: " + pw);
atr = getToken(user, pw);
tokenString = atr.getToken();
} catch (Exception e) {

View file

@ -98,12 +98,12 @@ public class HttpBasicAuthenticator implements Authenticator {
try {
String val = new String(Base64.decode(credentials));
log.debug("Username and password string is: " + val);
int seperatorIndex = val.indexOf(":");
if(seperatorIndex == -1) return null;
if(seperatorIndex == -1) return new String[]{val};
String user = val.substring(0, seperatorIndex);
String pw = val.substring(seperatorIndex + 1);
log.debug("user: " + user);
log.debug("pw: " + pw);
log.debug("Resolved username is: " + user + ", password is: " + pw);
return new String[]{user,pw};
} catch (final IOException e) {
throw new RuntimeException("Failed to parse credentials.", e);