keycloak-aplcache
Changes
core/src/main/java/org/keycloak/representations/adapters/config/PolicyEnforcerConfig.java 23(+17 -6)
model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/CachedPolicyStore.java 2(+1 -1)
model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/entities/CachedPolicy.java 2(+1 -1)
services/src/main/java/org/keycloak/protocol/oidc/installation/KeycloakOIDCClientInstallation.java 3(+2 -1)
themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html 14(+5 -9)
themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html 14(+5 -9)
themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html 14(+5 -9)
themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html 14(+5 -9)
themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html 14(+5 -9)
themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html 14(+5 -9)
themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html 14(+5 -9)
themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html 14(+5 -9)
themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-detail.html 8(+2 -6)
Details
diff --git a/core/src/main/java/org/keycloak/representations/adapters/config/PolicyEnforcerConfig.java b/core/src/main/java/org/keycloak/representations/adapters/config/PolicyEnforcerConfig.java
index 5145ec7..b2c5757 100644
--- a/core/src/main/java/org/keycloak/representations/adapters/config/PolicyEnforcerConfig.java
+++ b/core/src/main/java/org/keycloak/representations/adapters/config/PolicyEnforcerConfig.java
@@ -18,6 +18,7 @@
package org.keycloak.representations.adapters.config;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
@@ -30,24 +31,30 @@ import java.util.List;
public class PolicyEnforcerConfig {
@JsonProperty("create-resources")
- private Boolean createResources;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Boolean createResources = Boolean.FALSE;
@JsonProperty("enforcement-mode")
private EnforcementMode enforcementMode = EnforcementMode.ENFORCING;
@JsonProperty("user-managed-access")
+ @JsonInclude(JsonInclude.Include.NON_NULL)
private UmaProtocolConfig umaProtocolConfig;
@JsonProperty("entitlement")
+ @JsonInclude(JsonInclude.Include.NON_NULL)
private EntitlementProtocolConfig entitlementProtocolConfig;
@JsonProperty("paths")
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<PathConfig> paths = new ArrayList<>();
@JsonProperty("online-introspection")
- private Boolean onlineIntrospection;
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private Boolean onlineIntrospection = Boolean.FALSE;
@JsonProperty("on-deny-redirect-to")
+ @JsonInclude(JsonInclude.Include.NON_NULL)
private String accessDeniedPath;
public Boolean isCreateResources() {
@@ -55,10 +62,6 @@ public class PolicyEnforcerConfig {
}
public List<PathConfig> getPaths() {
- if (this.paths == null) {
- return null;
- }
-
return Collections.unmodifiableList(this.paths);
}
@@ -82,6 +85,14 @@ public class PolicyEnforcerConfig {
return onlineIntrospection;
}
+ public void setCreateResources(Boolean createResources) {
+ this.createResources = createResources;
+ }
+
+ public void setOnlineIntrospection(Boolean onlineIntrospection) {
+ this.onlineIntrospection = onlineIntrospection;
+ }
+
public void setPaths(List<PathConfig> paths) {
this.paths = paths;
}
diff --git a/model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/CachedPolicyStore.java b/model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/CachedPolicyStore.java
index 10c108d..6bdf96f 100644
--- a/model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/CachedPolicyStore.java
+++ b/model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/CachedPolicyStore.java
@@ -369,7 +369,7 @@ public class CachedPolicyStore implements PolicyStore {
if (getId() == null) return false;
- if (o == null || getClass() != o.getClass()) return false;
+ if (!Policy.class.isInstance(o)) return false;
Policy that = (Policy) o;
diff --git a/model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/entities/CachedPolicy.java b/model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/entities/CachedPolicy.java
index fd2b488..99493bf 100644
--- a/model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/entities/CachedPolicy.java
+++ b/model/infinispan/src/main/java/org/keycloak/models/authorization/infinispan/entities/CachedPolicy.java
@@ -200,7 +200,7 @@ public class CachedPolicy implements Policy {
if (o == null || getClass() != o.getClass()) return false;
- AbstractIdentifiableEntity that = (AbstractIdentifiableEntity) o;
+ Policy that = (Policy) o;
if (!getId().equals(that.getId())) return false;
diff --git a/model/jpa/src/main/java/org/keycloak/authorization/jpa/entities/PolicyEntity.java b/model/jpa/src/main/java/org/keycloak/authorization/jpa/entities/PolicyEntity.java
index a5a6b27..540dc31 100644
--- a/model/jpa/src/main/java/org/keycloak/authorization/jpa/entities/PolicyEntity.java
+++ b/model/jpa/src/main/java/org/keycloak/authorization/jpa/entities/PolicyEntity.java
@@ -236,9 +236,9 @@ public class PolicyEntity implements Policy {
if (this.id == null) return false;
- if (o == null || getClass() != o.getClass()) return false;
+ if (!Policy.class.isInstance(o)) return false;
- AbstractIdentifiableEntity that = (AbstractIdentifiableEntity) o;
+ Policy that = (Policy) o;
if (!getId().equals(that.getId())) return false;
diff --git a/services/src/main/java/org/keycloak/authorization/admin/PolicyService.java b/services/src/main/java/org/keycloak/authorization/admin/PolicyService.java
index 1b54d56..d2d623c 100644
--- a/services/src/main/java/org/keycloak/authorization/admin/PolicyService.java
+++ b/services/src/main/java/org/keycloak/authorization/admin/PolicyService.java
@@ -42,6 +42,7 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import java.io.IOException;
@@ -177,6 +178,27 @@ public class PolicyService {
return Response.ok(toRepresentation(model, authorization)).build();
}
+ @Path("/search")
+ @GET
+ @Produces("application/json")
+ @NoCache
+ public Response find(@QueryParam("name") String name) {
+ this.auth.requireView();
+ StoreFactory storeFactory = authorization.getStoreFactory();
+
+ if (name == null) {
+ return Response.status(Status.BAD_REQUEST).build();
+ }
+
+ Policy model = storeFactory.getPolicyStore().findByName(name, this.resourceServer.getId());
+
+ if (model == null) {
+ return Response.status(Status.OK).build();
+ }
+
+ return Response.ok(toRepresentation(model, authorization)).build();
+ }
+
@GET
@Produces("application/json")
@NoCache
diff --git a/services/src/main/java/org/keycloak/authorization/admin/ResourceServerService.java b/services/src/main/java/org/keycloak/authorization/admin/ResourceServerService.java
index 7d19e83..59ba844 100644
--- a/services/src/main/java/org/keycloak/authorization/admin/ResourceServerService.java
+++ b/services/src/main/java/org/keycloak/authorization/admin/ResourceServerService.java
@@ -448,7 +448,7 @@ public class ResourceServerService {
private PolicyRepresentation createDefaultPolicy() {
PolicyRepresentation defaultPolicy = new PolicyRepresentation();
- defaultPolicy.setName("Only From Realm Policy");
+ defaultPolicy.setName("Default Policy");
defaultPolicy.setDescription("A policy that grants access only for users within this realm");
defaultPolicy.setType("js");
defaultPolicy.setDecisionStrategy(DecisionStrategy.AFFIRMATIVE);
@@ -456,21 +456,7 @@ public class ResourceServerService {
HashMap<String, String> defaultPolicyConfig = new HashMap<>();
- defaultPolicyConfig.put("code", "var context = $evaluation.getContext();\n" +
- "\n" +
- "// using attributes from the evaluation context to obtain the realm\n" +
- "var contextAttributes = context.getAttributes();\n" +
- "var realmName = contextAttributes.getValue('kc.realm.name').asString(0);\n" +
- "\n" +
- "// using attributes from the identity to obtain the issuer\n" +
- "var identity = context.getIdentity();\n" +
- "var identityAttributes = identity.getAttributes();\n" +
- "var issuer = identityAttributes.getValue('iss').asString(0);\n" +
- "\n" +
- "// only users from the realm have access granted \n" +
- "if (issuer.endsWith(realmName)) {\n" +
- " $evaluation.grant();\n" +
- "}");
+ defaultPolicyConfig.put("code", "// by default, grants any permission associated with this policy\n$evaluation.grant();\n");
defaultPolicy.setConfig(defaultPolicyConfig);
diff --git a/services/src/main/java/org/keycloak/authorization/admin/ResourceSetService.java b/services/src/main/java/org/keycloak/authorization/admin/ResourceSetService.java
index 9078408..8bb4a9b 100644
--- a/services/src/main/java/org/keycloak/authorization/admin/ResourceSetService.java
+++ b/services/src/main/java/org/keycloak/authorization/admin/ResourceSetService.java
@@ -39,11 +39,14 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import java.util.List;
import java.util.stream.Collectors;
+import static org.keycloak.authorization.admin.util.Models.toRepresentation;
+
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
*/
@@ -148,7 +151,28 @@ public class ResourceSetService {
return Response.status(Status.NOT_FOUND).build();
}
- return Response.ok(Models.toRepresentation(model, this.resourceServer, authorization)).build();
+ return Response.ok(toRepresentation(model, this.resourceServer, authorization)).build();
+ }
+
+ @Path("/search")
+ @GET
+ @Produces("application/json")
+ @NoCache
+ public Response find(@QueryParam("name") String name) {
+ this.auth.requireView();
+ StoreFactory storeFactory = authorization.getStoreFactory();
+
+ if (name == null) {
+ return Response.status(Status.BAD_REQUEST).build();
+ }
+
+ Resource model = storeFactory.getResourceStore().findByName(name, this.resourceServer.getId());
+
+ if (model == null) {
+ return Response.status(Status.OK).build();
+ }
+
+ return Response.ok(toRepresentation(model, this.resourceServer, authorization)).build();
}
@GET
@@ -160,7 +184,7 @@ public class ResourceSetService {
return Response.ok(
storeFactory.getResourceStore().findByResourceServer(this.resourceServer.getId()).stream()
- .map(resource -> Models.toRepresentation(resource, this.resourceServer, authorization))
+ .map(resource -> toRepresentation(resource, this.resourceServer, authorization))
.collect(Collectors.toList()))
.build();
}
diff --git a/services/src/main/java/org/keycloak/authorization/admin/ScopeService.java b/services/src/main/java/org/keycloak/authorization/admin/ScopeService.java
index 08bbed9..97b8541 100644
--- a/services/src/main/java/org/keycloak/authorization/admin/ScopeService.java
+++ b/services/src/main/java/org/keycloak/authorization/admin/ScopeService.java
@@ -17,6 +17,7 @@
*/
package org.keycloak.authorization.admin;
+import org.jboss.resteasy.annotations.cache.NoCache;
import org.keycloak.authorization.AuthorizationProvider;
import org.keycloak.authorization.model.Policy;
import org.keycloak.authorization.model.Resource;
@@ -36,6 +37,7 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import java.util.Arrays;
@@ -134,6 +136,27 @@ public class ScopeService {
return Response.ok(toRepresentation(model, this.authorization)).build();
}
+ @Path("/search")
+ @GET
+ @Produces("application/json")
+ @NoCache
+ public Response find(@QueryParam("name") String name) {
+ this.auth.requireView();
+ StoreFactory storeFactory = authorization.getStoreFactory();
+
+ if (name == null) {
+ return Response.status(Status.BAD_REQUEST).build();
+ }
+
+ Scope model = storeFactory.getScopeStore().findByName(name, this.resourceServer.getId());
+
+ if (model == null) {
+ return Response.status(Status.OK).build();
+ }
+
+ return Response.ok(toRepresentation(model, authorization)).build();
+ }
+
@GET
@Produces("application/json")
public Response findAll() {
diff --git a/services/src/main/java/org/keycloak/protocol/oidc/installation/KeycloakOIDCClientInstallation.java b/services/src/main/java/org/keycloak/protocol/oidc/installation/KeycloakOIDCClientInstallation.java
index a7781de..6fda3f0 100755
--- a/services/src/main/java/org/keycloak/protocol/oidc/installation/KeycloakOIDCClientInstallation.java
+++ b/services/src/main/java/org/keycloak/protocol/oidc/installation/KeycloakOIDCClientInstallation.java
@@ -156,7 +156,8 @@ public class KeycloakOIDCClientInstallation implements ClientInstallationProvide
PolicyEnforcerConfig enforcerConfig = new PolicyEnforcerConfig();
enforcerConfig.setEnforcementMode(null);
- enforcerConfig.setPaths(null);
+ enforcerConfig.setCreateResources(null);
+ enforcerConfig.setOnlineIntrospection(null);
rep.setEnforcerConfig(enforcerConfig);
diff --git a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js
index 216a5a9..680cb5b 100644
--- a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js
+++ b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js
@@ -107,6 +107,8 @@ module.controller('ResourceServerResourceDetailCtrl', function($scope, $http, $r
$scope.scopes = data;
});
+ var $instance = this;
+
ResourceServer.get({
realm : $route.current.params.realm,
client : client.id
@@ -131,9 +133,11 @@ module.controller('ResourceServerResourceDetailCtrl', function($scope, $http, $r
}, true);
$scope.save = function() {
- ResourceServerResource.save({realm : realm.realm, client : $scope.client.id}, $scope.resource, function(data) {
- $location.url("/realms/" + realm.realm + "/clients/" + $scope.client.id + "/authz/resource-server/resource/" + data._id);
- Notifications.success("The resource has been created.");
+ $instance.checkNameAvailability(function () {
+ ResourceServerResource.save({realm : realm.realm, client : $scope.client.id}, $scope.resource, function(data) {
+ $location.url("/realms/" + realm.realm + "/clients/" + $scope.client.id + "/authz/resource-server/resource/" + data._id);
+ Notifications.success("The resource has been created.");
+ });
});
}
@@ -153,6 +157,10 @@ module.controller('ResourceServerResourceDetailCtrl', function($scope, $http, $r
$scope.resource.scopes[i] = $scope.resource.scopes[i].name;
}
+ data = angular.copy($scope.resource);
+
+ $scope.originalResource = data;
+
$scope.$watch('resource', function() {
if (!angular.equals($scope.resource, data)) {
$scope.changed = true;
@@ -160,9 +168,11 @@ module.controller('ResourceServerResourceDetailCtrl', function($scope, $http, $r
}, true);
$scope.save = function() {
- ResourceServerResource.update({realm : realm.realm, client : $scope.client.id, rsrid : $scope.resource._id}, $scope.resource, function() {
- $route.reload();
- Notifications.success("The resource has been updated.");
+ $instance.checkNameAvailability(function () {
+ ResourceServerResource.update({realm : realm.realm, client : $scope.client.id, rsrid : $scope.resource._id}, $scope.resource, function() {
+ $route.reload();
+ Notifications.success("The resource has been updated.");
+ });
});
}
@@ -188,12 +198,30 @@ module.controller('ResourceServerResourceDetailCtrl', function($scope, $http, $r
}
$scope.reset = function() {
- $scope.resource = angular.copy(data);
- $scope.changed = false;
+ $route.reload();
}
});
}
});
+
+ $scope.checkNewNameAvailability = function () {
+ $instance.checkNameAvailability(function () {});
+ }
+
+ this.checkNameAvailability = function (onSuccess) {
+ ResourceServerResource.search({
+ realm : $route.current.params.realm,
+ client : client.id,
+ rsrid : $route.current.params.rsrid,
+ name: $scope.resource.name
+ }, function(data) {
+ if (data && data._id && data._id != $scope.resource._id) {
+ Notifications.error("Name already in use by another resource, please choose another one.");
+ } else {
+ onSuccess();
+ }
+ });
+ }
});
module.controller('ResourceServerScopeCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerScope, client) {
@@ -216,6 +244,8 @@ module.controller('ResourceServerScopeDetailCtrl', function($scope, $http, $rout
$scope.realm = realm;
$scope.client = client;
+ var $instance = this;
+
ResourceServer.get({
realm : $route.current.params.realm,
client : client.id
@@ -230,7 +260,7 @@ module.controller('ResourceServerScopeDetailCtrl', function($scope, $http, $rout
var scope = {};
- $scope.resource = angular.copy(scope);
+ $scope.scope = angular.copy(scope);
$scope.$watch('scope', function() {
if (!angular.equals($scope.scope, scope)) {
@@ -239,9 +269,11 @@ module.controller('ResourceServerScopeDetailCtrl', function($scope, $http, $rout
}, true);
$scope.save = function() {
- ResourceServerScope.save({realm : realm.realm, client : $scope.client.id}, $scope.scope, function(data) {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/scope/" + data.id);
- Notifications.success("The scope has been created.");
+ $instance.checkNameAvailability(function () {
+ ResourceServerScope.save({realm : realm.realm, client : $scope.client.id}, $scope.scope, function(data) {
+ $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/scope/" + data.id);
+ Notifications.success("The scope has been created.");
+ });
});
}
} else {
@@ -259,10 +291,14 @@ module.controller('ResourceServerScopeDetailCtrl', function($scope, $http, $rout
}
}, true);
+ $scope.originalScope = angular.copy($scope.scope);
+
$scope.save = function() {
- ResourceServerScope.update({realm : realm.realm, client : $scope.client.id, id : $scope.scope.id}, $scope.scope, function() {
- $scope.changed = false;
- Notifications.success("The scope has been updated.");
+ $instance.checkNameAvailability(function () {
+ ResourceServerScope.update({realm : realm.realm, client : $scope.client.id, id : $scope.scope.id}, $scope.scope, function() {
+ $scope.changed = false;
+ Notifications.success("The scope has been updated.");
+ });
});
}
@@ -288,12 +324,29 @@ module.controller('ResourceServerScopeDetailCtrl', function($scope, $http, $rout
}
$scope.reset = function() {
- $scope.scope = angular.copy(data);
- $scope.changed = false;
+ $route.reload();
}
});
}
});
+
+ $scope.checkNewNameAvailability = function () {
+ $instance.checkNameAvailability(function () {});
+ }
+
+ this.checkNameAvailability = function (onSuccess) {
+ ResourceServerScope.search({
+ realm : $route.current.params.realm,
+ client : client.id,
+ name: $scope.scope.name
+ }, function(data) {
+ if (data && data.id && data.id != $scope.scope.id) {
+ Notifications.error("Name already in use by another scope, please choose another one.");
+ } else {
+ onSuccess();
+ }
+ });
+ }
});
module.controller('ResourceServerPolicyCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerPolicy, PolicyProvider, client) {
@@ -845,6 +898,8 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
delegate.onInit();
+ var $instance = this;
+
ResourceServer.get({
realm : $route.current.params.realm,
client : client.id
@@ -876,17 +931,19 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
}, true);
$scope.save = function() {
- if (delegate.onCreate) {
- delegate.onCreate();
- }
- ResourceServerPolicy.save({realm : realm.realm, client : client.id}, $scope.policy, function(data) {
- if (delegate.isPermission()) {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/permission/" + $scope.policy.type + "/" + data.id);
- Notifications.success("The permission has been created.");
- } else {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/policy/" + $scope.policy.type + "/" + data.id);
- Notifications.success("The policy has been created.");
+ $instance.checkNameAvailability(function () {
+ if (delegate.onCreate) {
+ delegate.onCreate();
}
+ ResourceServerPolicy.save({realm : realm.realm, client : client.id}, $scope.policy, function(data) {
+ if (delegate.isPermission()) {
+ $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/permission/" + $scope.policy.type + "/" + data.id);
+ Notifications.success("The permission has been created.");
+ } else {
+ $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/policy/" + $scope.policy.type + "/" + data.id);
+ Notifications.success("The policy has been created.");
+ }
+ });
});
}
@@ -903,6 +960,7 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
client : client.id,
id : $route.current.params.id,
}, function(data) {
+ $scope.originalPolicy = data;
var policy = angular.copy(data);
if (delegate.onInitUpdate) {
@@ -919,16 +977,18 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
}, true);
$scope.save = function() {
- if (delegate.onUpdate) {
- delegate.onUpdate();
- }
- ResourceServerPolicy.update({realm : realm.realm, client : client.id, id : $scope.policy.id}, $scope.policy, function() {
- $route.reload();
- if (delegate.isPermission()) {
- Notifications.success("The permission has been updated.");
- } else {
- Notifications.success("The policy has been updated.");
+ $instance.checkNameAvailability(function () {
+ if (delegate.onUpdate) {
+ delegate.onUpdate();
}
+ ResourceServerPolicy.update({realm : realm.realm, client : client.id, id : $scope.policy.id}, $scope.policy, function() {
+ $route.reload();
+ if (delegate.isPermission()) {
+ Notifications.success("The permission has been updated.");
+ } else {
+ Notifications.success("The policy has been updated.");
+ }
+ });
});
}
@@ -971,11 +1031,31 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe
}
}
});
+
+ $scope.checkNewNameAvailability = function () {
+ $instance.checkNameAvailability(function () {});
+ }
+
+ this.checkNameAvailability = function (onSuccess) {
+ ResourceServerPolicy.search({
+ realm: $route.current.params.realm,
+ client: client.id,
+ name: $scope.policy.name
+ }, function(data) {
+ if (data && data.id && data.id != $scope.policy.id) {
+ Notifications.error("Name already in use by another policy or permission, please choose another one.");
+ } else {
+ onSuccess();
+ }
+ });
+ }
}
return PolicyController;
});
+
+
module.controller('PolicyEvaluateCtrl', function($scope, $http, $route, $location, realm, clients, roles, ResourceServer, client, ResourceServerResource, ResourceServerScope, User, Notifications) {
$scope.realm = realm;
$scope.client = client;
diff --git a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-services.js b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-services.js
index e611430..795cf1d 100644
--- a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-services.js
+++ b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-services.js
@@ -15,7 +15,8 @@ module.factory('ResourceServerResource', function($resource) {
client: '@client',
rsrid : '@rsrid'
}, {
- 'update' : {method : 'PUT'}
+ 'update' : {method : 'PUT'},
+ 'search' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/resource/search', method : 'GET'}
});
});
@@ -25,7 +26,8 @@ module.factory('ResourceServerScope', function($resource) {
client: '@client',
id : '@id'
}, {
- 'update' : {method : 'PUT'}
+ 'update' : {method : 'PUT'},
+ 'search' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/scope/search', method : 'GET'}
});
});
@@ -35,7 +37,8 @@ module.factory('ResourceServerPolicy', function($resource) {
client: '@client',
id : '@id'
}, {
- 'update' : {method : 'PUT'}
+ 'update' : {method : 'PUT'},
+ 'search' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/search', method : 'GET'}
});
});
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html
index 3d6a7bb..a8d4512 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-resource-detail.html
@@ -6,18 +6,18 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/permission">{{:: 'authz-permissions' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-resource-permission' | translate}}</li>
- <li data-ng-hide="create">{{policy.name}}</li>
+ <li data-ng-hide="create">{{originalPolicy.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-resource-permission' | translate}}</h1>
- <h1 data-ng-hide="create">{{policy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-click="remove()"></i></h1>
+ <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
<fieldset class="border-top">
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-permission-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -83,13 +83,9 @@
<input type="hidden" data-ng-model="policy.type"/>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html
index 969a4cc..3d1660b 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/provider/resource-server-policy-scope-detail.html
@@ -6,18 +6,18 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/permission">{{:: 'authz-permissions' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-scope-permission' | translate}}</li>
- <li data-ng-hide="create">{{policy.name}}</li>
+ <li data-ng-hide="create">{{originalPolicy.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-scope-permission' | translate}}</h1>
- <h1 data-ng-hide="create">{{policy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-click="remove()"></i></h1>
+ <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
<fieldset class="border-top">
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-permission-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -96,13 +96,9 @@
<input type="hidden" data-ng-model="policy.type"/>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageClients">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html
index 4607adb..7888f21 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html
@@ -7,11 +7,11 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-aggregated-policy' | translate}}</li>
<li data-ng-hide="create">{{:: 'authz-aggregated' | translate}}</li>
- <li data-ng-hide="create">{{policy.name}}</li>
+ <li data-ng-hide="create">{{originalPolicy.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-aggregated-policy' | translate}}</h1>
- <h1 data-ng-hide="create">{{policy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
+ <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
@@ -19,7 +19,7 @@
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-policy-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -72,13 +72,9 @@
<input type="hidden" data-ng-model="policy.type"/>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageClients">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html
index 8a268f6..a121f17 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-drools-detail.html
@@ -7,11 +7,11 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-drools-policy' | translate}}</li>
<li data-ng-hide="create">Drools</li>
- <li data-ng-hide="create">{{policy.name}}</li>
+ <li data-ng-hide="create">{{originalPolicy.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-drools-policy' | translate}}</h1>
- <h1 data-ng-hide="create">{{policy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
+ <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
@@ -19,7 +19,7 @@
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-policy-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -112,13 +112,9 @@
<input type="hidden" data-ng-model="policy.type"/>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html
index 7966ac2..fb2fbc4 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-js-detail.html
@@ -10,18 +10,18 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-js-policy' | translate}}</li>
<li data-ng-hide="create">JavaScript</li>
- <li data-ng-hide="create">{{policy.name}}</li>
+ <li data-ng-hide="create">{{originalPolicy.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-js-policy' | translate}}</h1>
- <h1 data-ng-hide="create">{{policy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-click="remove()"></i></h1>
+ <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
<fieldset class="border-top">
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-policy-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -55,13 +55,9 @@
<input type="hidden" data-ng-model="policy.type"/>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html
index 8a17870..9b0c199 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-role-detail.html
@@ -25,11 +25,11 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-role-policy' | translate}}</li>
<li data-ng-hide="create">{{:: 'roles' | translate}}</li>
- <li data-ng-hide="create">{{policy.name}}</li>
+ <li data-ng-hide="create">{{originalPolicy.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-role-policy' | translate}}</h1>
- <h1 data-ng-hide="create">{{policy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
+ <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
@@ -37,7 +37,7 @@
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-policy-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -99,13 +99,9 @@
<input type="hidden" data-ng-model="policy.type"/>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageClients">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html
index 10468d5..fc4af74 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-time-detail.html
@@ -10,19 +10,19 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-time-policy' | translate}}</li>
<li data-ng-hide="create">{{:: 'time' | translate}}</li>
- <li data-ng-hide="create">{{policy.name}}</li>
+ <li data-ng-hide="create">{{originalPolicy.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-time-policy' | translate}}</h1>
- <h1 data-ng-hide="create">{{policy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-click="remove()"></i></h1>
+ <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
<fieldset class="border-top">
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-policy-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -65,13 +65,9 @@
<input type="hidden" data-ng-model="policy.type"/>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html
index 977a2ac..6b56f37 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/policy/provider/resource-server-policy-user-detail.html
@@ -7,11 +7,11 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-user-policy' | translate}}</li>
<li data-ng-hide="create">{{:: 'user' | translate}}</li>
- <li data-ng-hide="create">{{policy.name}}</li>
+ <li data-ng-hide="create">{{originalPolicy.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-user-policy' | translate}}</h1>
- <h1 data-ng-hide="create">{{policy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
+ <h1 data-ng-hide="create">{{originalPolicy.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
@@ -19,7 +19,7 @@
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="policy.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-policy-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -80,13 +80,9 @@
<input type="hidden" data-ng-model="policy.type"/>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageClients">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-detail.html
index f7d1482..1110043 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-detail.html
@@ -43,13 +43,9 @@
</div>
<kc-tooltip>{{:: 'authz-remote-resource-management.tooltip' | translate}}</kc-tooltip>
</div>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-resource-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-resource-detail.html
index be105f8..f61c6e9 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-resource-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-resource-detail.html
@@ -6,11 +6,11 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/resource">{{:: 'authz-resource' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-resource' | translate}}</li>
- <li data-ng-hide="create">{{resource.name}}</li>
+ <li data-ng-hide="create">{{originalResource.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-resource' | translate}}</h1>
- <h1 data-ng-hide="create">{{resource.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
+ <h1 data-ng-hide="create">{{originalResource.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
@@ -18,7 +18,7 @@
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} <span class="required" data-ng-show="create">*</span></label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="resource.name" autofocus required>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="resource.name" autofocus required data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-resource-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -63,13 +63,9 @@
</div>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-scope-detail.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-scope-detail.html
index 2af5bf3..fac9c9c 100644
--- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-scope-detail.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/resource-server-scope-detail.html
@@ -6,11 +6,11 @@
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/scope">{{:: 'authz-scope' | translate}}</a></li>
<li data-ng-show="create">{{:: 'authz-add-scope' | translate}}</li>
- <li data-ng-hide="create">{{scope.name}}</li>
+ <li data-ng-hide="create">{{originalScope.name}}</li>
</ol>
<h1 data-ng-show="create">{{:: 'authz-add-scope' | translate}}</h1>
- <h1 data-ng-hide="create">{{scope.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
+ <h1 data-ng-hide="create">{{originalScope.name|capitalize}}<i class="pficon pficon-delete clickable" data-ng-show="!create"
data-ng-hide="changed" data-ng-click="remove()"></i></h1>
<form class="form-horizontal" name="clientForm" novalidate>
@@ -18,7 +18,7 @@
<div class="form-group">
<label class="col-md-2 control-label" for="name">{{:: 'name' | translate}} </label>
<div class="col-sm-6">
- <input class="form-control" type="text" id="name" name="name" data-ng-model="scope.name" autofocus>
+ <input class="form-control" type="text" id="name" name="name" data-ng-model="scope.name" autofocus data-ng-blur="checkNewNameAvailability()">
</div>
<kc-tooltip>{{:: 'authz-scope-name.tooltip' | translate}}</kc-tooltip>
</div>
@@ -31,13 +31,9 @@
</div>
</fieldset>
- <div class="form-group">
- <div class="col-md-10 col-md-offset-2" data-ng-show="create">
+ <div class="form-group" data-ng-show="access.manageAuthorization">
+ <div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
- <button kc-cancel data-ng-click="cancel()">{{:: 'cancel' | translate}}</button>
- </div>
- <div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageClients">
- <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>