KEYCLOAK-958 Support role names with '/' and '\'

This commit is contained in:
Stian Thorgersen 2015-01-15 12:21:58 +01:00
parent 82a7471042
commit 7ccea2bd10
7 changed files with 20 additions and 18 deletions

View file

@ -332,11 +332,12 @@ module.controller('ApplicationRoleDetailCtrl', function($scope, realm, applicati
$scope.changed = false; $scope.changed = false;
role = angular.copy($scope.role); role = angular.copy($scope.role);
var l = headers().location; ApplicationRole.get({ realm: realm.realm, application : application.id, role: role.name }, function(role) {
var id = l.substring(l.lastIndexOf("/") + 1); var id = role.id;
$location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles/" + id); $location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles/" + id);
Notifications.success("The role has been created."); Notifications.success("The role has been created.");
}); });
});
} else { } else {
$scope.update(); $scope.update();
} }
@ -347,7 +348,7 @@ module.controller('ApplicationRoleDetailCtrl', function($scope, realm, applicati
$scope.role.$remove({ $scope.role.$remove({
realm : realm.realm, realm : realm.realm,
application : application.id, application : application.id,
role : $scope.role.name role : $scope.role.id
}, function() { }, function() {
$location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles"); $location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles");
Notifications.success("The role has been deleted."); Notifications.success("The role has been deleted.");

View file

@ -952,11 +952,12 @@ module.controller('RoleDetailCtrl', function($scope, realm, role, roles, applica
$scope.changed = false; $scope.changed = false;
role = angular.copy($scope.role); role = angular.copy($scope.role);
var l = headers().location; Role.get({ realm: realm.realm, role: role.name }, function(role) {
var id = l.substring(l.lastIndexOf("/") + 1); var id = role.id;
$location.url("/realms/" + realm.realm + "/roles/" + id); $location.url("/realms/" + realm.realm + "/roles/" + id);
Notifications.success("The role has been created."); Notifications.success("The role has been created.");
}); });
});
} else { } else {
$scope.update(); $scope.update();
} }
@ -966,7 +967,7 @@ module.controller('RoleDetailCtrl', function($scope, realm, role, roles, applica
Dialog.confirmDelete($scope.role.name, 'role', function () { Dialog.confirmDelete($scope.role.name, 'role', function () {
$scope.role.$remove({ $scope.role.$remove({
realm: realm.realm, realm: realm.realm,
role: $scope.role.name role: $scope.role.id
}, function () { }, function () {
$location.url("/realms/" + realm.realm + "/roles"); $location.url("/realms/" + realm.realm + "/roles");
Notifications.success("The role has been deleted."); Notifications.success("The role has been deleted.");

View file

@ -137,8 +137,8 @@ module.factory('UserFederatedIdentityLoader', function(Loader, UserFederatedIden
module.factory('RoleLoader', function(Loader, Role, $route, $q) { module.factory('RoleLoader', function(Loader, RoleById, $route, $q) {
return Loader.get(Role, function() { return Loader.get(RoleById, function() {
return { return {
realm : $route.current.params.realm, realm : $route.current.params.realm,
role : $route.current.params.role role : $route.current.params.role
@ -154,8 +154,8 @@ module.factory('RoleListLoader', function(Loader, Role, $route, $q) {
}); });
}); });
module.factory('ApplicationRoleLoader', function(Loader, ApplicationRole, $route, $q) { module.factory('ApplicationRoleLoader', function(Loader, RoleById, $route, $q) {
return Loader.get(ApplicationRole, function() { return Loader.get(RoleById, function() {
return { return {
realm : $route.current.params.realm, realm : $route.current.params.realm,
application : $route.current.params.application, application : $route.current.params.application,

View file

@ -40,7 +40,7 @@
required> --> required> -->
</div> </div>
</div> </div>
<div class="form-group clearfix block"> <div class="form-group clearfix block" data-ng-hide="create">
<label class="col-sm-2 control-label" for="compositeSwitch" class="control-label">Composite Roles</label> <label class="col-sm-2 control-label" for="compositeSwitch" class="control-label">Composite Roles</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch /> <input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch />

View file

@ -52,7 +52,7 @@
--> -->
<tbody> <tbody>
<tr ng-repeat="role in roles"> <tr ng-repeat="role in roles">
<td><a href="#/realms/{{realm.realm}}/applications/{{application.id}}/roles/{{role.name}}">{{role.name}}</a></td> <td><a href="#/realms/{{realm.realm}}/applications/{{application.id}}/roles/{{role.id}}">{{role.name}}</a></td>
<td>{{role.composite}}</td> <td>{{role.composite}}</td>
<td>{{role.description}}</td> <td>{{role.description}}</td>
</tr> </tr>

View file

@ -29,7 +29,7 @@
<textarea class="form-control" rows="5" cols="50" id="description" name="description" data-ng-model="role.description"></textarea> <textarea class="form-control" rows="5" cols="50" id="description" name="description" data-ng-model="role.description"></textarea>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group" data-ng-hide="create">
<label class="col-sm-2 control-label" for="compositeSwitch" class="control-label">Composite Roles</label> <label class="col-sm-2 control-label" for="compositeSwitch" class="control-label">Composite Roles</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch /> <input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch />

View file

@ -46,7 +46,7 @@
--> -->
<tbody> <tbody>
<tr ng-repeat="role in roles | filter:{name: searchQuery}"> <tr ng-repeat="role in roles | filter:{name: searchQuery}">
<td><a href="#/realms/{{realm.realm}}/roles/{{role.name}}">{{role.name}}</a></td> <td><a href="#/realms/{{realm.realm}}/roles/{{role.id}}">{{role.name}}</a></td>
<td>{{role.composite}}</td> <td>{{role.composite}}</td>
<td>{{role.description}}</td> <td>{{role.description}}</td>
</tr> </tr>