Skip to content

Commit

Permalink
KEYCLOAK-14038: Re-allow special characters for Roles only
Browse files Browse the repository at this point in the history
  • Loading branch information
ssilvert committed May 20, 2020
1 parent c057b99 commit 13d0491
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.keycloak.utils.ReservedCharValidator;

/**
* @resource Roles
Expand Down Expand Up @@ -136,8 +135,6 @@ public Response createRole(final RoleRepresentation rep) {
if (rep.getName() == null) {
throw new BadRequestException();
}

ReservedCharValidator.validate(rep.getName());

try {
RoleModel role = roleContainer.addRole(rep.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.ws.rs.BadRequestException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -89,12 +88,6 @@ public void testAddRole() {
assertTrue(hasRole(rolesRsc, "role1"));
}

@Test(expected = BadRequestException.class)
public void testAddRoleWithReservedCharacter() {
RoleRepresentation role1 = makeRole("r&ole1");
rolesRsc.create(role1);
}

@Test
public void testRemoveRole() {
RoleRepresentation role2 = makeRole("role2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,6 @@ public void testAddRoleWithLongName() {
assertNotNull(realmRolesPage.table().findRole(name));
}

// KEYCLOAK-12768: Certain characters in names cause bad URIs. Disallow.
@Test
public void testAddRoleWithBadCharsInName() {
String roleName = "hello;:]!@#role";
assertCurrentUrlEquals(realmRolesPage);
realmRolesPage.table().addRole();
assertCurrentUrlEquals(createRolePage);
createRolePage.form().setName(roleName);
assertAlertWarning();
createRolePage.form().save();
assertAlertSuccess();
realmRolesPage.navigateTo();
assertNotNull(realmRolesPage.table().findRole("hellorole"));
}

@Test
public void testAddExistingRole() {
addRole(testRole);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<label class="col-md-2 control-label" for="name">{{:: 'role-name' | translate}} <span class="required" data-ng-show="create">*</span></label>

<div class="col-md-6">
<input kc-no-reserved-chars class="form-control" type="text" id="name" name="name" data-ng-model="role.name" autofocus
<input class="form-control" type="text" id="name" name="name" data-ng-model="role.name" autofocus
required data-ng-readonly="!create">
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<label class="col-md-2 control-label" for="name"><span class="required" data-ng-show="create">*</span> {{:: 'role-name' | translate}}</label>

<div class="col-md-6">
<input kc-no-reserved-chars class="form-control" type="text" id="name" name="name" data-ng-model="role.name" autofocus
<input class="form-control" type="text" id="name" name="name" data-ng-model="role.name" autofocus
required data-ng-readonly="!create">
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="col-md-6" data-ng-if="option.type == 'Role'">
<div class="row">
<div class="col-md-8">
<input kc-no-reserved-chars class="form-control" type="text" data-ng-model="config[ option.name ]" >
<input class="form-control" type="text" data-ng-model="config[ option.name ]" >
</div>
<div class="col-md-2">
<button type="button" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button>
Expand Down

0 comments on commit 13d0491

Please sign in to comment.