vsts-mirror-git-repository icon indicating copy to clipboard operation
vsts-mirror-git-repository copied to clipboard

Enhance interface to support multiple authentication methods

Open calebcartwright opened this issue 4 years ago • 0 comments

Currently the only authentication mechanism supported by the mirror task is URI encoding with basic auth in the userinfo subcomponent. Though this is a viable means of authentication with the major git hosting platforms, it's generally discouraged, not necessarily universally supported, and there are of course several other preferable ways to authenticate.

The lack of support for alternatives has been reported as a problem (e.g. #63, #10) and more generally it'd be good for us to support other use cases (e.g. #85, #1)

For anyone interested in working on this, some details/hints are below. It would also probably be a good idea to include support for one of the other authentication mechanisms as part of the PR that addresses this issue (the easiest one may be None)

  • Two new inputs needs to be added to the task that allow the user to specify the authentication mechanism, one for the Source repo and another for the Target repo (for example sourceGitRepositoryAuthenticationMechanism and destinationGitRepositoryAuthenticationMechanism
    • Both should be of type picklist since we'll eventually support several such mechanisms
    • I imagine the first values should have display names like access token (current available option), and probably none
  • The existing inputs for the access tokens (sourceGitRepositoryPersonalAccessToken and destinationGitRepositoryPersonalAccessToken) need to have visibleRules wired up based on the value of the respective new inputs created in the preceding step
    • Here's an example utilizing visibleRule https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureFileCopyV4/task.json#L77
  • The task code that loads the input values needs to be updated to import the value of the new inputs, and then the second boolean arg used for other getInput calls to indicate whether the input is required will need to be updated to be set dynamically based on the value of the new authentication mechanism input fields vs. a literal bool. e.g. the second arg to getInput will be based on the value of destinationGitRepositoryAuthenticationMechanism https://github.com/swellaby/vsts-mirror-git-repository/blob/3b11470f42e2617c46f7ae607d23e0a64da776a6/src/git-mirror/git-mirror-task.ts#L25
  • The task code will need to be updated to build the uri and potentially the git command args/flags (for example with #85 -c http.extraheader="AUTHORIZATION: .....) based on the new input values

https://github.com/swellaby/vsts-mirror-git-repository/blob/3b11470f42e2617c46f7ae607d23e0a64da776a6/src/git-mirror/git-mirror-task.ts#L128-L141

https://github.com/swellaby/vsts-mirror-git-repository/blob/3b11470f42e2617c46f7ae607d23e0a64da776a6/src/git-mirror/git-mirror-task.ts#L91-L104

calebcartwright avatar Nov 17 '20 00:11 calebcartwright