[KEYCLOAK-12412] - Policy enforcer should consider charset when comparing the content-type of the request

This commit is contained in:
Pedro Igor 2019-12-12 18:53:55 -03:00 committed by Stian Thorgersen
parent aceb123242
commit 3bd193acd7
2 changed files with 12 additions and 0 deletions

View file

@ -102,6 +102,8 @@ public class RequestPlaceHolderResolver implements PlaceHolderResolver {
if (contentType == null) {
contentType = "";
} else if (contentType.indexOf(';') != -1){
contentType = contentType.substring(0, contentType.indexOf(';')).trim();
}
InputStream body = request.getInputStream(true);

View file

@ -248,6 +248,16 @@ public class ClaimInformationPointProviderTest extends AbstractKeycloakTest {
assertEquals(2, claims.get("individualRoles").size());
assertEquals("{\"roleSpec\":2342,\"roleId\":4234}", claims.get("individualRoles").get(0));
assertEquals("{\"roleSpec\":4223,\"roleId\":523}", claims.get("individualRoles").get(1));
headers.put("Content-Type", Arrays.asList("application/json; charset=utf-8"));
httpFacade = createHttpFacade(headers, new ByteArrayInputStream(treeNode.toString().getBytes()));
claims = getClaimInformationProviderForPath("/claims-from-body-json-object", "claims").resolve(httpFacade);
assertEquals(1, claims.size());
assertEquals(2, claims.get("individualRoles").size());
assertEquals("{\"roleSpec\":2342,\"roleId\":4234}", claims.get("individualRoles").get(0));
assertEquals("{\"roleSpec\":4223,\"roleId\":523}", claims.get("individualRoles").get(1));
}
@Test