Skip to content

Commit

Permalink
ISSUE-603: Minor: Registry is failing to parse the doAs user (#604)
Browse files Browse the repository at this point in the history
* ISSUE-603: Minor: Registry is failing to parse the doAs user

* Picking the last doAs user as knox attaches the query params at the end.
  • Loading branch information
guruchai authored and raju-saravanan committed Oct 10, 2019
1 parent 12324ac commit 754af5d
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -450,26 +450,22 @@ public boolean shouldAuthenticate(HttpServletRequest request) {
}

protected static String getDoasUser(HttpServletRequest request) {
String doAsUser = null;
String doAsUser = "";
String queryString = request.getQueryString();
if (queryString != null) {
String[] pairs = queryString.split(QUERY_STRING_DELIMITER);
try {
for (String pair : pairs) {
if (pair.startsWith(DOAS_QUERY_STRING)) {
doAsUser = URLDecoder.decode(pair.substring(DOAS_QUERY_STRING.length()), "UTF-8").trim();
if (doAsUser.isEmpty()) {
return null;
}
}
break;
}
} catch (UnsupportedEncodingException ex) {
//We are providing "UTF-8". This should not be happening ideally.
LOG.error("Invalid encoding provided.");
}
}
return doAsUser;
return doAsUser.isEmpty() ? null : doAsUser;
}

/**
Expand Down

0 comments on commit 754af5d

Please sign in to comment.