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
21 changes: 21 additions & 0 deletions zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,27 @@ the variable does.
(Java system property: **zookeeper.skipACL**)
Skips ACL checks. This results in a boost in throughput,
but opens up full access to the data tree to everyone.
Supported values are **yes** (skip ACL checks), **dryrun** and
**no** (default, enforce ACL checks). In **dryrun** mode the ACL checks are
still evaluated, but a request that would have been rejected with
NOAUTH is allowed and a warning is logged instead (path, requested permission,
session id, client address, client authentication identities and node ACL).
Identities are logged as scheme:user, omitting digest password hashes.
This can be used to audit the impact of enforcing ACLs before turning them on.
Note that dryrun does not provide the throughput boost of **yes** and, like
**yes**, leaves the data tree open to everyone.
Comment thread
bellatrix007 marked this conversation as resolved.
Resolved
The Java system-property value is case-sensitive and is not trimmed.
Any value other than **yes** or **dryrun**, including an invalid value,
enforces ACL checks. When configured through **zoo.cfg**, the configuration
parser trims surrounding whitespace before setting this property.
The property is read when the server class is initialized; changing it
requires a server restart.

Compared with 3.6.3-35, ZooKeeper 3.8.7 checks READ permission for
`exists()` on existing znodes. In **dryrun** mode, high-frequency
`exists()` requests that would be denied can therefore generate additional
WARN log volume. Assess logging throughput and storage before enabling
**dryrun** for such workloads.

* *quorumListenOnAllIPs* :
When set to true the ZooKeeper server will listen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
import org.apache.zookeeper.server.quorum.ReadOnlyZooKeeperServer;
import org.apache.zookeeper.server.util.AuthUtil;
import org.apache.zookeeper.server.util.JvmPauseMonitor;
import org.apache.zookeeper.server.util.OSMXBean;
import org.apache.zookeeper.server.util.QuotaMetricsUtils;
Expand All @@ -106,6 +107,7 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {

public static final String ENABLE_EAGER_ACL_CHECK = "zookeeper.enableEagerACLCheck";
public static final String SKIP_ACL = "zookeeper.skipACL";
public static final String SKIP_ACL_DRYRUN = "dryrun";
public static final String EPHEMERAL_NODES_TOTAL_BYTE_LIMIT_KEY = "zookeeper.ephemeralNodes.total.byte.limit";
public static final int DEFAULT_EPHEMERAL_NODES_TOTAL_BYTE_LIMIT = -1;
private static int ephemeralCountLimit;
Expand All @@ -118,6 +120,9 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {

static final boolean skipACL;

// When zookeeper.skipACL=dryrun, evaluate ACL checks but only log failures.
static final boolean skipACLDryRun;

public static final boolean enforceQuota;

public static final String SASL_SUPER_USER = "zookeeper.superUser";
Expand All @@ -143,9 +148,14 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
enableEagerACLCheck = Boolean.getBoolean(ENABLE_EAGER_ACL_CHECK);
LOG.info("{} = {}", ENABLE_EAGER_ACL_CHECK, enableEagerACLCheck);

skipACL = System.getProperty(SKIP_ACL, "no").equals("yes");
String skipACLValue = System.getProperty(SKIP_ACL, "no");
skipACL = skipACLValue.equals("yes");
skipACLDryRun = skipACLValue.equals(SKIP_ACL_DRYRUN);
if (skipACL) {
LOG.info("{}==\"yes\", ACL checks will be skipped", SKIP_ACL);
} else if (skipACLDryRun) {
LOG.info("{}==\"{}\", ACL checks will be evaluated but failures will only be logged, requests will not be rejected",
SKIP_ACL, SKIP_ACL_DRYRUN);
}

enforceQuota = Boolean.parseBoolean(System.getProperty(ENFORCE_QUOTA, "false"));
Expand Down Expand Up @@ -2026,18 +2036,20 @@ public void dumpMonitorValues(BiConsumer<String, Object> response) {
* @param setAcls : for set ACL operations, the list of ACLs being set. Otherwise null.
*/
public void checkACL(ServerCnxn cnxn, List<ACL> acl, int perm, List<Id> ids, String path, List<ACL> setAcls) throws KeeperException.NoAuthException {
checkACLWithContext(new ServerAuthenticationProvider.ServerObjs(this, cnxn), acl, perm, ids, path, setAcls);
checkACLWithContext(new ServerAuthenticationProvider.ServerObjs(this, cnxn),
cnxn == null ? -1 : cnxn.getSessionId(), acl, perm, ids, path, setAcls);
}

public void checkACL(Request request, List<ACL> acl, int perm, String path, List<ACL> setAcls)
throws KeeperException.NoAuthException {
checkACLWithContext(
new ServerAuthenticationProvider.ServerObjs(this, request.cnxn, request.getX509ClientIdentity()),
acl, perm, request.authInfo, path, setAcls);
request.sessionId, acl, perm, request.authInfo, path, setAcls);
}

private void checkACLWithContext(ServerAuthenticationProvider.ServerObjs serverObjs, List<ACL> acl, int perm,
List<Id> ids, String path, List<ACL> setAcls) throws KeeperException.NoAuthException {
private void checkACLWithContext(ServerAuthenticationProvider.ServerObjs serverObjs, long sessionId,
List<ACL> acl, int perm, List<Id> ids, String path, List<ACL> setAcls)
throws KeeperException.NoAuthException {
if (skipACL) {
return;
}
Expand Down Expand Up @@ -2073,9 +2085,35 @@ private void checkACLWithContext(ServerAuthenticationProvider.ServerObjs serverO
}
}
}
if (skipACLDryRun) {
ServerCnxn cnxn = serverObjs.getCnxn();
List<String> clientAuth = new ArrayList<>();
for (Id authId : ids) {
clientAuth.add(describeIdForLog(authId));
}
List<String> nodeACL = new ArrayList<>();
for (ACL a : acl) {
nodeACL.add(describeIdForLog(a.getId()) + ":" + a.getPerms());
}
LOG.warn("{}=\"{}\": ACL check would have failed, request is allowed. path={}, requestedPerm={}, "
+ "sessionId=0x{}, clientAddress={}, clientAuth={}, nodeACL={}",
SKIP_ACL, SKIP_ACL_DRYRUN, path, perm, Long.toHexString(sessionId),
cnxn == null ? null : cnxn.getRemoteSocketAddress(), clientAuth, nodeACL);
return;
}
throw new KeeperException.NoAuthException();
}

// Format as scheme:user so that credentials (e.g. digest password hashes) are not logged.
private static String describeIdForLog(Id id) {
String scheme = id.getScheme();
if ("world".equals(scheme) || "auth".equals(scheme)) {
return scheme + ":" + id.getId();
}
String user = id.getId() == null ? null : AuthUtil.getUser(id);
return user == null ? scheme : scheme + ":" + user;
}

/**
* check a path whether exceeded the quota.
*
Expand Down
Loading