nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi] natural commented on a change in pull request #3672: NIFI-6363 Additional Sensitive Property Providers
Date Wed, 04 Sep 2019 16:54:40 GMT
natural commented on a change in pull request #3672: NIFI-6363 Additional Sensitive Property
Providers
URL: https://github.com/apache/nifi/pull/3672#discussion_r320867401
 
 

 ##########
 File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/sensitive/gcp/kms/GCPKMSSensitivePropertyProvider.java
 ##########
 @@ -0,0 +1,187 @@
+/*
+ * 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.nifi.properties.sensitive.gcp.kms;
+
+import com.google.cloud.kms.v1.CryptoKeyName;
+import com.google.cloud.kms.v1.DecryptResponse;
+import com.google.cloud.kms.v1.EncryptResponse;
+import com.google.cloud.kms.v1.KeyManagementServiceClient;
+import com.google.protobuf.ByteString;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.properties.sensitive.SensitivePropertyConfigurationException;
+import org.apache.nifi.properties.sensitive.SensitivePropertyProtectionException;
+import org.apache.nifi.properties.sensitive.SensitivePropertyProvider;
+import org.bouncycastle.util.encoders.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * This provider uses the GCP SDK to interact with the GCP KMS.  Values are encoded/decoded
base64, using the
+ * standard encoders from bouncycastle.
+ */
+public class GCPKMSSensitivePropertyProvider implements SensitivePropertyProvider {
+    private static final Logger logger = LoggerFactory.getLogger(GCPKMSSensitivePropertyProvider.class);
+    private static final String IMPLEMENTATION_NAME = "GCP KMS Sensitive Property Provider";
+
+    private static final String MATERIAL_PREFIX = "gcp";
+    private static final String MATERIAL_KEY_TYPE = "kms";
+    private static final String MATERIAL_SEPARATOR = "/";
+    private static final String IMPLEMENTATION_PREFIX = MATERIAL_PREFIX + MATERIAL_SEPARATOR
+ MATERIAL_KEY_TYPE + MATERIAL_SEPARATOR;
+
+    private String keyId;
+    private String projectId;
+    private String locationId;
+    private String keyRingId;
+    private String cryptoKeyId;
+
+    private final String resource;
+    private final KeyManagementServiceClient client;
+
+
+    public GCPKMSSensitivePropertyProvider(String keyId) {
+        if (StringUtils.isBlank(System.getenv("GOOGLE_APPLICATION_CREDENTIALS"))) {
 
 Review comment:
   I'm reluctant to change this behavior because it matches the recommendations (https://cloud.google.com/docs/authentication/getting-started).
   
   Also, these SPP classes need their configuration to exist outside of nifi (in system props,
environment vars, etc) so I'm not sure if we can prevent bad things from happening in these
cases.
   
   For now I think we're going to resolve this via documentation.
   
   Thanks again for the feedback.  If I've missed something or if you feel strongly about
this, please let me know.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message