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

fixes #1107 #1108

Merged
merged 1 commit into from
Mar 9, 2017
Merged

fixes #1107 #1108

merged 1 commit into from
Mar 9, 2017

Conversation

reasonerjt
Copy link
Contributor

@reasonerjt reasonerjt commented Mar 1, 2017

When doing auth, add the path of "tuf URL" before "/v2" for ping client

For more details please refer to #1107

Signed-off-by: Tan Jiang [email protected]

@docker-jenkins
Copy link

Can one of the admins verify this patch?

@@ -889,7 +889,13 @@ func tokenAuth(trustServerURL string, baseTransport *http.Transport, gun data.GU
if endpoint.Scheme == "" {
return nil, fmt.Errorf("Trust server url has to be in the form of http(s)://URL:PORT. Got: %s", trustServerURL)
}
subPath, err := url.Parse("v2/")
var p string
if strings.HasSuffix(endpoint.Path, "/") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just use filepath.Join here, which would take care of de-duping the / for you (and even de-duping extra / as well: https://play.golang.org/p/ALPqJzKDCq)

Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking: If you wouldn't mind, could this URL validation be moved to a utility function in storage/httpstore.go so that it could be shared between this and the HTTPStore? It'd be useful for library users of the notary client as well.

It would also make it easier to test, since you can just test that function alone (because the second thing I was going to ask is a test for this particular validation withsubpaths :))

Copy link
Contributor

Choose a reason for hiding this comment

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

@cyli should just be path.Join as filepath would do the wrong thing on Windows systems and these are HTTP URLs.

Could alternatively use the url package which will absolutely ensure it's a correct URL.

Copy link
Contributor

Choose a reason for hiding this comment

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

You have to be precise with the / but it works. https://play.golang.org/p/eVHFrPre4i

Copy link
Contributor

Choose a reason for hiding this comment

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

@endophage Ah good point, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@endophage
Are you saying user have to call
notary -s https://docker.com/notary/??
Wouldn't it be better if the code can handle both cases, with or without the trailing /

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cyli
Thanks for reviewing I'll check httpstore.go when I have time, probably early next week.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well... I was thinking we could detect the trailing slash and add if necessary. I don't feel strongly though, what you have currently is fine.

@cyli
Copy link
Contributor

cyli commented Mar 1, 2017

jenkins, test this please

@endophage
Copy link
Contributor

The circleCI failures appear legitimate. It appears path.Join is causing the trailing / on the /v2/ to be dropped, while the existing code didn't do that. I believe that's causing a 404 from the server in the failing tests.

@reasonerjt
Copy link
Contributor Author

@endophage Thanks for the comment.
I'll fix it, sorry 'bout that.

Signed-off-by: Tan Jiang <[email protected]>
@endophage
Copy link
Contributor

@reasonerjt no worries, but it does make me think we should detect the presence of a trailing / on the initial base url and add it there if necessary, then just use net/url rather than path.

@endophage
Copy link
Contributor

jenkins, test this please

@endophage
Copy link
Contributor

LGTM pending Jenkins but fully expect it to pass.

Copy link
Contributor

@cyli cyli left a comment

Choose a reason for hiding this comment

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

LGTM

@cyli cyli merged commit a76c377 into notaryproject:master Mar 9, 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.

5 participants