Skip to content

Commit

Permalink
Fixes open-metadata#12651 Organization policy changes are overwritten…
Browse files Browse the repository at this point in the history
… during server restart (open-metadata#12652)
  • Loading branch information
sureshms authored Jul 29, 2023
1 parent b7e3242 commit 786dde1
Showing 1 changed file with 0 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
import org.openmetadata.service.security.Authorizer;
import org.openmetadata.service.security.policyevaluator.CompiledRule;
import org.openmetadata.service.security.policyevaluator.RuleEvaluator;
import org.openmetadata.service.util.JsonUtils;
import org.openmetadata.service.util.ResultList;

@Slf4j
Expand Down Expand Up @@ -107,23 +106,6 @@ public void initialize(OpenMetadataApplicationConfig config) throws IOException
repository.initSeedDataFromResources();
}

@Override
public void upgrade() throws IOException {
// Introduced in 0.13
// OrganizationPolicy rule change
Policy originalOrgPolicy = repository.getByName(null, Entity.ORGANIZATION_POLICY_NAME, repository.getPatchFields());
Policy updatedOrgPolicy = JsonUtils.readValue(JsonUtils.pojoToJson(originalOrgPolicy), Policy.class);

// Rules are in alphabetical order - change second rule "OrganizationPolicy-Owner-Rule"
// from ALL operation to remove CREATE operation and allow all the other operations for the owner
updatedOrgPolicy
.getRules()
.get(1)
.withOperations(List.of(MetadataOperation.EDIT_ALL, MetadataOperation.VIEW_ALL, MetadataOperation.DELETE));
repository.patch(
null, originalOrgPolicy.getId(), "admin", JsonUtils.getJsonPatch(originalOrgPolicy, updatedOrgPolicy));
}

public static class PolicyList extends ResultList<Policy> {
/* Required for serde */
}
Expand Down

0 comments on commit 786dde1

Please sign in to comment.