Class MultiRolesTokenAuthorizationProvider
- java.lang.Object
-
- org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider
-
- org.apache.pulsar.broker.authorization.MultiRolesTokenAuthorizationProvider
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,AuthorizationProvider
public class MultiRolesTokenAuthorizationProvider extends PulsarAuthorizationProvider
-
-
Field Summary
-
Fields inherited from class org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider
conf, pulsarResources
-
-
Constructor Summary
Constructors Constructor Description MultiRolesTokenAuthorizationProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Boolean>allowFunctionOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, java.lang.String role, AuthenticationDataSource authenticationData)Allow all function operations with in this namespace.java.util.concurrent.CompletableFuture<java.lang.Boolean>allowNamespaceOperationAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, java.lang.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.java.util.concurrent.CompletableFuture<java.lang.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, java.lang.String role, AuthenticationDataSource authData)Check if a given role is allowed to execute a given policy operation on the namespace.java.util.concurrent.CompletableFuture<java.lang.Boolean>allowSinkOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, java.lang.String role, AuthenticationDataSource authenticationData)Allow all sink operations with in this namespace.java.util.concurrent.CompletableFuture<java.lang.Boolean>allowSourceOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, java.lang.String role, AuthenticationDataSource authenticationData)Allow all source operations with in this namespace.java.util.concurrent.CompletableFuture<java.lang.Boolean>allowTenantOperationAsync(java.lang.String tenantName, java.lang.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.java.util.concurrent.CompletableFuture<java.lang.Boolean>allowTopicOperationAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.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.java.util.concurrent.CompletableFuture<java.lang.Boolean>allowTopicPolicyOperationAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, org.apache.pulsar.common.policies.data.PolicyName policyName, org.apache.pulsar.common.policies.data.PolicyOperation policyOperation, AuthenticationDataSource authData)Check if a given role is allowed to execute a given topic operation on topic's policy.java.util.concurrent.CompletableFuture<java.lang.Boolean>authorize(AuthenticationDataSource authenticationData, java.util.function.Function<java.lang.String,java.util.concurrent.CompletableFuture<java.lang.Boolean>> authorizeFunc)java.util.concurrent.CompletableFuture<java.lang.Boolean>canConsumeAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, AuthenticationDataSource authenticationData, java.lang.String subscription)Check if the specified role has permission to receive messages from the specified fully qualified topic name.java.util.concurrent.CompletableFuture<java.lang.Boolean>canLookupAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, AuthenticationDataSource authenticationData)Check whether the specified role can perform a lookup for the specified topic.java.util.concurrent.CompletableFuture<java.lang.Boolean>canProduceAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, AuthenticationDataSource authenticationData)Check if the specified role has permission to send messages to the specified fully qualified topic name.voidinitialize(ServiceConfiguration conf, PulsarResources pulsarResources)Perform initialization for the authorization provider.java.util.concurrent.CompletableFuture<java.lang.Boolean>isSuperUser(java.lang.String role, AuthenticationDataSource authenticationData, ServiceConfiguration serviceConfiguration)Check if specified role is a super user.java.util.concurrent.CompletableFuture<java.lang.Boolean>validateTenantAdminAccess(java.lang.String tenantName, java.lang.String role, AuthenticationDataSource authData)-
Methods inherited from class org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider
checkPermission, close, grantPermissionAsync, grantPermissionAsync, grantSubscriptionPermissionAsync, revokeSubscriptionPermissionAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pulsar.broker.authorization.AuthorizationProvider
allowNamespaceOperation, allowNamespaceOperation, allowNamespaceOperationAsync, allowNamespacePolicyOperation, allowNamespacePolicyOperation, allowNamespacePolicyOperationAsync, allowTenantOperation, allowTenantOperation, allowTenantOperationAsync, allowTopicOperation, allowTopicOperation, allowTopicOperationAsync, allowTopicPolicyOperation, initialize, isSuperUser, isTenantAdmin
-
-
-
-
Method Detail
-
initialize
public void initialize(ServiceConfiguration conf, PulsarResources pulsarResources) throws java.io.IOException
Description copied from interface:AuthorizationProviderPerform initialization for the authorization provider.- Specified by:
initializein interfaceAuthorizationProvider- Overrides:
initializein classPulsarAuthorizationProvider- Parameters:
conf- broker config objectpulsarResources- Resources component for access to metadata- Throws:
java.io.IOException- if the initialization fails
-
isSuperUser
public java.util.concurrent.CompletableFuture<java.lang.Boolean> isSuperUser(java.lang.String role, AuthenticationDataSource authenticationData, ServiceConfiguration serviceConfiguration)Description copied from interface:AuthorizationProviderCheck 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
-
validateTenantAdminAccess
public java.util.concurrent.CompletableFuture<java.lang.Boolean> validateTenantAdminAccess(java.lang.String tenantName, java.lang.String role, AuthenticationDataSource authData)- Overrides:
validateTenantAdminAccessin classPulsarAuthorizationProvider
-
authorize
public java.util.concurrent.CompletableFuture<java.lang.Boolean> authorize(AuthenticationDataSource authenticationData, java.util.function.Function<java.lang.String,java.util.concurrent.CompletableFuture<java.lang.Boolean>> authorizeFunc)
-
canProduceAsync
public java.util.concurrent.CompletableFuture<java.lang.Boolean> canProduceAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, AuthenticationDataSource authenticationData)Check if the specified role has permission to send messages to the specified fully qualified topic name.- Specified by:
canProduceAsyncin interfaceAuthorizationProvider- Overrides:
canProduceAsyncin classPulsarAuthorizationProvider- Parameters:
topicName- the fully qualified topic name associated with the topic.role- the app id used to send messages to the topic.
-
canConsumeAsync
public java.util.concurrent.CompletableFuture<java.lang.Boolean> canConsumeAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, AuthenticationDataSource authenticationData, java.lang.String subscription)Check if the specified role has permission to receive messages from the specified fully qualified topic name.- Specified by:
canConsumeAsyncin interfaceAuthorizationProvider- Overrides:
canConsumeAsyncin classPulsarAuthorizationProvider- 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
public java.util.concurrent.CompletableFuture<java.lang.Boolean> canLookupAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.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.
- Specified by:
canLookupAsyncin interfaceAuthorizationProvider- Overrides:
canLookupAsyncin classPulsarAuthorizationProvider- Parameters:
topicName-role-- Returns:
- Throws:
java.lang.Exception
-
allowFunctionOpsAsync
public java.util.concurrent.CompletableFuture<java.lang.Boolean> allowFunctionOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, java.lang.String role, AuthenticationDataSource authenticationData)Description copied from interface:AuthorizationProviderAllow all function operations with in this namespace.- Specified by:
allowFunctionOpsAsyncin interfaceAuthorizationProvider- Overrides:
allowFunctionOpsAsyncin classPulsarAuthorizationProvider- 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
public java.util.concurrent.CompletableFuture<java.lang.Boolean> allowSourceOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, java.lang.String role, AuthenticationDataSource authenticationData)Description copied from interface:AuthorizationProviderAllow all source operations with in this namespace.- Specified by:
allowSourceOpsAsyncin interfaceAuthorizationProvider- Overrides:
allowSourceOpsAsyncin classPulsarAuthorizationProvider- 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
public java.util.concurrent.CompletableFuture<java.lang.Boolean> allowSinkOpsAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, java.lang.String role, AuthenticationDataSource authenticationData)Description copied from interface:AuthorizationProviderAllow all sink operations with in this namespace.- Specified by:
allowSinkOpsAsyncin interfaceAuthorizationProvider- Overrides:
allowSinkOpsAsyncin classPulsarAuthorizationProvider- 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
-
allowTenantOperationAsync
public java.util.concurrent.CompletableFuture<java.lang.Boolean> allowTenantOperationAsync(java.lang.String tenantName, java.lang.String role, org.apache.pulsar.common.policies.data.TenantOperation operation, AuthenticationDataSource authData)Description copied from interface:AuthorizationProviderCheck if a given role is allowed to execute a given operation on the tenant.- Specified by:
allowTenantOperationAsyncin interfaceAuthorizationProvider- Overrides:
allowTenantOperationAsyncin classPulsarAuthorizationProvider- Parameters:
tenantName- tenant namerole- role nameoperation- tenant operationauthData- authenticated data of the role- Returns:
- a completable future represents check result
-
allowNamespaceOperationAsync
public java.util.concurrent.CompletableFuture<java.lang.Boolean> allowNamespaceOperationAsync(org.apache.pulsar.common.naming.NamespaceName namespaceName, java.lang.String role, org.apache.pulsar.common.policies.data.NamespaceOperation operation, AuthenticationDataSource authData)Description copied from interface:AuthorizationProviderCheck if a given role is allowed to execute a given operation on the namespace.- Specified by:
allowNamespaceOperationAsyncin interfaceAuthorizationProvider- Overrides:
allowNamespaceOperationAsyncin classPulsarAuthorizationProvider- Parameters:
namespaceName- namespace namerole- role nameoperation- namespace operationauthData- authenticated data- Returns:
- a completable future represents check result
-
allowNamespacePolicyOperationAsync
public java.util.concurrent.CompletableFuture<java.lang.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, java.lang.String role, AuthenticationDataSource authData)Description copied from interface:AuthorizationProviderCheck if a given role is allowed to execute a given policy operation on the namespace.- Specified by:
allowNamespacePolicyOperationAsyncin interfaceAuthorizationProvider- Overrides:
allowNamespacePolicyOperationAsyncin classPulsarAuthorizationProvider- Parameters:
namespaceName- namespace namepolicy- policy nameoperation- policy operationrole- role nameauthData- authenticated data- Returns:
- a completable future represents check result
-
allowTopicOperationAsync
public java.util.concurrent.CompletableFuture<java.lang.Boolean> allowTopicOperationAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, org.apache.pulsar.common.policies.data.TopicOperation operation, AuthenticationDataSource authData)Description copied from interface:AuthorizationProviderCheck if a given role is allowed to execute a given topic operation on the topic.- Specified by:
allowTopicOperationAsyncin interfaceAuthorizationProvider- Overrides:
allowTopicOperationAsyncin classPulsarAuthorizationProvider- Parameters:
topicName- topic namerole- role nameoperation- topic operationauthData- authenticated data- Returns:
- CompletableFuture
-
allowTopicPolicyOperationAsync
public java.util.concurrent.CompletableFuture<java.lang.Boolean> allowTopicPolicyOperationAsync(org.apache.pulsar.common.naming.TopicName topicName, java.lang.String role, org.apache.pulsar.common.policies.data.PolicyName policyName, org.apache.pulsar.common.policies.data.PolicyOperation policyOperation, AuthenticationDataSource authData)Description copied from interface:AuthorizationProviderCheck if a given role is allowed to execute a given topic operation on topic's policy.- Specified by:
allowTopicPolicyOperationAsyncin interfaceAuthorizationProvider- Overrides:
allowTopicPolicyOperationAsyncin classPulsarAuthorizationProvider- Parameters:
topicName- topic namerole- role namepolicyOperation- topic operationauthData- authenticated data- Returns:
- CompletableFuture
-
-