Skip to content

Improve basic auth handling for canonical ports - #15945

Merged
openshift-merge-robot merged 2 commits into
openshift:masterfrom
smarterclayton:ports
Sep 9, 2017
Merged

Improve basic auth handling for canonical ports#15945
openshift-merge-robot merged 2 commits into
openshift:masterfrom
smarterclayton:ports

Conversation

@smarterclayton

Copy link
Copy Markdown
Contributor

Also make it easier to set custom scopes (used in another PR) for direct registry access.

@openshift-merge-robot openshift-merge-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 23, 2017
@openshift-merge-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: smarterclayton

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

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 23, 2017
@smarterclayton

Copy link
Copy Markdown
Contributor Author

@legionus extracted from that other PR. Note the change to target.String() - the underlying docker logic in credential provider already does this calculation, and of the new test cases I added the only ones that changed when I updated that line was the mismatched scheme* tests.

@enj

enj commented Aug 24, 2017

Copy link
Copy Markdown
Contributor

@openshift/sig-security

@liggitt

liggitt commented Aug 24, 2017

Copy link
Copy Markdown
Contributor

@smarterclayton is this related to #14319? are you getting redirected to a URL you are not expecting?

@smarterclayton

Copy link
Copy Markdown
Contributor Author

No, I just noticed it while testing the registry (at foo:443) was not using secrets for foo.

@openshift-merge-robot openshift-merge-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 30, 2017
@smarterclayton

Copy link
Copy Markdown
Contributor Author

PTAL

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 31, 2017
{name: "mismatched scheme", args: args{keyring: fn("https://localhost", def), target: &url.URL{Scheme: "http", Host: "localhost"}}, user: "", password: ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Neat! Didn't know about this.

{name: "canonical https", args: args{keyring: fn("localhost", def), target: &url.URL{Scheme: "https", Host: "localhost:443"}}, user: def.Username, password: def.Password},
{name: "only https", args: args{keyring: fn("https://localhost", def), target: &url.URL{Host: "localhost"}}, user: def.Username, password: def.Password},
{name: "only https scheme", args: args{keyring: fn("https://localhost", def), target: &url.URL{Scheme: "https", Host: "localhost"}}, user: def.Username, password: def.Password},
{name: "mismatched scheme - http", args: args{keyring: fn("http://localhost", def), target: &url.URL{Scheme: "https", Host: "localhost"}}, user: def.Username, password: def.Password},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Test cases with default and non-default ports in the keyring would be nice.

if len(target.Scheme) == 0 || target.Scheme == "https" {
value = target.Host + target.Path
} else {
value = target.String()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why http:// prefixed target is treated this way? It deserves at least a comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't want to send https credentials to http endpoints. You have to explicitly say you want to send credentials to an insecure endpoint.

Comment thread pkg/image/importer/credentials_test.go Outdated
{name: "only https scheme", args: args{keyring: fn("https://localhost", def), target: &url.URL{Scheme: "https", Host: "localhost"}}, user: def.Username, password: def.Password},
{name: "mismatched scheme - http", args: args{keyring: fn("http://localhost", def), target: &url.URL{Scheme: "https", Host: "localhost"}}, user: def.Username, password: def.Password},

// this is not allowed by the credential keyring, possibly because of insufficient testing

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe because https targets get trimmed before a lookup: 8ec0656#diff-d60fc09a78ae86f4931185b756b2ba00R168

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I meant that the upstream credential keyring is incorrectly handling http credentials.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The upstream keyring cannot handle targets with scheme. If the "https" hadn't been removed from the target before a call to Lookup(), no match would had been found as well. The target shouldn't contain the scheme at all.

@smarterclayton

Copy link
Copy Markdown
Contributor Author

Any other comments?

@miminar

miminar commented Sep 8, 2017

Copy link
Copy Markdown

No, LGTM otherwise.

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 8, 2017
@smarterclayton smarterclayton added the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2017
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2017
@smarterclayton smarterclayton added the lgtm Indicates that a PR is ready to be merged. label Sep 8, 2017
@openshift-bot

Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot

Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

Automatic merge from submit-queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants