From 370d88fd6ccdc59575c993bbb54e93cddd44b2a1 Mon Sep 17 00:00:00 2001 From: Fateh Singh Date: Tue, 24 Sep 2024 13:27:33 -0700 Subject: [PATCH 1/2] RANGER-4920: kms docker - Fix kms service url, volume support for configs --- .../config/ranger-kms/dbks-site.xml | 455 ++++++++++++++++++ .../config/ranger-kms/kms-logback.xml | 71 +++ .../config/ranger-kms/kms-site.xml | 192 ++++++++ .../config/ranger-kms/ranger-kms-site.xml | 78 +++ .../docker-compose.ranger-kms.yml | 3 + .../scripts/create-ranger-services.py | 2 +- plugin-kms/scripts/enable-kms-plugin.sh | 7 + 7 files changed, 807 insertions(+), 1 deletion(-) create mode 100755 dev-support/ranger-docker/config/ranger-kms/dbks-site.xml create mode 100644 dev-support/ranger-docker/config/ranger-kms/kms-logback.xml create mode 100644 dev-support/ranger-docker/config/ranger-kms/kms-site.xml create mode 100644 dev-support/ranger-docker/config/ranger-kms/ranger-kms-site.xml diff --git a/dev-support/ranger-docker/config/ranger-kms/dbks-site.xml b/dev-support/ranger-docker/config/ranger-kms/dbks-site.xml new file mode 100755 index 0000000000..ef586a3dbd --- /dev/null +++ b/dev-support/ranger-docker/config/ranger-kms/dbks-site.xml @@ -0,0 +1,455 @@ + + + + + + + + + hadoop.kms.blacklist.DECRYPT_EEK + hdfs + + Blacklist for decrypt EncryptedKey + CryptoExtension operations + + + + + + + ranger.db.encrypt.key.password + Str0ngPassw0rd + + Password used for encrypting Master Key + + + + + ranger.kms.service.masterkey.password.cipher + AES + + Cipher used for encrypting Master Key + + + + + ranger.kms.service.masterkey.password.size + 256 + + Size of masterkey + + + + + ranger.kms.service.masterkey.password.salt.size + 8 + + Salt size to encrypt Master Key + + + + + ranger.kms.service.masterkey.password.salt + abcdefghijklmnopqrstuvwxyz01234567890 + + Salt to encrypt Master Key + + + + + + ranger.kms.service.masterkey.password.iteration.count + 1000 + + Iteration count to encrypt Master Key + + + + + ranger.kms.service.masterkey.password.encryption.algorithm + PBEWithMD5AndDES + + Algorithm to encrypt Master Key + + + + + ranger.kms.service.masterkey.password.md.algorithm + SHA + + Message Digest algorithn to encrypt Master Key + + + + + + + ranger.ks.jpa.jdbc.url + jdbc:log4jdbc:mysql://localhost:3306/rangerkms + + URL for Database + + + + + ranger.ks.jpa.jdbc.user + kmsadmin + + Database username used for operation + + + + + ranger.ks.jpa.jdbc.password + kmsadmin + + Database user's password + + + + + ranger.ks.jpa.jdbc.credential.provider.path + /tmp/kms.jceks + + Credential provider path + + + + + ranger.ks.jpa.jdbc.credential.alias + ranger.ks.jdbc.password + + Credential alias used for password + + + + + ranger.ks.masterkey.credential.alias + ranger.ks.masterkey.password + + Credential alias used for masterkey + + + + + ranger.ks.jpa.jdbc.dialect + org.eclipse.persistence.platform.database.MySQLPlatform + + Dialect used for database + + + + + ranger.ks.jpa.jdbc.driver + net.sf.log4jdbc.DriverSpy + + Driver used for database + + + + + ranger.ks.jdbc.sqlconnectorjar + /usr/share/java/mysql-connector-java.jar + + Driver used for database + + + + + + ranger.ks.kerberos.principal + rangerkms/_HOST@REALM + + + + ranger.ks.kerberos.keytab + + + + + + + ranger.kms.keysecure.enabled + false + + + + + ranger.kms.keysecure.UserPassword.Authentication + true + + + + ranger.kms.keysecure.masterkey.name + safenetmasterkey + Safenet key secure master key name + + + ranger.kms.keysecure.login.username + user1 + Safenet key secure username + + + ranger.kms.keysecure.login.password + t1e2s3t4 + Safenet key secure user password + + + ranger.kms.keysecure.login.password.alias + ranger.ks.login.password + Safenet key secure user password + + + ranger.kms.keysecure.hostname + SunPKCS11-keysecurehn + Safenet key secure hostname + + + ranger.kms.keysecure.masterkey.size + 256 + key size + + + ranger.kms.keysecure.sunpkcs11.cfg.filepath + /opt/safenetConf/64/8.3.1/sunpkcs11.cfg + Location of Safenet key secure library configuration file + + + ranger.kms.keysecure.provider.type + SunPKCS11 + Security Provider for key secure + + + + + + ranger.kms.azurekeyvault.enabled + false + Flag for Azure Key Vault + + + ranger.kms.azure.keyvault.ssl.enabled + false + Flag for Azure authentication via certificate or password + + + ranger.kms.azure.client.id + + Azure Client Id + + + ranger.kms.azure.client.secret + + Azure Client Secret + + + ranger.kms.azure.client.secret.alias + ranger.ks.azure.client.secret + Azure Client Secret Alias + + + ranger.kms.azure.keyvault.certificate.path + /home/machine/Desktop/azureAuthCertificate/keyvault-MyCert.pfx + Azure key vault cerificate path + + + ranger.kms.azure.keyvault.certificate.password + + Azure key vault cerificate password + + + ranger.kms.azure.masterkey.name + + Azure master key name + + + ranger.kms.azure.masterkey.type + + Azure key type: RSA, RSA_HSM, EC, EC_HSM + + + ranger.kms.azure.zonekey.encryption.algorithm + + Encryption Algo : RSA_OAEP, RSA_OAEP_256, RSA1_5 + + + ranger.kms.azurekeyvault.url + + Azure Key Vault url + + + + + + ranger.kms.awskms.enabled + false + Flag for AWS KMS + + + ranger.kms.awskms.masterkey.id + + AWS KMS Master key id + + + ranger.kms.aws.client.accesskey + + AWS Client Access Key + + + ranger.kms.aws.client.secretkey + + AWS Client Secret Key + + + ranger.kms.aws.client.secretkey.alias + ranger.ks.aws.client.secretkey + AWS Client Secret Key Alias + + + ranger.kms.aws.client.region + + AWS Region + + + + + + ranger.kms.gcp.enabled + false + Flag for Google Cloud HSM e.g - true or false + + + ranger.kms.gcp.keyring.id + + Name of KeyRing. + + + ranger.kms.gcp.cred.file + + Absolute path of downloaded json credential file, e.g - /path/to/credFile.json + + + ranger.kms.gcp.project.id + + Name of project on Google Cloud HSM. + + + ranger.kms.gcp.location.id + + GCP KeyRing location id, e.g - us-east1, global etc. + + + ranger.kms.gcp.masterkey.name + + GCP Master Key Name. + + + + + + ranger.kms.tencentkms.enabled + false + Flag for Tencent KMS + + + ranger.kms.tencent.client.id + + Tencent Client Id + + + ranger.kms.tencent.client.secret + + Tencent Client Secret + + + ranger.kms.tencent.client.secret.alias + ranger.ks.tencent.client.secret + Tencent Client Secret Alias + + + ranger.kms.tencent.client.region + ap-beijing + Tencent Client Id + + + ranger.kms.tencent.masterkey.id + + Tencent master key name + + + + + + ranger.ks.hsm.type + LunaProvider + + + + + ranger.ks.hsm.enabled + false + + + + + ranger.ks.hsm.partition.name + + + + + + ranger.ks.hsm.partition.password + + + + + + ranger.ks.hsm.partition.password.alias + ranger.kms.hsm.partition.password + + + + + ranger.ks.db.ssl.enabled + false + + + ranger.ks.db.ssl.required + false + + + ranger.ks.db.ssl.verifyServerCertificate + false + + + ranger.ks.db.ssl.auth.type + 2-way + + + ranger.ks.db.ssl.certificateFile + + + + ranger.truststore.file.type + jks + + + ranger.keystore.file.type + jks + + diff --git a/dev-support/ranger-docker/config/ranger-kms/kms-logback.xml b/dev-support/ranger-docker/config/ranger-kms/kms-logback.xml new file mode 100644 index 0000000000..1e57d7cfa4 --- /dev/null +++ b/dev-support/ranger-docker/config/ranger-kms/kms-logback.xml @@ -0,0 +1,71 @@ + + + + + + + + + true + ${kms.log.dir}/kms-audit-${hostname}-${user}.log + + %d{ISO8601} %m%n + + + ${kms.log.dir}/kms-audit-${hostname}-${user}.log.%d{yyyy-MM-dd} + 15 + true + + + + + false + ${kms.log.dir}/ranger_kms_metric_data_for_${metric.type}.log + + %m%n + + + + + + + ${kms.log.dir}/ranger-kms-${hostname}-${user}.log + true + + %d{ISO8601} %-5p [%t] %c{1} \(%F:%L\) - %m%n + + + ${kms.log.dir}/ranger-kms-${hostname}-${user}.log.%d{yyyy-MM-dd} + 15 + true + + + + + + + + + + + + + + + + diff --git a/dev-support/ranger-docker/config/ranger-kms/kms-site.xml b/dev-support/ranger-docker/config/ranger-kms/kms-site.xml new file mode 100644 index 0000000000..5f2575a845 --- /dev/null +++ b/dev-support/ranger-docker/config/ranger-kms/kms-site.xml @@ -0,0 +1,192 @@ + + + + + + + + hadoop.kms.key.provider.uri + dbks://http@localhost:9292/kms + + URI of the backing KeyProvider for the KMS. + + + + + hadoop.security.keystore.JavaKeyStoreProvider.password + none + + If using the JavaKeyStoreProvider, the password for the keystore file. + + + + + + + hadoop.kms.cache.enable + true + + Whether the KMS will act as a cache for the backing KeyProvider. + When the cache is enabled, operations like getKeyVersion, getMetadata, + and getCurrentKey will sometimes return cached data without consulting + the backing KeyProvider. Cached values are flushed when keys are deleted + or modified. + + + + + hadoop.kms.cache.timeout.ms + 600000 + + Expiry time for the KMS key version and key metadata cache, in + milliseconds. This affects getKeyVersion and getMetadata. + + + + + hadoop.kms.current.key.cache.timeout.ms + 30000 + + Expiry time for the KMS current key cache, in milliseconds. This + affects getCurrentKey operations. + + + + + + + hadoop.kms.audit.aggregation.window.ms + 10000 + + Duplicate audit log events within the aggregation window (specified in + ms) are quashed to reduce log traffic. A single message for aggregated + events is printed at the end of the window, along with a count of the + number of aggregated events. + + + + + + + hadoop.kms.authentication.type + simple + + Authentication type for the KMS. Can be either "simple" + or "kerberos". + + + + + hadoop.kms.authentication.kerberos.keytab + ${user.home}/kms.keytab + + Path to the keytab with credentials for the configured Kerberos principal. + + + + + hadoop.kms.authentication.kerberos.principal + HTTP/localhost + + The Kerberos principal to use for the HTTP endpoint. + The principal must start with 'HTTP/' as per the Kerberos HTTP SPNEGO specification. + + + + + hadoop.kms.authentication.kerberos.name.rules + DEFAULT + + Rules used to resolve Kerberos principal names. + + + + + + + hadoop.kms.authentication.signer.secret.provider + random + + Indicates how the secret to sign the authentication cookies will be + stored. Options are 'random' (default), 'string' and 'zookeeper'. + If using a setup with multiple KMS instances, 'zookeeper' should be used. + + + + + + + hadoop.kms.authentication.signer.secret.provider.zookeeper.path + /hadoop-kms/hadoop-auth-signature-secret + + The Zookeeper ZNode path where the KMS instances will store and retrieve + the secret from. + + + + + hadoop.kms.authentication.signer.secret.provider.zookeeper.connection.string + #HOSTNAME#:#PORT#,... + + The Zookeeper connection string, a list of hostnames and port comma + separated. + + + + + hadoop.kms.authentication.signer.secret.provider.zookeeper.auth.type + kerberos + + The Zookeeper authentication type, 'none' or 'sasl' (Kerberos). + + + + + hadoop.kms.authentication.signer.secret.provider.zookeeper.kerberos.keytab + /etc/hadoop/conf/kms.keytab + + The absolute path for the Kerberos keytab with the credentials to + connect to Zookeeper. + + + + + hadoop.kms.authentication.signer.secret.provider.zookeeper.kerberos.principal + kms/#HOSTNAME# + + The Kerberos service principal used to connect to Zookeeper. + + + + + hadoop.kms.security.authorization.manager + org.apache.ranger.authorization.kms.authorizer.RangerKmsAuthorizer + + + + hadoop.kms.proxyuser.ranger.groups + * + + + + hadoop.kms.proxyuser.ranger.hosts + * + + + + hadoop.kms.proxyuser.ranger.users + * + + diff --git a/dev-support/ranger-docker/config/ranger-kms/ranger-kms-site.xml b/dev-support/ranger-docker/config/ranger-kms/ranger-kms-site.xml new file mode 100644 index 0000000000..8b72cc2b79 --- /dev/null +++ b/dev-support/ranger-docker/config/ranger-kms/ranger-kms-site.xml @@ -0,0 +1,78 @@ + + + + + + ranger.service.host + localhost + + + + ranger.service.http.port + 9292 + + + + ranger.service.shutdown.port + 7085 + + + + ranger.contextName + /kms + + + + xa.webapp.dir + ./webapp + + + ranger.service.https.port + 9393 + + + ranger.service.https.attrib.ssl.enabled + false + + + ajp.enabled + false + + + ranger.service.https.attrib.client.auth + want + + + ranger.credential.provider.path + /etc/ranger/kms/rangerkms.jceks + + + ranger.service.https.attrib.keystore.file + + + + ranger.service.https.attrib.keystore.keyalias + rangerkms + + + ranger.service.https.attrib.keystore.pass + + + + ranger.service.https.attrib.keystore.credential.alias + keyStoreCredentialAlias + + + diff --git a/dev-support/ranger-docker/docker-compose.ranger-kms.yml b/dev-support/ranger-docker/docker-compose.ranger-kms.yml index 3808e424ef..7d72e0fa39 100644 --- a/dev-support/ranger-docker/docker-compose.ranger-kms.yml +++ b/dev-support/ranger-docker/docker-compose.ranger-kms.yml @@ -12,6 +12,8 @@ services: hostname: ranger-kms.example.com stdin_open: true tty: true + volumes: + - ./config/ranger-kms:/opt/ranger/kms/ews/webapp/WEB-INF/classes/conf networks: - ranger ports: @@ -22,6 +24,7 @@ services: environment: - KMS_VERSION - RANGER_DB_TYPE + - KMS_IN_DOCKER=true command: - /home/ranger/scripts/ranger-kms.sh diff --git a/dev-support/ranger-docker/scripts/create-ranger-services.py b/dev-support/ranger-docker/scripts/create-ranger-services.py index 45d6a77915..b701bf7e07 100644 --- a/dev-support/ranger-docker/scripts/create-ranger-services.py +++ b/dev-support/ranger-docker/scripts/create-ranger-services.py @@ -47,7 +47,7 @@ def service_not_exists(service): kms = RangerService({'name': 'dev_kms', 'type': 'kms', 'configs': {'username': 'keyadmin', 'password': 'rangerR0cks!', - 'provider': 'http://ranger-kms:9292'}}) + 'provider': 'dbks://http@ranger-kms:9292/kms'}}) trino = RangerService({'name': 'dev_trino', 'type': 'trino', diff --git a/plugin-kms/scripts/enable-kms-plugin.sh b/plugin-kms/scripts/enable-kms-plugin.sh index d8ace8628b..f1649f1c71 100755 --- a/plugin-kms/scripts/enable-kms-plugin.sh +++ b/plugin-kms/scripts/enable-kms-plugin.sh @@ -377,6 +377,13 @@ then fi archivefn="${HCOMPONENT_CONF_DIR}/.${orgfn}.${dt}" newfn="${HCOMPONENT_CONF_DIR}/.${orgfn}-new.${dt}" + if [ "${KMS_IN_DOCKER}" ]; then + TEMP_DIR="${HCOMPONENT_ + CONF_DIR}"/saved + mkdir "${TEMP_DIR}" + archivefn="${TEMP_DIR}/.${orgfn}.${dt}" + newfn="${TEMP_DIR}/.${orgfn}-new.${dt}" + fi log "Saving current config file: ${fullpathorgfn} to ${archivefn} ..." cp ${fullpathorgfn} ${archivefn} if [ $? -eq 0 ] From c5a57e3e0a2d55506312b6e8b4f3aeba00ae5db7 Mon Sep 17 00:00:00 2001 From: Fateh Singh Date: Mon, 30 Sep 2024 09:42:13 -0700 Subject: [PATCH 2/2] RANGER-4920: review comment - remove extra line --- plugin-kms/scripts/enable-kms-plugin.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin-kms/scripts/enable-kms-plugin.sh b/plugin-kms/scripts/enable-kms-plugin.sh index f1649f1c71..a1941e444c 100755 --- a/plugin-kms/scripts/enable-kms-plugin.sh +++ b/plugin-kms/scripts/enable-kms-plugin.sh @@ -378,8 +378,7 @@ then archivefn="${HCOMPONENT_CONF_DIR}/.${orgfn}.${dt}" newfn="${HCOMPONENT_CONF_DIR}/.${orgfn}-new.${dt}" if [ "${KMS_IN_DOCKER}" ]; then - TEMP_DIR="${HCOMPONENT_ - CONF_DIR}"/saved + TEMP_DIR="${HCOMPONENT_CONF_DIR}"/saved mkdir "${TEMP_DIR}" archivefn="${TEMP_DIR}/.${orgfn}.${dt}" newfn="${TEMP_DIR}/.${orgfn}-new.${dt}"