lifepuzzlefun commented on code in PR #20456:
URL: https://github.com/apache/pulsar/pull/20456#discussion_r1213212636
##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java:
##########
@@ -185,6 +185,18 @@ CompletableFuture<Boolean> allowSinkOpsAsync(NamespaceName
namespaceName, String
CompletableFuture<Void> grantPermissionAsync(NamespaceName namespace,
Set<AuthAction> actions, String role,
String authDataJson);
+ /**
+ * Revoke authorization-action permission on a namespace to the given
client.
+ * @param namespace
+ * @param role
+ * @return CompletableFuture<Void>
+ */
+ default CompletableFuture<Void> revokePermissionAsync(NamespaceName
namespace, String role) {
+ return FutureUtil.failedFuture(new IllegalStateException(
Review Comment:
maybe `java.lang.UnsupportedOperationException` is more suitable.
##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java:
##########
@@ -249,6 +249,31 @@ public CompletableFuture<Void>
grantPermissionAsync(TopicName topicName, Set<Aut
});
}
+ @Override
+ public CompletableFuture<Void> revokePermissionAsync(TopicName topicName,
String role) {
+ return getPoliciesReadOnlyAsync().thenCompose(readonly -> {
+ if (readonly) {
+ if (log.isDebugEnabled()) {
+ log.debug("Policies are read-only. Broker cannot do
read-write operations");
+ }
+ throw new IllegalStateException("policies are in readonly
mode");
+ }
+ return pulsarResources.getNamespaceResources()
+ .setPoliciesAsync(topicName.getNamespaceObject(), policies
-> {
+ policies.auth_policies.getTopicAuthentication()
+ .computeIfAbsent(topicName.toString(), __ ->
new HashMap<>())
Review Comment:
if topic not in authentication maybe we can just return
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]