You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zh...@apache.org on 2022/06/10 08:08:53 UTC
[incubator-devlake] branch main updated: fix: jira basic auth migration should encrypt password (#2160)
This is an automated email from the ASF dual-hosted git repository.
zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 15e30f84 fix: jira basic auth migration should encrypt password (#2160)
15e30f84 is described below
commit 15e30f843c603b4cdb2b671339c8bc2e91cf62b8
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Fri Jun 10 16:08:50 2022 +0800
fix: jira basic auth migration should encrypt password (#2160)
---
plugins/jira/models/migrationscripts/updateSchemas20220601.go | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/plugins/jira/models/migrationscripts/updateSchemas20220601.go b/plugins/jira/models/migrationscripts/updateSchemas20220601.go
index ba9e9554..7a7bb7b5 100644
--- a/plugins/jira/models/migrationscripts/updateSchemas20220601.go
+++ b/plugins/jira/models/migrationscripts/updateSchemas20220601.go
@@ -78,8 +78,7 @@ func (u *UpdateSchemas20220601) Up(ctx context.Context, db *gorm.DB) error {
for _, connection := range connections {
basicAuthEncoded, err := core.Decrypt(encKey, connection.BasicAuthEncoded)
if err != nil {
- u.logger.Warn("failed to decrypt basicAuth for connection %d", connection.ID)
- continue
+ return err
}
basicAuth, err := base64.StdEncoding.DecodeString(basicAuthEncoded)
if err != nil {
@@ -87,6 +86,10 @@ func (u *UpdateSchemas20220601) Up(ctx context.Context, db *gorm.DB) error {
}
strList := strings.Split(string(basicAuth), ":")
if len(strList) > 1 {
+ encPass, err := core.Encrypt(encKey, strList[1])
+ if err != nil {
+ return err
+ }
newConnection := JiraConnection20220601{
RestConnection: helper.RestConnection{
BaseConnection: helper.BaseConnection{
@@ -99,13 +102,13 @@ func (u *UpdateSchemas20220601) Up(ctx context.Context, db *gorm.DB) error {
},
BasicAuth: helper.BasicAuth{
Username: strList[0],
- Password: strList[1],
+ Password: encPass,
},
EpicKeyField: connection.EpicKeyField,
StoryPointField: connection.StoryPointField,
RemotelinkCommitShaPattern: connection.RemotelinkCommitShaPattern,
}
- err := db.Save(newConnection).Error
+ err = db.Save(newConnection).Error
if err != nil {
return err
}