You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "klesh (via GitHub)" <gi...@apache.org> on 2023/01/29 09:57:54 UTC

[GitHub] [incubator-devlake] klesh opened a new pull request, #4260: Multiple Authorization Methods Support Mechanism (JIRA supports PAT/BasicAuth)

klesh opened a new pull request, #4260:
URL: https://github.com/apache/incubator-devlake/pull/4260

   ### Summary
   This PR is a more robust/reasonable/elegant/comprehensive solution for #4027, #4212.
   
   The Mechanism offers the following aid for connections that require Single or Multiple Authorizations
   
   ** For Connections Support Single Authorization Method **, define the connection to look like:
   
   ```golang
   // GitlabConn holds the essential information to connect to the Gitlab API
   type GitlabConn struct {
   	helper.RestConnection `mapstructure:",squash"`
   	helper.AccessToken    `mapstructure:",squash"`
   }
   
   // This object conforms to what the frontend currently sends.
   // GitlabConnection holds GitlabConn plus ID/Name for database storage
   type GitlabConnection struct {
   	helper.BaseConnection `mapstructure:",squash"`
   	GitlabConn            `mapstructure:",squash"`
   }
   ```
   
   ** For Connections Support Multiple Authorization Methods **, define the connection to look like:
   ```golang
   // JiraConn holds the essential information to connect to the Jira API
   type JiraConn struct {
   	helper.RestConnection `mapstructure:",squash"`
   	helper.MultiAuth      `mapstructure:",squash"`
   	helper.BasicAuth      `mapstructure:",squash"`
   	helper.AccessToken    `mapstructure:",squash"`
   }
   
   // SetupAuthentication implements the `IAuthentication` interface by delegating
   // the actual logic to the `MultiAuth` struct to help us write less code
   func (jc JiraConn) SetupAuthentication(req *http.Request) errors.Error {
   	return jc.MultiAuth.SetupAuthenticationForConnection(&jc, req)
   }
   
   // JiraConnection holds JiraConn plus ID/Name for database storage
   type JiraConnection struct {
   	helper.BaseConnection `mapstructure:",squash"`
   	JiraConn              `mapstructure:",squash"`
   }
   ```
   
   ** Test Connection implementation for both parties be like **:
   ```golang
   	// decode
   	var err errors.Error
   	var connection models.GitlabConn
   	if err = api.Decode(input.Body, &connection, vld); err != nil {
   		return nil, err
   	}
   	// test connection
   	apiClient, err := api.NewApiClientFromConnection(context.TODO(), basicRes, connection)
   	if err != nil {
   		return nil, errors.Convert(err)
   	}
   
   // TEST the connection with apiClient
   ```
   
   
   ### Does this close any open issues?
   Closes #4027 
   Closes #4212 
   


-- 
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@devlake.apache.org

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


[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #4260: Multiple Authorization Methods Support Mechanism (JIRA supports PAT/BasicAuth)

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on code in PR #4260:
URL: https://github.com/apache/incubator-devlake/pull/4260#discussion_r1089935623


##########
backend/plugins/sonarqube/models/connection.go:
##########
@@ -21,6 +21,7 @@ import helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
 
 // This object conforms to what the frontend currently sends.
 type SonarqubeConnection struct {

Review Comment:
   According to NewApiClientFromConnection, for sonarqube connection, we have to save "TOKEN:" as token, because sonarqube's Authorization is different from other plugins



-- 
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@devlake.apache.org

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


[GitHub] [incubator-devlake] warren830 commented on pull request #4260: Multiple Authorization Methods Support Mechanism (JIRA supports PAT/BasicAuth)

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on PR #4260:
URL: https://github.com/apache/incubator-devlake/pull/4260#issuecomment-1407652090

   Seems like we need to do more work in 20230129_add_multi_auth.go for jira, otherwise, it will report error:
   <img width="765" alt="image" src="https://user-images.githubusercontent.com/39366025/215326489-911873c6-c8d0-42dc-9e56-a744bea68c75.png">
   


-- 
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@devlake.apache.org

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


[GitHub] [incubator-devlake] warren830 commented on pull request #4260: Multiple Authorization Methods Support Mechanism (JIRA supports PAT/BasicAuth)

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on PR #4260:
URL: https://github.com/apache/incubator-devlake/pull/4260#issuecomment-1407637799

   According to backend/plugins/feishu/models/migrationscripts/20220714_add_init_tables.go, we also need to modify this script in jira


-- 
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@devlake.apache.org

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


[GitHub] [incubator-devlake] klesh commented on pull request #4260: Multiple Authorization Methods Support Mechanism (JIRA supports PAT/BasicAuth)

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on PR #4260:
URL: https://github.com/apache/incubator-devlake/pull/4260#issuecomment-1407657268

   > Seems like we also need to modify all existed connections in 20230129_add_multi_auth.go for jira, otherwise, it will report error: <img alt="image" width="765" src="https://user-images.githubusercontent.com/39366025/215326489-911873c6-c8d0-42dc-9e56-a744bea68c75.png">
   
   Good catch, fixed.


-- 
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@devlake.apache.org

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


[GitHub] [incubator-devlake] klesh merged pull request #4260: Multiple Authorization Methods Support Mechanism (JIRA supports PAT/BasicAuth)

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh merged PR #4260:
URL: https://github.com/apache/incubator-devlake/pull/4260


-- 
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@devlake.apache.org

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


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #4260: Multiple Authorization Methods Support Mechanism (JIRA supports PAT/BasicAuth)

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on code in PR #4260:
URL: https://github.com/apache/incubator-devlake/pull/4260#discussion_r1089938813


##########
backend/plugins/sonarqube/models/connection.go:
##########
@@ -21,6 +21,7 @@ import helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
 
 // This object conforms to what the frontend currently sends.
 type SonarqubeConnection struct {

Review Comment:
   Do you mean the Header value should be `Token xxx`?



-- 
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@devlake.apache.org

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