diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authorization/PolicyEnforcer.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authorization/PolicyEnforcer.java index fe8aa1aac1..ccd9452945 100644 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authorization/PolicyEnforcer.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authorization/PolicyEnforcer.java @@ -168,36 +168,11 @@ public class PolicyEnforcer { } if (resource == null) { - if (enforcerConfig.isCreateResources()) { - LOGGER.debugf("Creating resource on server for path [%s].", pathConfig); - ResourceRepresentation representation = new ResourceRepresentation(); - - representation.setName(resourceName); - representation.setType(pathConfig.getType()); - representation.setUri(path); - - HashSet scopes = new HashSet<>(); - - for (String scopeName : pathConfig.getScopes()) { - ScopeRepresentation scope = new ScopeRepresentation(); - - scope.setName(scopeName); - - scopes.add(scope); - } - - representation.setScopes(scopes); - - ResourceRepresentation registrationResponse = protectedResource.create(representation); - - pathConfig.setId(registrationResponse.getId()); - } else { - throw new RuntimeException("Could not find matching resource on server with uri [" + path + "] or name [" + resourceName + "]. Make sure you have created a resource on the server that matches with the path configuration."); - } - } else { - pathConfig.setId(resource.getId()); + throw new RuntimeException("Could not find matching resource on server with uri [" + path + "] or name [" + resourceName + "]. Make sure you have created a resource on the server that matches with the path configuration."); } + pathConfig.setId(resource.getId()); + PathConfig existingPath = null; for (PathConfig current : paths.values()) { 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 89dadbfdad..46189f6111 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 @@ -29,10 +29,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ public class PolicyEnforcerConfig { - @JsonProperty("create-resources") - @JsonInclude(JsonInclude.Include.NON_NULL) - private Boolean createResources = Boolean.FALSE; - @JsonProperty("enforcement-mode") private EnforcementMode enforcementMode = EnforcementMode.ENFORCING; @@ -48,10 +44,6 @@ public class PolicyEnforcerConfig { @JsonInclude(JsonInclude.Include.NON_NULL) private UserManagedAccessConfig userManagedAccess; - public Boolean isCreateResources() { - return this.createResources; - } - public List getPaths() { return this.paths; } @@ -68,10 +60,6 @@ public class PolicyEnforcerConfig { return this.userManagedAccess; } - public void setCreateResources(Boolean createResources) { - this.createResources = createResources; - } - public void setPaths(List paths) { this.paths = paths; } 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 60970d8ef7..d0b7de6d00 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 @@ -155,7 +155,6 @@ public class KeycloakOIDCClientInstallation implements ClientInstallationProvide PolicyEnforcerConfig enforcerConfig = new PolicyEnforcerConfig(); enforcerConfig.setEnforcementMode(null); - enforcerConfig.setCreateResources(null); rep.setEnforcerConfig(enforcerConfig);