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

Add support of BasicAuthentication Authentication to Git #1940

Merged

Conversation

i053322
Copy link
Contributor

@i053322 i053322 commented Jul 26, 2016

What does this PR do?

Add support of Basic Authenticationt git.
It will support in operation of import,clone,fetch,rebase,push,pull.
The user will provide the user and password for the request and it will create credentials provider

What issues does this PR fix or reference?

Add support to clone and work with repository that support basic authentication

Previous Behavior

Remove this section if not relevant
It was not possible to work with repository that need basic Authentication

New Behavior

This content may also be included in the release notes.

Tests written?

Yes/No
It exist for our scenario

Docs requirements?

Include the content for all the docs changes required.

  1. API changes
  2. User docs changes

Please review Che's Contributing Guide for best practices.

Signed-off-by: i053322 [email protected]

@codenvy-ci
Copy link

Can one of the admins verify this patch?

@skabashnyuk
Copy link
Contributor

Where this user and password is come from. How they are stored?

@i053322
Copy link
Contributor Author

i053322 commented Jul 26, 2016

It should come from the client. for example in the POST call it will be added to the oData in format of for example
"source": {
"runners": {},
"project": {
"location": sGitUrl,
"type": "git-ba",
"parameters": {
"userName": sGitSshUsername,
"password": sGitSshPassword
}
}
}

@codenvy-ci
Copy link

Can one of the admins verify this patch?

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from 0b9f6d3 to 34eeb7d Compare August 14, 2016 06:37
@skabashnyuk
Copy link
Contributor

ok. @vinokurig ?

final String pass = parameters.get("password");
if (user != null && pass != null) {
setCredentials = true;
GitBasicAuthenticationCredentialsProvider.setCurrentCredentials(user, pass);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add static import

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from 34eeb7d to 4c52b09 Compare August 15, 2016 10:30
@i053322
Copy link
Contributor Author

i053322 commented Aug 15, 2016

@vinokurig - I fixed the comment

private static final String GIT_PROJECT_ID = "git-project-id";

@Override
public UserCredential getUserCredential() throws GitException {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method never throws GitException, I think you should remove this 'throws'

Copy link
Contributor Author

@i053322 i053322 Aug 15, 2016

Choose a reason for hiding this comment

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

@vinokurig - Its is how the interfce CredentialsProvider
UserCredential getUserCredential() throws GitException;
also GitHubOAuthCredentialProvider has the same logic

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but you are not obligated to add throws GitException in overridden method.
In this case you will get rid of of try-catch in canProvideCredentials() method

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from 4c52b09 to c4735b2 Compare August 15, 2016 11:53
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - API
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong license: * Codenvy, S.A. - initial API and implementation

@vinokurig
Copy link
Contributor

Please fix JGitConnectionTest according to your changes

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from c4735b2 to e769fb8 Compare August 16, 2016 06:11
@i053322
Copy link
Contributor Author

i053322 commented Aug 16, 2016

@vinokurig - Fixed the comment

@vinokurig
Copy link
Contributor

Please remove new line (1593) in JGitConnection other ok for me

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from e769fb8 to 5ab7896 Compare August 16, 2016 08:55
@i053322
Copy link
Contributor Author

i053322 commented Aug 16, 2016

@vinokurig - fixed the last issue

@vinokurig
Copy link
Contributor

ok for me


private static final Logger LOG = LoggerFactory.getLogger(GitBasicAuthenticationCredentialsProvider.class);
private static ThreadLocal<UserCredential> currRequestCredentials = new ThreadLocal<>();
private static final String GIT_PROJECT_ID = "git-project-id";
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure that git-project-id is good name for CredentialsProvider? Mb git-basic or just basic would be better?

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 will fix it

public ProviderInfo(@NotNull String providerName) {
info.put(PROVIDER_NAME, providerName);
}

Copy link
Member

Choose a reason for hiding this comment

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

also please fix java doc of getAuthenticateUrl method and describe that it can return null value and add org.eclipse.che.commons.annotation.Nullable for it

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from da69e82 to 2db28d8 Compare August 18, 2016 12:06
@i053322
Copy link
Contributor Author

i053322 commented Aug 18, 2016

@sleshchenko - fixed the comments

@sleshchenko
Copy link
Member

@i053322 What about #1940 (comment) ?

return info.get(AUTHENTICATE_URL);
}
/**
* @return authenticate URL. It could retrun null value.
Copy link
Member

@sleshchenko sleshchenko Aug 18, 2016

Choose a reason for hiding this comment

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

typo retrun

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from 2db28d8 to 20ffbb0 Compare August 21, 2016 06:41
@i053322
Copy link
Contributor Author

i053322 commented Aug 21, 2016

@sleshchenko - fixed the comments

@Override
public UserCredential getUserCredential() {
UserCredential credentials = currRequestCredentials.get();
return credentials;
Copy link
Member

Choose a reason for hiding this comment

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

just return currRequestCredentials.get(); ?

@sleshchenko
Copy link
Member

LGTM

@skabashnyuk
Copy link
Contributor

@vinokurig wdyt?

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from 20ffbb0 to b3e54e0 Compare August 23, 2016 05:43
@i053322
Copy link
Contributor Author

i053322 commented Aug 23, 2016

@sleshchenko - fixed the last comment

@vinokurig
Copy link
Contributor

Ok for me

@skabashnyuk
Copy link
Contributor

@vinokurig please continue merging this pr in appropriate moment of our release cycle

@i053322
Copy link
Contributor Author

i053322 commented Sep 4, 2016

@skabashnyuk - can I create PR for 3.x ?

@vinokurig
Copy link
Contributor

@i053322 Yes, you can create a PR to 3.x. We have merged big changes to 4.x and it became unstable. This PR will be merged when 4.x master will become stable.

@Singleton
public class GitBasicAuthenticationCredentialsProvider implements CredentialsProvider {

private static final Logger LOG = LoggerFactory.getLogger(GitBasicAuthenticationCredentialsProvider.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is unused here, please remove it

@i053322 i053322 force-pushed the add_basic_Authentication_to_git branch from b3e54e0 to 2047a5b Compare September 5, 2016 12:16
@vkuznyetsov vkuznyetsov added this to the 5.0.0-M2 milestone Sep 14, 2016
@riuvshin riuvshin modified the milestones: 5.0.0-M3, 5.0.0-M2 Sep 20, 2016
@vinokurig vinokurig mentioned this pull request Sep 22, 2016
@vinokurig vinokurig merged commit 4595c9d into eclipse-che:master Sep 22, 2016
@bmicklea bmicklea mentioned this pull request Sep 28, 2016
63 tasks
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants