Interface AuthorizationProvider
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
MultiRolesTokenAuthorizationProvider,PulsarAuthorizationProvider
Provider of authorization mechanism.
-
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<Boolean>allowBrokerOperationAsync(String clusterName, String brokerId, org.apache.pulsar.common.policies.data.BrokerOperation brokerOperation, String role, AuthenticationDataSource authData) default CompletableFuture<Boolean>allowClusterOperationAsync(String clusterName, org.apache.pulsar.common.policies.data.ClusterOperation clusterOperation, String role, AuthenticationDataSource authData) default CompletableFuture<Boolean>allowClusterPolicyOperationAsync(String clusterName, String role, org.apache.pulsar.common.policies.data.PolicyName policy, org.apache.pulsar.common.policies.data.PolicyOperation operation, AuthenticationDataSource authData) allowFunctionOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, String role, AuthenticationDataSource authenticationData) Allow all function operations with in this namespace.default CompletableFuture<Boolean>allowNamespaceOperationAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, String role, org.apache.pulsar.common.policies.data.NamespaceOperation operation, AuthenticationDataSource authData) Check if a given role is allowed to execute a given operation on the namespace.default CompletableFuture<Boolean>allowNamespacePolicyOperationAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.policies.data.PolicyName policy, org.apache.pulsar.common.policies.data.PolicyOperation operation, String role, AuthenticationDataSource authData) Check if a given role is allowed to execute a given policy operation on the namespace.allowSinkOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, String role, AuthenticationDataSource authenticationData) Allow all sink operations with in this namespace.allowSourceOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, String role, AuthenticationDataSource authenticationData) Allow all source operations with in this namespace.default CompletableFuture<Boolean>allowTenantOperationAsync(String tenantName, String role, org.apache.pulsar.common.policies.data.TenantOperation operation, AuthenticationDataSource authData) Check if a given role is allowed to execute a given operation on the tenant.default CompletableFuture<Boolean>allowTopicOperationAsync(org.apache.pulsar.common.naming.TopicName topic, String role, org.apache.pulsar.common.policies.data.TopicOperation operation, AuthenticationDataSource authData) Check if a given role is allowed to execute a given topic operation on the topic.default CompletableFuture<Boolean>allowTopicPolicyOperationAsync(org.apache.pulsar.common.naming.TopicName topic, String role, org.apache.pulsar.common.policies.data.PolicyName policy, org.apache.pulsar.common.policies.data.PolicyOperation operation, AuthenticationDataSource authData) Check if a given role is allowed to execute a given topic operation on topic's policy.canConsumeAsync(org.apache.pulsar.common.naming.TopicName topicName, String role, AuthenticationDataSource authenticationData, String subscription) Check if the specified role has permission to receive messages from the specified fully qualified topic name.canLookupAsync(org.apache.pulsar.common.naming.TopicName topicName, String role, AuthenticationDataSource authenticationData) Check whether the specified role can perform a lookup for the specified topic.canProduceAsync(org.apache.pulsar.common.naming.TopicName topicName, String role, AuthenticationDataSource authenticationData) Check if the specified role has permission to send messages to the specified fully qualified topic name.default CompletableFuture<Map<String,Set<org.apache.pulsar.common.policies.data.AuthAction>>> getPermissionsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName) Get authorization-action permissions on a namespace.default CompletableFuture<Map<String,Set<org.apache.pulsar.common.policies.data.AuthAction>>> getPermissionsAsync(org.apache.pulsar.common.naming.TopicName topicName) Get authorization-action permissions on a topic.default CompletableFuture<Map<String,Set<String>>> getSubscriptionPermissionsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName) Get authorization-action permissions on a topic.default CompletableFuture<Void>grantPermissionAsync(List<org.apache.pulsar.client.admin.GrantTopicPermissionOptions> options) grantPermissionAsync(org.apache.pulsar.common.naming.NamespaceName namespace, Set<org.apache.pulsar.common.policies.data.AuthAction> actions, String role, String authDataJson) Grant authorization-action permission on a namespace to the given client.grantPermissionAsync(org.apache.pulsar.common.naming.TopicName topicName, Set<org.apache.pulsar.common.policies.data.AuthAction> actions, String role, String authDataJson) Grant authorization-action permission on a topic to the given client.grantSubscriptionPermissionAsync(org.apache.pulsar.common.naming.NamespaceName namespace, String subscriptionName, Set<String> roles, String authDataJson) Grant permission to roles that can access subscription-admin api.default voidinitialize(ServiceConfiguration conf, PulsarResources pulsarResources) Perform initialization for the authorization provider.default CompletableFuture<Boolean>isSuperUser(String role, AuthenticationDataSource authenticationData, ServiceConfiguration serviceConfiguration) Check if specified role is a super user.default CompletableFuture<Boolean>isTenantAdmin(String tenant, String role, org.apache.pulsar.common.policies.data.TenantInfo tenantInfo, AuthenticationDataSource authenticationData) Check if specified role is an admin of the tenant.default CompletableFuture<Void>removePermissionsAsync(org.apache.pulsar.common.naming.TopicName topicName) Remove authorization-action permissions on a topic.default CompletableFuture<Void>revokePermissionAsync(List<org.apache.pulsar.client.admin.RevokeTopicPermissionOptions> options) default CompletableFuture<Void>revokePermissionAsync(org.apache.pulsar.common.naming.NamespaceName namespace, String role) Revoke authorization-action permission on a namespace to the given client.default CompletableFuture<Void>revokePermissionAsync(org.apache.pulsar.common.naming.TopicName topicName, String role) Revoke authorization-action permission on a topic to the given client.revokeSubscriptionPermissionAsync(org.apache.pulsar.common.naming.NamespaceName namespace, String subscriptionName, String role, String authDataJson) Revoke subscription admin-api access for a role.
-
Method Details
-
isSuperUser
default CompletableFuture<Boolean> isSuperUser(String role, AuthenticationDataSource authenticationData, ServiceConfiguration serviceConfiguration) Check if specified role is a super user.- Parameters:
role- the role to checkauthenticationData- authentication data related to the role- Returns:
- a CompletableFuture containing a boolean in which true means the role is a super user and false if it is not
-
isTenantAdmin
default CompletableFuture<Boolean> isTenantAdmin(String tenant, String role, org.apache.pulsar.common.policies.data.TenantInfo tenantInfo, AuthenticationDataSource authenticationData) Check if specified role is an admin of the tenant.- Parameters:
tenant- the tenant to checkrole- the role to check- Returns:
- a CompletableFuture containing a boolean in which true means the role is an admin user and false if it is not
-
initialize
default void initialize(ServiceConfiguration conf, PulsarResources pulsarResources) throws IOException Perform initialization for the authorization provider.- Parameters:
conf- broker config objectpulsarResources- Resources component for access to metadata- Throws:
IOException- if the initialization fails
-
canProduceAsync
CompletableFuture<Boolean> canProduceAsync(org.apache.pulsar.common.naming.TopicName topicName, String role, AuthenticationDataSource authenticationData) Check if the specified role has permission to send messages to the specified fully qualified topic name.- Parameters:
topicName- the fully qualified topic name associated with the topic.role- the app id used to send messages to the topic.
-
canConsumeAsync
CompletableFuture<Boolean> canConsumeAsync(org.apache.pulsar.common.naming.TopicName topicName, String role, AuthenticationDataSource authenticationData, String subscription) Check if the specified role has permission to receive messages from the specified fully qualified topic name.- Parameters:
topicName- the fully qualified topic name associated with the topic.role- the app id used to receive messages from the topic.subscription- the subscription name defined by the client
-
canLookupAsync
CompletableFuture<Boolean> canLookupAsync(org.apache.pulsar.common.naming.TopicName topicName, String role, AuthenticationDataSource authenticationData) Check whether the specified role can perform a lookup for the specified topic. For that the caller needs to have producer or consumer permission.- Parameters:
topicName-role-- Returns:
- Throws:
Exception
-
allowFunctionOpsAsync
CompletableFuture<Boolean> allowFunctionOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, String role, AuthenticationDataSource authenticationData) Allow all function operations with in this namespace.- Parameters:
namespaceName- The namespace that the function operations can be executed inrole- The role to checkauthenticationData- authentication data related to the role- Returns:
- a boolean to determine whether authorized or not
-
allowSourceOpsAsync
CompletableFuture<Boolean> allowSourceOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, String role, AuthenticationDataSource authenticationData) Allow all source operations with in this namespace.- Parameters:
namespaceName- The namespace that the sources operations can be executed inrole- The role to checkauthenticationData- authentication data related to the role- Returns:
- a boolean to determine whether authorized or not
-
allowSinkOpsAsync
CompletableFuture<Boolean> allowSinkOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, String role, AuthenticationDataSource authenticationData) Allow all sink operations with in this namespace.- Parameters:
namespaceName- The namespace that the sink operations can be executed inrole- The role to checkauthenticationData- authentication data related to the role- Returns:
- a boolean to determine whether authorized or not
-
grantPermissionAsync
CompletableFuture<Void> grantPermissionAsync(org.apache.pulsar.common.naming.NamespaceName namespace, Set<org.apache.pulsar.common.policies.data.AuthAction> actions, String role, String authDataJson) Grant authorization-action permission on a namespace to the given client. NOTE: used to complete withIllegalArgumentExceptionwhen namespace not found or withIllegalStateExceptionwhen failed to grant permission. This behavior is now deprecated. Please use the appropriateMetadataStoreException.- Parameters:
namespace-actions-role-authDataJson- additional authdata in json format- Returns:
- CompletableFuture
-
revokePermissionAsync
default CompletableFuture<Void> revokePermissionAsync(org.apache.pulsar.common.naming.NamespaceName namespace, String role) Revoke authorization-action permission on a namespace to the given client.- Parameters:
namespace-role-- Returns:
- CompletableFuture
-
grantSubscriptionPermissionAsync
CompletableFuture<Void> grantSubscriptionPermissionAsync(org.apache.pulsar.common.naming.NamespaceName namespace, String subscriptionName, Set<String> roles, String authDataJson) Grant permission to roles that can access subscription-admin api.- Parameters:
namespace-subscriptionName-roles-authDataJson- additional authdata in json format- Returns:
- CompletableFuture
-
revokeSubscriptionPermissionAsync
CompletableFuture<Void> revokeSubscriptionPermissionAsync(org.apache.pulsar.common.naming.NamespaceName namespace, String subscriptionName, String role, String authDataJson) Revoke subscription admin-api access for a role.- Parameters:
namespace-subscriptionName-role-- Returns:
- CompletableFuture
-
grantPermissionAsync
CompletableFuture<Void> grantPermissionAsync(org.apache.pulsar.common.naming.TopicName topicName, Set<org.apache.pulsar.common.policies.data.AuthAction> actions, String role, String authDataJson) Grant authorization-action permission on a topic to the given client. NOTE: used to complete withIllegalArgumentExceptionwhen namespace not found or withIllegalStateExceptionwhen failed to grant permission. This behavior is now deprecated. Please use the appropriateMetadataStoreException.- Parameters:
topicName-role-authDataJson- additional authdata in json format- Returns:
- CompletableFuture
-
grantPermissionAsync
default CompletableFuture<Void> grantPermissionAsync(List<org.apache.pulsar.client.admin.GrantTopicPermissionOptions> options) -
revokePermissionAsync
default CompletableFuture<Void> revokePermissionAsync(List<org.apache.pulsar.client.admin.RevokeTopicPermissionOptions> options) -
revokePermissionAsync
default CompletableFuture<Void> revokePermissionAsync(org.apache.pulsar.common.naming.TopicName topicName, String role) Revoke authorization-action permission on a topic to the given client.- Parameters:
topicName-role-- Returns:
- CompletableFuture
-
allowTenantOperationAsync
default CompletableFuture<Boolean> allowTenantOperationAsync(String tenantName, String role, org.apache.pulsar.common.policies.data.TenantOperation operation, AuthenticationDataSource authData) Check if a given role is allowed to execute a given operation on the tenant.- Parameters:
tenantName- tenant namerole- role nameoperation- tenant operationauthData- authenticated data of the role- Returns:
- a completable future represents check result
-
allowNamespaceOperationAsync
default CompletableFuture<Boolean> allowNamespaceOperationAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, String role, org.apache.pulsar.common.policies.data.NamespaceOperation operation, AuthenticationDataSource authData) Check if a given role is allowed to execute a given operation on the namespace.- Parameters:
namespaceName- namespace namerole- role nameoperation- namespace operationauthData- authenticated data- Returns:
- a completable future represents check result
-
allowNamespacePolicyOperationAsync
default CompletableFuture<Boolean> allowNamespacePolicyOperationAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, org.apache.pulsar.common.policies.data.PolicyName policy, org.apache.pulsar.common.policies.data.PolicyOperation operation, String role, AuthenticationDataSource authData) Check if a given role is allowed to execute a given policy operation on the namespace.- Parameters:
namespaceName- namespace namepolicy- policy nameoperation- policy operationrole- role nameauthData- authenticated data- Returns:
- a completable future represents check result
-
allowTopicOperationAsync
default CompletableFuture<Boolean> allowTopicOperationAsync(org.apache.pulsar.common.naming.TopicName topic, String role, org.apache.pulsar.common.policies.data.TopicOperation operation, AuthenticationDataSource authData) Check if a given role is allowed to execute a given topic operation on the topic.- Parameters:
topic- topic namerole- role nameoperation- topic operationauthData- authenticated data- Returns:
- CompletableFuture
-
allowTopicPolicyOperationAsync
default CompletableFuture<Boolean> allowTopicPolicyOperationAsync(org.apache.pulsar.common.naming.TopicName topic, String role, org.apache.pulsar.common.policies.data.PolicyName policy, org.apache.pulsar.common.policies.data.PolicyOperation operation, AuthenticationDataSource authData) Check if a given role is allowed to execute a given topic operation on topic's policy.- Parameters:
topic- topic namerole- role nameoperation- topic operationauthData- authenticated data- Returns:
- CompletableFuture
-
removePermissionsAsync
default CompletableFuture<Void> removePermissionsAsync(org.apache.pulsar.common.naming.TopicName topicName) Remove authorization-action permissions on a topic.- Parameters:
topicName-- Returns:
- CompletableFuture
-
getPermissionsAsync
default CompletableFuture<Map<String,Set<org.apache.pulsar.common.policies.data.AuthAction>>> getPermissionsAsync(org.apache.pulsar.common.naming.TopicName topicName) Get authorization-action permissions on a topic.- Parameters:
topicName-- Returns:
- CompletableFuture<Map<String, Set
>>
-
getSubscriptionPermissionsAsync
default CompletableFuture<Map<String,Set<String>>> getSubscriptionPermissionsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName) Get authorization-action permissions on a topic.- Parameters:
namespaceName-- Returns:
- CompletableFuture<Map<String, Set
>>
-
getPermissionsAsync
default CompletableFuture<Map<String,Set<org.apache.pulsar.common.policies.data.AuthAction>>> getPermissionsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName) Get authorization-action permissions on a namespace.- Parameters:
namespaceName-- Returns:
- CompletableFuture<Map<String, Set
>>
-
allowBrokerOperationAsync
default CompletableFuture<Boolean> allowBrokerOperationAsync(String clusterName, String brokerId, org.apache.pulsar.common.policies.data.BrokerOperation brokerOperation, String role, AuthenticationDataSource authData) -
allowClusterOperationAsync
default CompletableFuture<Boolean> allowClusterOperationAsync(String clusterName, org.apache.pulsar.common.policies.data.ClusterOperation clusterOperation, String role, AuthenticationDataSource authData) -
allowClusterPolicyOperationAsync
default CompletableFuture<Boolean> allowClusterPolicyOperationAsync(String clusterName, String role, org.apache.pulsar.common.policies.data.PolicyName policy, org.apache.pulsar.common.policies.data.PolicyOperation operation, AuthenticationDataSource authData)
-