Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,70 @@ and [SASL authentication for ZooKeeper](https://cwiki.apache.org/confluence/disp
Then set this property **zookeeper.ssl.authProvider=[scheme]** and that provider
will be used for secure authentication.

##### LinkedIn X509 znode-group ACL support

The optional group provider maps an authenticated certificate identity to domains
stored under `/zookeeper/uri-domain-map/<domain>/<clientId>`. Each client ID is
one znode name; lookup is exact, and a client can belong to multiple domains.
The server does **not** create this mapping root. An absent root is supported:
clients initially receive their certificate identity, and a persistent recursive
watch updates connected clients when operators create, change or remove mappings.
Updates cover both secure and unified-port TLS connections.

Configure the provider in `zoo.cfg`:

```
authProvider.x509=org.apache.zookeeper.server.auth.znode.groupacl.X509ZNodeGroupAclProvider
ssl.x509.clientCertIdType=SAN
ssl.x509.clientCertIdSanMatchType=6
ssl.x509.clientCertIdSanMatchRegex=^urn:example:
```

Use the usual TLS key/trust store settings and leave `ssl.authProvider` unset;
that separate setting selects an X509 provider supplying custom TLS managers.
The group provider uses the configured stores, including password-file settings,
and does not change hostname verification, reverse DNS or FIPS policy.

The following names are `zoo.cfg` keys; Java system properties add `zookeeper.`.
SAN selection also works with the ordinary X509 provider.

| Key | Default / meaning |
| --- | --- |
| `ssl.x509.clientCertIdType` | Subject DN; `SAN` selects a subject alternative name. |
| `ssl.x509.clientCertIdSanMatchType` | Unset; SAN type 0–8, for example 6 for URI. |
| `ssl.x509.clientCertIdSanMatchRegex` | `.*`; must select exactly one SAN of the configured type. |
| `ssl.x509.clientCertIdSanExtractRegex` | `.*`; extracts from that SAN using a regex match. |
| `ssl.x509.clientCertIdSanExtractMatcherGroupIndex` | `0`; regex capture group to use as the identity. |
| `X509ZNodeGroupAclProvider.setX509ClientIdAsAcl` | `false`; replace supplied ACLs with authenticated domain/client IDs, each with ALL permissions. |
| `X509ZNodeGroupAclProvider.allowedClientIdAsAclDomains` | Empty; comma-separated IDs to use for automatic ACLs when the global switch is off. |
| `X509ZNodeGroupAclProvider.superUserId` | Empty; comma-separated certificate identities with unrestricted access and permission to choose ACLs. |
| `X509ZNodeGroupAclProvider.crossDomainAccessDomainName` | Empty; comma-separated domains with cross-domain access. Automatic ACLs for their writes use `x509:<domain>`. |
| `X509ZNodeGroupAclProvider.openReadAccessPathPrefix` | Empty; comma-separated literal path prefixes receiving `world:anyone` READ permission during enabled group ACL processing, even when supplied ownership ACLs are retained. |
| `X509ZNodeGroupAclProvider.storeAuthedClientId` | `false`; retain the certificate ID alongside mapped domains on non-dedicated servers. |
| `X509ZNodeGroupAclProvider.dedicatedDomain` | Unset; restrict TLS connections to one domain instead of applying automatic group ACLs. |
| `X509ZNodeGroupAclProvider.enforceDedicatedDomain` | `true`; when false, log a domain mismatch without disconnecting it. |

Unsuccessful SAN selection falls back to Subject DN. Unknown but trusted clients
receive `x509:<clientId>` rather than a mapped domain. Explicit creator ACLs expand
the authenticated identities normally; no SPIFFE or legacy-identity translation
is performed. Automatic ACL replacement applies to both create and setACL, not
just creation. On non-dedicated servers using the group provider, configured
open-read prefixes add READ permission when the global automatic-ACL switch is
enabled or authenticated X509 IDs match the automatic-ACL allowlist. This also
applies when a writer keeps supplied ownership ACLs: explicit X509 superusers and
non-X509 clients still undergo ordinary ACL validation, with the configured READ
permission added. Dedicated-domain mode, inactive group ACL processing and
nonmatching prefixes do not add this permission. Cross-domain users and explicit
superusers are exempt from dedicated-domain connection filtering.

Treat mapping writes as privilege changes: bootstrap the root deliberately and
protect its subtree's ACLs against unauthorized create/delete operations. The
feature does not secure plaintext listeners or make existing znodes private.
READ/watch checks and existing ACLs remain enforced. Configure the same policy
on every server before startup; configuration is cached, whereas mapping znodes
are watched dynamically. Enabling automatic ACLs or dedicated-domain enforcement
is an intentional access-policy change and should be qualified before rollout.

* *zookeeper.ensembleAuthName* :
(Java system property only: **zookeeper.ensembleAuthName**)
**New in 3.6.0:**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.apache.zookeeper.common.X509Exception.SSLContextException;
import org.apache.zookeeper.server.NettyServerCnxn.HandshakeState;
import org.apache.zookeeper.server.auth.ProviderRegistry;
import org.apache.zookeeper.server.auth.ServerAuthenticationProvider;
import org.apache.zookeeper.server.auth.X509AuthenticationProvider;
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
import org.slf4j.Logger;
Expand Down Expand Up @@ -445,15 +446,19 @@ public void operationComplete(Future<Channel> future) {

String authProviderProp = System.getProperty(x509Util.getSslAuthProviderProperty(), "x509");

X509AuthenticationProvider authProvider = (X509AuthenticationProvider) ProviderRegistry.getProvider(authProviderProp);
// All implementations of the AuthenticationProvider interface should be supported here. Currently
// any custom implementation of X509AuthenticationProvider or ServerAuthenticationProvider is
// supported with backward compatability.
ServerAuthenticationProvider authProvider = ProviderRegistry.getServerProvider(authProviderProp);
Comment thread
bellatrix007 marked this conversation as resolved.
Resolved

if (authProvider == null) {
LOG.error("X509 Auth provider not found: {}", authProviderProp);
cnxn.close(ServerCnxn.DisconnectReason.AUTH_PROVIDER_NOT_FOUND);
return;
}

KeeperException.Code code = authProvider.handleAuthentication(cnxn, null);
KeeperException.Code code = authProvider.handleAuthentication(
new ServerAuthenticationProvider.ServerObjs(zkServer, cnxn), null);
if (KeeperException.Code.OK != code) {
zkServer.serverStats().incrementAuthFailedCount();
LOG.error("Authentication failed for session 0x{}", Long.toHexString(cnxn.getSessionId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
import org.apache.jute.BinaryOutputArchive;
import org.apache.jute.Record;
import org.apache.zookeeper.CreateMode;
Expand Down Expand Up @@ -60,6 +62,8 @@
import org.apache.zookeeper.server.ZooKeeperServer.PrecalculatedDigest;
import org.apache.zookeeper.server.auth.ProviderRegistry;
import org.apache.zookeeper.server.auth.ServerAuthenticationProvider;
import org.apache.zookeeper.server.auth.X509AuthenticationConfig;
import org.apache.zookeeper.server.auth.X509AuthenticationUtil;
import org.apache.zookeeper.server.quorum.LeaderZooKeeperServer;
import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
Expand Down Expand Up @@ -1024,6 +1028,64 @@ public static List<ACL> fixupACL(String path, List<Id> authInfo, List<ACL> acls)
throw new KeeperException.InvalidACLException(path);
}
List<ACL> rv = new ArrayList<>();

// Overwrite the acl list for users (except super user) when the auth provider is
// X509ZnodeGroupAclProvider, and isX509ClientIdAsAclEnabled is true. Note that
// clientIdAsAcl can be partially enabled for specific domains by adding them to
// the allowedClientIdAsAclDomains list.
//
// Set x509 ZNode ACL as the client's corresponding domain name. This domain name denotes a
// ZNode group the client belongs to and can be derived from the client URI-domain mapping
// (UriDomainMappingHelper).
// Cases where such grouping by override applies are:
// Single domain user / cross domain components -> set (x509 : domainName) as znode ACL
// Users whose extracted clientId is not found in the ClientURIDomainMapping
// -> set (x509: clientURI) as znode ACL
// Examples that will not be handled by the "following logic" are:
// x509 super user, plaintext port clients, any user when dedicated server is enabled
// -> will go through original zk fixupACL logic
Set<String> enabledX509ClientIdAsACL = authInfo.stream()
.filter(id -> X509AuthenticationUtil.X509_SCHEME.equals(id.getScheme()))
.map(Id::getId)
.collect(Collectors.toCollection(HashSet::new));
if (!X509AuthenticationConfig.getInstance().isX509ClientIdAsAclEnabled()) {
// If clientIdAsAclEnabled is true, all the X509 auth entries should be added to the ACL. If it's not enabled,
// only preserve the ones that are present in allowedClientIdAsAclDomains. If the intersection is empty,
// overwriting the ACL will be disabled.
enabledX509ClientIdAsACL
.removeIf(id -> !X509AuthenticationConfig.getInstance().getAllowedClientIdAsAclDomains().contains(id));
}

if ((!enabledX509ClientIdAsACL.isEmpty() || X509AuthenticationConfig.getInstance().isX509ClientIdAsAclEnabled())
&& X509AuthenticationConfig.getInstance().isX509ZnodeGroupAclEnabled()
&& !X509AuthenticationConfig.getInstance().isZnodeGroupAclDedicatedServerEnabled()) {
boolean isUserProvidedAclOverriden = false;
for (Id id : authInfo) {
boolean isX509 = enabledX509ClientIdAsACL.contains(id.getId());
boolean isX509CrossDomainComponent =
id.getScheme().equals(X509AuthenticationUtil.SUPERUSER_AUTH_SCHEME)
&& !X509AuthenticationConfig.getInstance().getZnodeGroupAclSuperUserIds()
.contains(id.getId());
if (isX509 || isX509CrossDomainComponent) {
rv.add(new ACL(ZooDefs.Perms.ALL,
new Id(X509AuthenticationUtil.X509_SCHEME, id.getId())));
isUserProvidedAclOverriden = true;
}
}
// If the znode path contains open read access node path prefix, add (world:anyone, r)
if (X509AuthenticationConfig.getInstance().getZnodeGroupAclOpenReadAccessPathPrefixes()
.stream().anyMatch(path::startsWith)) {
rv.add(new ACL(ZooDefs.Perms.READ, ZooDefs.Ids.ANYONE_ID_UNSAFE));
}
if (isUserProvidedAclOverriden) {
// Only for users who are handled by the above logic, return the result,
// for others should continue to original fixupACL logic. This variable is necessary
// because if path is open read path, its open read ACL will be added to the list,
// regardless of user category, so rv's size won't be a good indicator here.
return rv;
}
Comment thread
bellatrix007 marked this conversation as resolved.
Resolved
}

for (ACL a : uniqacls) {
LOG.debug("Processing ACL: {}", a);
if (a == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public enum DisconnectReason {
AUTH_PROVIDER_NOT_FOUND("auth provider not found"),
FAILED_HANDSHAKE("Unsuccessful handshake"),
CLIENT_RATE_LIMIT("Client hits rate limiting threshold"),
CLIENT_CNX_LIMIT("Client hits connection limiting threshold");
CLIENT_CNX_LIMIT("Client hits connection limiting threshold"),
SSL_AUTH_FAILURE("ssl_auth_failure");

String disconnectReason;

Expand Down
Loading