You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/07/19 07:50:55 UTC

[incubator-devlake] 01/06: fix: jira verify enckey and jira encode password

This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 8a017cc8e5b06970a7469dbd51b31ac240d8a7db
Author: abeizn <zi...@merico.dev>
AuthorDate: Mon Jul 18 22:46:21 2022 +0800

    fix: jira verify enckey and jira encode password
---
 plugins/jira/models/migrationscripts/init_schema.go | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/plugins/jira/models/migrationscripts/init_schema.go b/plugins/jira/models/migrationscripts/init_schema.go
index fe35842f..e823670f 100644
--- a/plugins/jira/models/migrationscripts/init_schema.go
+++ b/plugins/jira/models/migrationscripts/init_schema.go
@@ -20,6 +20,7 @@ package migrationscripts
 import (
 	"context"
 	"encoding/base64"
+	"fmt"
 	"strings"
 
 	"github.com/apache/incubator-devlake/config"
@@ -90,6 +91,9 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 
 				c := config.GetConfig()
 				encKey := c.GetString("ENCODE_KEY")
+				if encKey == "" {
+					return fmt.Errorf("jira v0.11 invalid encKey")
+				}
 				auth, err := core.Decrypt(encKey, v.BasicAuthEncoded)
 				if err != nil {
 					return err
@@ -101,7 +105,10 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 				originInfo := strings.Split(string(pk), ":")
 				if len(originInfo) == 2 {
 					conn.Username = originInfo[0]
-					conn.Password = originInfo[1]
+					conn.Password, err = core.Encrypt(encKey, originInfo[1])
+					if err != nil {
+						return err
+					}
 					// create
 					db.Create(&conn)
 				}
@@ -131,6 +138,9 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 
 				c := config.GetConfig()
 				encKey := c.GetString("ENCODE_KEY")
+				if encKey == "" {
+					return fmt.Errorf("jia v0.10 invalid encKey")
+				}
 				auth, err := core.Decrypt(encKey, v.BasicAuthEncoded)
 				if err != nil {
 					return err
@@ -142,7 +152,10 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
 				originInfo := strings.Split(string(pk), ":")
 				if len(originInfo) == 2 {
 					conn.Username = originInfo[0]
-					conn.Password = originInfo[1]
+					conn.Password, err = core.Encrypt(encKey, originInfo[1])
+					if err != nil {
+						return err
+					}
 					// create
 					db.Create(&conn)
 				}