navinko commented on code in PR #9868: URL: https://github.com/apache/ozone/pull/9868#discussion_r3079888194
########## hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/kerberos/AuthorizationProbe.java: ########## @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.debug.kerberos; + +import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_AUTHORIZATION_ENABLED; +import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SECURITY_ENABLED_KEY; + +import org.apache.hadoop.fs.CommonConfigurationKeysPublic; +import org.apache.hadoop.hdds.HddsConfigKeys; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.ozone.OzoneConfigKeys; +import org.apache.hadoop.ozone.om.OMConfigKeys; + +/** + * Validates Ozone and Hadoop RPC authorization configuration. + * Checks whether Hadoop authorization and Ozone ACL settings are enabled + * and properly configured. + * Missing or disabled authorization is reported as a warning. + */ +public class AuthorizationProbe extends ConfigProbe { + + @Override + public String name() { + return "Authorization Configuration"; + } + + @Override + public ProbeResult test(OzoneConfiguration conf) { + + // Print relevant configs + print(conf, OZONE_SECURITY_ENABLED_KEY); + print(conf, OZONE_AUTHORIZATION_ENABLED); + print(conf, OzoneConfigKeys.OZONE_ACL_ENABLED); + print(conf, OzoneConfigKeys.OZONE_ACL_AUTHORIZER_CLASS); + + print(conf, CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION); + print(conf, OMConfigKeys.OZONE_OM_SECURITY_CLIENT_PROTOCOL_ACL); + + print(conf, HddsConfigKeys.HDDS_SECURITY_CLIENT_DATANODE_CONTAINER_PROTOCOL_ACL); + print(conf, HddsConfigKeys.HDDS_SECURITY_CLIENT_SCM_CONTAINER_PROTOCOL_ACL); + print(conf, HddsConfigKeys.HDDS_SECURITY_CLIENT_SCM_BLOCK_PROTOCOL_ACL); + print(conf, HddsConfigKeys.HDDS_SECURITY_CLIENT_SCM_CERTIFICATE_PROTOCOL_ACL); + + ProbeResult result = ProbeResult.PASS; + + // Validate Ozone security if enabled + boolean ozoneSecurityEnabled = conf.getBoolean(OZONE_SECURITY_ENABLED_KEY, + OzoneConfigKeys.OZONE_SECURITY_ENABLED_DEFAULT); + + // If security disabled, no need to check further. + if (!ozoneSecurityEnabled) { + warn("Ozone security is disabled (" + + OZONE_SECURITY_ENABLED_KEY + "=" + ozoneSecurityEnabled + ". " + + "Authorization checks are not enforced in non-secure mode."); + return ProbeResult.WARN; // not a failure + } + + // Validate Ozone authorization(master switch) + boolean ozoneAuthEnabled = conf.getBoolean(OZONE_AUTHORIZATION_ENABLED, + OzoneConfigKeys.OZONE_AUTHORIZATION_ENABLED_DEFAULT); + + if (!ozoneAuthEnabled) { + warn("Ozone authorization is disabled (" + + OZONE_AUTHORIZATION_ENABLED + "=" + ozoneAuthEnabled + ". " + + "No admin or ACL checks will be enforced."); + result = ProbeResult.WARN; + } + + // Validate Hadoop authorization + boolean hadoopAuthEnabled = conf.getBoolean( + CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, false); + + if (!hadoopAuthEnabled) { + warn("Hadoop authorization is disabled"); + result = ProbeResult.WARN; + } + + // Validate Ozone ACLs enforcement + boolean ozoneAclEnabled = conf.getBoolean( + OzoneConfigKeys.OZONE_ACL_ENABLED, false); Review Comment: upodated. ########## hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/kerberos/PrincipalMappingProbe.java: ########## @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.debug.kerberos; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.apache.hadoop.hdds.HddsConfigKeys; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.hdds.recon.ReconConfig; +import org.apache.hadoop.hdds.scm.ScmConfig; +import org.apache.hadoop.ozone.om.OMConfigKeys; +import org.apache.hadoop.security.authentication.util.KerberosName; + +/** + * Validates auth_to_local principal mapping. + */ +public class PrincipalMappingProbe extends ConfigProbe { + + @Override + public String name() { + return "Auth-to-Local Mapping"; + } + + @Override + public ProbeResult test(OzoneConfiguration conf) { + + // Check if krb5.conf is empty or missing ? + // as it causes KerberosName to fail + File krbConfig = getKrb5ConfigFile(); + if (!canReadFile(krbConfig, "krb5.conf")) { + error("Kerberos configuration file (" + krbConfig.getAbsolutePath() + + ") is missing or empty. Mapping validation cannot proceed."); + return ProbeResult.FAIL; + } + + // Read rule + String rules = conf.getTrimmed( + "hadoop.security.auth_to_local", "DEFAULT"); Review Comment: changed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
