-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Update NewClient handle credentials in the url #23
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NewClientFromURL is a wrapper for NewClient with two notable differences: * The url may contain credentials, http://admin:secret@localhost:8081/ for example. These credentials may either be a user name and password or name and value as in the case of cookie based authentication. * If the url contains credentials then this function will attempt to validate the credentials before returning the client. An error will be returned if the credentials cannot be validated. The process of validating the credentials is relatively simple and only requires that the provided user have permission to GET /a/accounts/self. Internally NewClientFromURL calls each of the Set*Auth functions followed by GetAccount("self"). The first call to GetAccount("self") which succeeds will return a *Client.
@andygrunwald I know you're probably still out so I'll try to get to the point:
Unless you have some major objections, I'd like to go ahead an merge this so we can start to use it in the docker tests. |
opalmer
changed the title
Implement NewClientFromURL to construct *gerrit.Client with credentials
Update NewClient handle credentials in the url
Oct 20, 2016
Minor update, added credential handling directly to |
I like the idea, because it breaks nothing :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates
NewClient
to handle credentials in the url:If the credentials are invalid then
err
will be set appropriately. This new function will be used in thedocker_tests
branch.Another case were this could be useful is when a consumer of go-gerrit is using configuration files to drive their application. In these cases code could go from:
To: