Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hardcoded string as username for Azure git credentials #529

Merged
merged 3 commits into from
Jul 6, 2023

Conversation

vinokurig
Copy link
Contributor

@vinokurig vinokurig commented Jun 30, 2023

What does this PR do?

Since Azure git provider do not support username for its user object, use username string as username in the git credentials file if the PAT is related to Azure Devops:

https://username:<token>@dev.azure.com

Screenshot/screencast of this PR

What issues does this PR fix or reference?

fixes eclipse-che/che#22313

How to test this PR?

  1. Setup an Azure DevOps PAT secret.
  2. Start a workspace from a private Azure DevOps repo.
    See: the workspace starts and the project is git cloned successfully.

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

Comment on lines 161 to 164
: personalAccessToken.getScmUserName(),
: isNullOrEmpty(personalAccessToken.getScmOrganization())
? personalAccessToken.getScmUserName()
: personalAccessToken.getScmOrganization(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this yet but this appears to apply to all platforms (e.g. GitHub, etc.). Is this intentional? I'm generally a little confused on what works for all platforms -- e.g. on GitHub my username is amisevsk and (I guess) my organization name is amisevsk, even though I'm not an organization?

Copy link
Contributor Author

@vinokurig vinokurig Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the PAT documentation we use the che.eclipse.org/scm-organization annotation only for the Azure DevOps. For GitHub and others except Azure, che.eclipse.org/scm-username is used so the flow is the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we extract this logic to a separate method and add javadoc for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworked the logic to use hardcoded "username" string for the Azure case. It seems to be safer then an scm-organization field.

Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
@vinokurig vinokurig changed the title Use scm organization for Azure git credentials Use hardcoded string as username for Azure git credentials Jul 3, 2023
@vinokurig
Copy link
Contributor Author

Updated the PR title and description according to the logic changes.

Copy link
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; haven't had a chance to test directly though.

@ibuziuk
Copy link
Member

ibuziuk commented Jul 5, 2023

@vinokurig could you please provide the image for testing? My understanding that with this PR token should work when configured from the user dashboard, right?

@vinokurig
Copy link
Contributor Author

A docker image to test the PR is quay.io/ivinokur/che-server:che-22313

Copy link
Member

@ibuziuk ibuziuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified against rosa cluster 👍 I think we are good to merge with 3 approvals

@openshift-ci
Copy link

openshift-ci bot commented Jul 5, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: amisevsk, ibuziuk, tolusha, vinokurig

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vinokurig vinokurig merged commit aee2079 into main Jul 6, 2023
@vinokurig vinokurig deleted the che-22313 branch July 6, 2023 06:37
@devstudio-release
Copy link

Build 3.8 :: server_3.x/184: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure token configuration does not seem to work from UI, password is asked when the project is cloned
5 participants