Interface AuthCache
public interface AuthCache
Cache containing authorization and authentication metadata. This is obtained from
a Kafka metadata topic.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThe result of a health check call. -
Method Summary
Modifier and TypeMethodDescriptionCollection<org.apache.kafka.common.acl.AclBinding> aclBindings(io.confluent.security.authorizer.Scope scope, org.apache.kafka.common.acl.AclBindingFilter aclBindingFilter, Predicate<io.confluent.security.authorizer.ResourcePattern> resourceAccess) Returns ACL bindings which match the provided filter.Map<io.confluent.security.authorizer.ResourcePattern, Set<io.confluent.security.authorizer.AccessRule>> aclRules(io.confluent.security.authorizer.Scope scope) Returns the ACL rules for all resources of given scopevoidaddMatchingRules(io.confluent.security.authorizer.provider.ResourceAuthorizeRules matchingRules, org.apache.kafka.common.security.auth.KafkaPrincipal userPrincipal, Set<org.apache.kafka.common.security.auth.KafkaPrincipal> groupPrincipals, String host, io.confluent.security.roledefinitions.Operation operation, io.confluent.security.authorizer.Scope scope, io.confluent.security.roledefinitions.ResourceType resourceType) Adds RBAC or ACL rules for the specified principals that match the provided parameters to `matchingRules`.default Collection<CertIdentityPool> findCertIdentityPools(X509Certificate cert, String organizationId, String providerId) Return the cert identity pools that match the given certificate metadata and organization id.default Collection<CertIdentityPool> findCertIdentityPools(Map<String, String> parsedCertMetadata, String organizationId, String providerId) Return the cert identity pools that match the given certificate metadata and organization id.default Collection<CaCertificatesKey> findCertIdentityProviders(Certificate[] certificates, String organizationId) Return the collections of identity providers that match the provided certificate chain.io.confluent.security.authorizer.provider.AuthorizeRulefindRule(org.apache.kafka.common.security.auth.KafkaPrincipal userPrincipal, Set<org.apache.kafka.common.security.auth.KafkaPrincipal> groupPrincipals, String host, io.confluent.security.authorizer.Action action) Returns RBAC or ACL rule that matches the specified action.default Certificate[]getCertChain(Certificate[] partialChain, String organizationId) Given a partial cert chain and organization id, return the complete certificate chain for the org if applicable.Set<org.apache.kafka.common.security.auth.KafkaPrincipal> groups(org.apache.kafka.common.security.auth.KafkaPrincipal sessionPrincipal) Returns the groups of the provided session principal.health check method which returns the health of the underlying auth storedefault booleanisCompleteCertChain(Certificate[] certChain, String organizationId) Check if the certificate chain is complete, which means: - all certificates in the chain must form a valid chain, i.e., each certificate in the chain is signed by the next certificate - the last certificate in the chain must be present in the trust store, i.e., there exists a cert identity provider that has the last certificate in the chain.default booleanisRevoked(Certificate[] certificates, String organizationId, String providerId) Given a chain of certificates from leaf up to root, return whether any cert in the chain is revoked.default booleanisRevoked(X509Certificate certificate, String organizationId, String providerId) Return whether the certificate is revoked.Set<io.confluent.security.authorizer.Scope> Returns all Scopes known by the backend, regardless of whether or not they actually exist.Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(io.confluent.security.authorizer.Scope scope) Returns the role bindings at the specified scope.Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(io.confluent.security.rbac.RoleBindingFilter filter) Returns role bindings that match the specified filter.Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(Set<io.confluent.security.authorizer.Scope> scopes) Returns all the role bindings from a set of scopes.Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(org.apache.kafka.common.security.auth.KafkaPrincipal principal) Returns role bindings for the given principal and the principals groups across all known scopes.Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(org.apache.kafka.common.security.auth.KafkaPrincipal principal, Set<io.confluent.security.authorizer.Scope> scopes) Returns role bindings for the given principal and the principals groups limited to the defined set of Scopes.io.confluent.security.roledefinitions.RbacRolesReturns the RBAC role definitions associated with this cache.io.confluent.security.authorizer.ScopeReturns the root scope of this cache.voidupdateAuthCacheExternally(String key, String value) io.confluent.security.rbac.UserMetadatauserMetadata(org.apache.kafka.common.security.auth.KafkaPrincipal userPrincipal) Returns metadata for the specified user principal if available or null if user is not known.Map<org.apache.kafka.common.security.auth.KafkaPrincipal, io.confluent.security.rbac.UserMetadata> users()Returns user metadata for all users.
-
Method Details
-
groups
Set<org.apache.kafka.common.security.auth.KafkaPrincipal> groups(org.apache.kafka.common.security.auth.KafkaPrincipal sessionPrincipal) Returns the groups of the provided session principal.- Parameters:
sessionPrincipal- User principal of the session which may contains groups- Returns:
- Set of group principals of the user, which may be empty
-
rbacRoleBindings
Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(io.confluent.security.authorizer.Scope scope) Returns the role bindings at the specified scope. Note that roles bindings of parent scopes are not returned. The returned collection may be empty.- Parameters:
scope- Scope for which role bindings are requested.- Returns:
- Set of roles currently assigned at the specified scope
-
rbacRoleBindings
Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(Set<io.confluent.security.authorizer.Scope> scopes) Returns all the role bindings from a set of scopes. Note that roles bindings of parent scopes are not returned. The returned collection may be empty.- Parameters:
scopes- Scopes for which role bindings are requested.- Returns:
- Set of roles currently assigned at the specified scopes
-
rbacRoleBindings
Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(io.confluent.security.rbac.RoleBindingFilter filter) Returns role bindings that match the specified filter.- Parameters:
filter- The filter used for matching role bindings- Returns:
- Set of role bindings that match the filter
-
rbacRoleBindings
Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(org.apache.kafka.common.security.auth.KafkaPrincipal principal) Returns role bindings for the given principal and the principals groups across all known scopes.- Parameters:
principal- The the principal to lookup rolebindings for- Returns:
- Set of role bindings for that principal and it's groups
-
rbacRoleBindings
Set<io.confluent.security.rbac.RoleBinding> rbacRoleBindings(org.apache.kafka.common.security.auth.KafkaPrincipal principal, Set<io.confluent.security.authorizer.Scope> scopes) Returns role bindings for the given principal and the principals groups limited to the defined set of Scopes.- Parameters:
principal- The the principal to lookup rolebindings for- Returns:
- Set of role bindings for that principal and it's groups in the provided scopes
-
userMetadata
io.confluent.security.rbac.UserMetadata userMetadata(org.apache.kafka.common.security.auth.KafkaPrincipal userPrincipal) Returns metadata for the specified user principal if available or null if user is not known.- Parameters:
userPrincipal- KafkaPrincipal of user- Returns:
- user metadata including group membership
-
users
Map<org.apache.kafka.common.security.auth.KafkaPrincipal, io.confluent.security.rbac.UserMetadata> users()Returns user metadata for all users. -
knownScopes
Set<io.confluent.security.authorizer.Scope> knownScopes()Returns all Scopes known by the backend, regardless of whether or not they actually exist.- Returns:
- Set of all
Scopesknown by this AuthCache
-
rootScope
io.confluent.security.authorizer.Scope rootScope()Returns the root scope of this cache. The cache discards entries with scope that is not contained within the root scope.- Returns:
- root scope of cache
-
rbacRoles
io.confluent.security.roledefinitions.RbacRoles rbacRoles()Returns the RBAC role definitions associated with this cache.- Returns:
- RBAC role definitions
-
aclRules
Map<io.confluent.security.authorizer.ResourcePattern, Set<io.confluent.security.authorizer.AccessRule>> aclRules(io.confluent.security.authorizer.Scope scope) Returns the ACL rules for all resources of given scope- Parameters:
scope- Scope of the resources- Returns:
- ACL rules for all resources of given scope
-
aclBindings
Collection<org.apache.kafka.common.acl.AclBinding> aclBindings(io.confluent.security.authorizer.Scope scope, org.apache.kafka.common.acl.AclBindingFilter aclBindingFilter, Predicate<io.confluent.security.authorizer.ResourcePattern> resourceAccess) Returns ACL bindings which match the provided filter.- Parameters:
scope- Scope of the acl search.aclBindingFilter- AclBindingFilter to matchresourceAccess- predicate to check resource access permission- Returns:
- Set of ACL bindings which match the provided aclBindingFilter
-
findRule
io.confluent.security.authorizer.provider.AuthorizeRule findRule(org.apache.kafka.common.security.auth.KafkaPrincipal userPrincipal, Set<org.apache.kafka.common.security.auth.KafkaPrincipal> groupPrincipals, String host, io.confluent.security.authorizer.Action action) Returns RBAC or ACL rule that matches the specified action.- Parameters:
userPrincipal- User principalgroupPrincipals- Set of group principals of the userhost- Client IP addressaction- Action to match including resource pattern and operation- Returns:
- Access rule that matches the principals and action
-
addMatchingRules
void addMatchingRules(io.confluent.security.authorizer.provider.ResourceAuthorizeRules matchingRules, org.apache.kafka.common.security.auth.KafkaPrincipal userPrincipal, Set<org.apache.kafka.common.security.auth.KafkaPrincipal> groupPrincipals, String host, io.confluent.security.roledefinitions.Operation operation, io.confluent.security.authorizer.Scope scope, io.confluent.security.roledefinitions.ResourceType resourceType) Adds RBAC or ACL rules for the specified principals that match the provided parameters to `matchingRules`. -
findCertIdentityPools
default Collection<CertIdentityPool> findCertIdentityPools(X509Certificate cert, String organizationId, String providerId) Return the cert identity pools that match the given certificate metadata and organization id. The providerId is optional to provide extra filtering.- Parameters:
cert- X509 certificate of the clientorganizationId- organization id, must not be null or emptyproviderId- provider id or null if not available- Returns:
- Collection of cert identity pools
-
findCertIdentityPools
default Collection<CertIdentityPool> findCertIdentityPools(Map<String, String> parsedCertMetadata, String organizationId, String providerId) Return the cert identity pools that match the given certificate metadata and organization id. The providerId is optional to provide extra filtering.- Parameters:
parsedCertMetadata- parsed certificate metadata of the client, as Common Expression Language (CEL) variablesorganizationId- organization id, must not be null or emptyproviderId- provider id or null if not available- Returns:
- Collection of cert identity pools
-
findCertIdentityProviders
default Collection<CaCertificatesKey> findCertIdentityProviders(Certificate[] certificates, String organizationId) Return the collections of identity providers that match the provided certificate chain. Note that the function doesn't check the validity of the certificate chain. It is the caller's responsibility to ensure that the certificate chain is valid, and the order of the certificate chain is correct, i.e., from leaf to root.- Parameters:
certificates- Certificate chain, it must not be null or empty (the first certificate is the end-entity certificate)organizationId- Organization ID, it must not be null or empty- Returns:
- Collection of identity providers that match the certificate chain
-
isRevoked
Return whether the certificate is revoked.- Parameters:
certificate- X509 certificate to check for revocationorganizationId- organization id, must not be null or emptyproviderId- provider id, must not be null or empty- Returns:
- true if the certificate is revoked, false otherwise
-
isRevoked
Given a chain of certificates from leaf up to root, return whether any cert in the chain is revoked.- Parameters:
certificates- X509 certificate chain to check for revocationorganizationId- organization id, must not be null or emptyproviderId- provider id, must not be null or empty- Returns:
- true if any of the certificates in the chain is revoked, false otherwise
-
isCompleteCertChain
Check if the certificate chain is complete, which means: - all certificates in the chain must form a valid chain, i.e., each certificate in the chain is signed by the next certificate - the last certificate in the chain must be present in the trust store, i.e., there exists a cert identity provider that has the last certificate in the chain. Note: the last certificate in the complete certificate chain is not necessarily a root CA certificate.- Parameters:
certChain- X509 cert chain must not be null or emptyorganizationId- organization id, must not be null or empty- Returns:
- true if the certificate chain is complete.
-
getCertChain
Given a partial cert chain and organization id, return the complete certificate chain for the org if applicable. A complete certificate chain is a chain of certificates that satisfies the following conditions: - all certificates in the chain must form a valid chain, i.e., each certificate in the chain is signed by the next certificate - the last certificate (CA) in the chain must be present in the trust store, i.e., there exists a cert identity provider that has the last certificate in the chain. Note: the last certificate in the complete certificate chain is not necessarily a root CA certificate.- Parameters:
partialChain- partial cert chain must not be null or empty, and the first certificate in the chain must be the end-entity certificateorganizationId- organization id, must not be null or empty- Returns:
- Certificate chain, it must not be null or empty
-
healthcheck
AuthCache.Result healthcheck()health check method which returns the health of the underlying auth store- Returns:
- Result object
-
updateAuthCacheExternally
-