Skip to content

Commit

Permalink
fix: escape properly double quote for password on HTTP Provider
Browse files Browse the repository at this point in the history
fixes AM-4687
  • Loading branch information
leleueri committed Jan 21, 2025
1 parent 99687d5 commit 4a1fdc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public static String sanitize(String credentials, String requestBody, List<HttpH
// if HTTP headers contains Content-Type == application/json
// it means we except a json body content
if (contentTypeHeaders.contains(MediaType.APPLICATION_JSON)) {
return credentials.replace("\"", "\\\\\"");
return credentials.replace("\"", "\\\"");
}

// if we can't rely on http headers, look into the body
if (contentTypeHeaders.isEmpty() && requestBody != null && (requestBody.startsWith("{") || requestBody.startsWith("["))) {
return credentials.replace("\"", "\\\\\"");
return credentials.replace("\"", "\\\"");
}
return credentials;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public void shouldLoadUserByUsername_authentication() {
TestObserver<User> testObserver = authenticationProvider.loadUserByUsername(new Authentication() {
@Override
public Object getCredentials() {
return "johndoe";
return "johndoepassword\"";
}

@Override
public Object getPrincipal() {
return "johndoepassword";
return "johndoe";
}

@Override
Expand All @@ -113,12 +113,12 @@ public void shouldLoadUserByUsername_authentication_badCredentials() {
TestObserver<User> testObserver = authenticationProvider.loadUserByUsername(new Authentication() {
@Override
public Object getCredentials() {
return "johndoe";
return "johndoepassword";
}

@Override
public Object getPrincipal() {
return "johndoepassword";
return "johndoe";
}

@Override
Expand Down

0 comments on commit 4a1fdc6

Please sign in to comment.