[KEYCLOAK-4102] - Removing create-resources configuration option
This commit is contained in:
parent
ffeb0420bf
commit
e9e376419d
3 changed files with 3 additions and 41 deletions
|
@ -168,36 +168,11 @@ public class PolicyEnforcer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
if (enforcerConfig.isCreateResources()) {
|
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.");
|
||||||
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<ScopeRepresentation> 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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pathConfig.setId(resource.getId());
|
||||||
|
|
||||||
PathConfig existingPath = null;
|
PathConfig existingPath = null;
|
||||||
|
|
||||||
for (PathConfig current : paths.values()) {
|
for (PathConfig current : paths.values()) {
|
||||||
|
|
|
@ -29,10 +29,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
*/
|
*/
|
||||||
public class PolicyEnforcerConfig {
|
public class PolicyEnforcerConfig {
|
||||||
|
|
||||||
@JsonProperty("create-resources")
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
private Boolean createResources = Boolean.FALSE;
|
|
||||||
|
|
||||||
@JsonProperty("enforcement-mode")
|
@JsonProperty("enforcement-mode")
|
||||||
private EnforcementMode enforcementMode = EnforcementMode.ENFORCING;
|
private EnforcementMode enforcementMode = EnforcementMode.ENFORCING;
|
||||||
|
|
||||||
|
@ -48,10 +44,6 @@ public class PolicyEnforcerConfig {
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
private UserManagedAccessConfig userManagedAccess;
|
private UserManagedAccessConfig userManagedAccess;
|
||||||
|
|
||||||
public Boolean isCreateResources() {
|
|
||||||
return this.createResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PathConfig> getPaths() {
|
public List<PathConfig> getPaths() {
|
||||||
return this.paths;
|
return this.paths;
|
||||||
}
|
}
|
||||||
|
@ -68,10 +60,6 @@ public class PolicyEnforcerConfig {
|
||||||
return this.userManagedAccess;
|
return this.userManagedAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreateResources(Boolean createResources) {
|
|
||||||
this.createResources = createResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPaths(List<PathConfig> paths) {
|
public void setPaths(List<PathConfig> paths) {
|
||||||
this.paths = paths;
|
this.paths = paths;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,6 @@ public class KeycloakOIDCClientInstallation implements ClientInstallationProvide
|
||||||
PolicyEnforcerConfig enforcerConfig = new PolicyEnforcerConfig();
|
PolicyEnforcerConfig enforcerConfig = new PolicyEnforcerConfig();
|
||||||
|
|
||||||
enforcerConfig.setEnforcementMode(null);
|
enforcerConfig.setEnforcementMode(null);
|
||||||
enforcerConfig.setCreateResources(null);
|
|
||||||
|
|
||||||
rep.setEnforcerConfig(enforcerConfig);
|
rep.setEnforcerConfig(enforcerConfig);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue