You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "shashwatsai (via GitHub)" <gi...@apache.org> on 2025/02/10 21:05:47 UTC

[PR] [Feature] Add Support for encrypting config fields [seatunnel-web]

shashwatsai opened a new pull request, #278:
URL: https://github.com/apache/seatunnel-web/pull/278

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
   
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   
   -->
   
   ## Purpose of this pull request
   
   While writing intermediate config to submit job via seatunnel client, we are required to encrypt certain fields like password, auth, username
   
   By Default no encryption would be done, to enable the encryption provide the following properties
   
   ```
   seatunnel-web:
     datasource:
       encryption:
         type: your_encryption
         keys-to-encrypt:
           - password
           - auth
   ```
   
   ref: https://seatunnel.apache.org/docs/2.3.9/connector-v2/Config-Encryption-Decryption/
   
   ## Check list
   
   * [x] Code changed are covered with tests, or it does not need tests for reason:
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature] Add Support for encrypting config fields [seatunnel-web]

Posted by "arshadmohammad (via GitHub)" <gi...@apache.org>.
arshadmohammad merged PR #278:
URL: https://github.com/apache/seatunnel-web/pull/278


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature] Add Support for encrypting config fields [seatunnel-web]

Posted by "arshadmohammad (via GitHub)" <gi...@apache.org>.
arshadmohammad commented on code in PR #278:
URL: https://github.com/apache/seatunnel-web/pull/278#discussion_r1950350248


##########
seatunnel-server/seatunnel-app/src/main/resources/application.yml:
##########
@@ -52,7 +52,13 @@ jwt:
   secretKey:
   algorithm: HS256
 
-
+seatunnel-web:

Review Comment:
   In an earlier PR, we placed the Seatunnel-web specific configuration under the spring config section. 
   You have now put seatunnel-web specific configuration under the seatunnel-web config section.
    This seems to be a better approach. Later, we can also move the configurations from the earlier PR under the seatunnel-web config section.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature] Add Support for encrypting config fields [seatunnel-web]

Posted by "arshadmohammad (via GitHub)" <gi...@apache.org>.
arshadmohammad commented on code in PR #278:
URL: https://github.com/apache/seatunnel-web/pull/278#discussion_r1950372896


##########
seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/utils/ConfigShadeUtil.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.seatunnel.app.utils;
+
+import org.apache.seatunnel.app.config.EncryptionConfig;
+import org.apache.seatunnel.core.starter.utils.ConfigShadeUtils;
+import org.apache.seatunnel.server.common.SeatunnelErrorEnum;
+import org.apache.seatunnel.server.common.SeatunnelException;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.Map;
+
+@Slf4j
+@Component
+public class ConfigShadeUtil {
+
+    @Autowired private EncryptionConfig encryptionConfig;
+
+    public void encryptData(Map<String, String> datasourceConfig) {
+        for (String key : encryptionConfig.getKeysToEncrypt()) {

Review Comment:
    When encryption type is default it does not do any encoding/decoding. can we simply return from where when encoding is default.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature] Add Support for encrypting config fields [seatunnel-web]

Posted by "arshadmohammad (via GitHub)" <gi...@apache.org>.
arshadmohammad commented on code in PR #278:
URL: https://github.com/apache/seatunnel-web/pull/278#discussion_r1950374695


##########
seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/service/impl/JobInstanceServiceImpl.java:
##########
@@ -324,6 +331,10 @@ public String generateJobConfig(
         if (sinkMap.size() > 0) {
             sinks = getConnectorConfig(sinkMap);
         }
+        envConfig =

Review Comment:
   add this config only when encryption is enabled.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature] Add Support for encrypting config fields [seatunnel-web]

Posted by "arshadmohammad (via GitHub)" <gi...@apache.org>.
arshadmohammad commented on code in PR #278:
URL: https://github.com/apache/seatunnel-web/pull/278#discussion_r1950373188


##########
seatunnel-server/seatunnel-app/src/main/resources/application.yml:
##########
@@ -52,7 +52,13 @@ jwt:
   secretKey:
   algorithm: HS256
 
-
+seatunnel-web:
+  datasource:
+    encryption:
+      type: default

Review Comment:
   can we use none instead of default



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org