diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java index dcf2a84e23ca0..a58cb7da60529 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java @@ -776,7 +776,7 @@ protected void internalSetNamespaceMessageTTL(Integer messageTTL) { } protected void internalSetSubscriptionExpirationTime(int expirationTime) { - validateAdminAccessForTenant(namespaceName.getTenant()); + validateNamespacePolicyOperation(namespaceName, PolicyName.SUBSCRIPTION_EXPIRATION_TIME, PolicyOperation.WRITE); validatePoliciesReadOnlyAccess(); if (expirationTime < 0) { @@ -791,7 +791,7 @@ protected void internalSetSubscriptionExpirationTime(int expirationTime) { protected void internalSetAutoTopicCreation(AsyncResponse asyncResponse, AutoTopicCreationOverride autoTopicCreationOverride) { final int maxPartitions = pulsar().getConfig().getMaxNumPartitionsPerPartitionedTopic(); - validateAdminAccessForTenant(namespaceName.getTenant()); + validateNamespacePolicyOperation(namespaceName, PolicyName.AUTO_TOPIC_CREATION, PolicyOperation.WRITE); validatePoliciesReadOnlyAccess(); if (autoTopicCreationOverride != null) { if (!AutoTopicCreationOverride.isValidOverride(autoTopicCreationOverride)) { @@ -831,8 +831,8 @@ protected void internalRemoveAutoTopicCreation(AsyncResponse asyncResponse) { } protected void internalSetAutoSubscriptionCreation( - AsyncResponse asyncResponse, AutoSubscriptionCreationOverride autoSubscriptionCreationOverride) { - validateAdminAccessForTenant(namespaceName.getTenant()); + AsyncResponse asyncResponse, AutoSubscriptionCreationOverride autoSubscriptionCreationOverride) { + validateNamespacePolicyOperation(namespaceName, PolicyName.AUTO_SUBSCRIPTION_CREATION, PolicyOperation.WRITE); validatePoliciesReadOnlyAccess(); // Force to read the data s.t. the watch to the cache content is setup. diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/PolicyName.java b/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/PolicyName.java index 7172d50fbb1c7..b10990ab7f501 100644 --- a/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/PolicyName.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/PolicyName.java @@ -25,6 +25,8 @@ public enum PolicyName { ALL, ANTI_AFFINITY, + AUTO_SUBSCRIPTION_CREATION, + AUTO_TOPIC_CREATION, BACKLOG, COMPACTION, DELAYED_DELIVERY, @@ -43,6 +45,7 @@ public enum PolicyName { REPLICATION_RATE, SCHEMA_COMPATIBILITY_STRATEGY, SUBSCRIPTION_AUTH_MODE, + SUBSCRIPTION_EXPIRATION_TIME, ENCRYPTION, TTL, MAX_TOPICS,