-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support basic authentication for registries #918
Conversation
One caveat: since we try HTTP first (in the expectation that we'll be redirected if HTTPS is required), if a registry accepts HTTP we might end up sending auth headers over an insecure connection. All of { |
An alternative would be to require people using insecure registries to tell us about them explicitly, e.g., as a command-line argument something like
|
The image registry code assumed - all image registries use HTTPS - all image registries use token authentication ..but if you run your own registry in your cluster, neither of these things is likely to be true. To support basic authentication, all we need to do is add a handler in when constructing the registry client; it will get used if the authentication challenge indicates so. Supporting HTTP is (oddly) a bit trickier, since there's no indication from an image name (which is all we have) whether the registry uses HTTP or HTTPS. Registries will tend to redirect any HTTP requests to HTTPS, so we _could_ try HTTP first and follow any redirection. However, if a registry supported both HTTP and HTTPS, and didn't redirect, we'd end up sending credentials over an insecure connection unnecessarily. Instead of that, make it possible to tell the daemon which registries to use HTTP for, with the (multiply-valued) argument `--registry-insecure-host`.
6ce7c92
to
ae9d267
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RCGW
Trace bool | ||
InsecureHosts []string | ||
|
||
mu sync.Mutex |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
f.mu.Unlock() | ||
|
||
scheme := "https" | ||
for _, h := range f.InsecureHosts { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Capturing thoughts: |
The image registry code assumed
..but if you run your own registry in your cluster, neither of these things is likely to be true.
To support basic authentication, all we need to do is add a handler in when constructing the registry client; it will get used if the authentication challenge indicates so.
Supporting HTTP is (oddly) a bit trickier, since there's no indication from an image name (which is all we have) whether the registry uses HTTP or HTTPS. We want to use HTTPS in general, so make the user tell us which hosts to use HTTP for (so that it's at least possible to use it), and otherwise use HTTPS.
Fixes #915.
EDIT: describe alternate solution, from comment below, to HTTP vs HTTPS.