You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/06/13 16:07:32 UTC
[4/9] mesos git commit: Implemented http basic auth to get docker
auth token.
Implemented http basic auth to get docker auth token.
Review: https://reviews.apache.org/r/45951/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5115194c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5115194c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5115194c
Branch: refs/heads/master
Commit: 5115194c5b4bebca6ee5e5c7f7fbfb8cbde24cfb
Parents: c13a9cb
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Jun 13 09:06:47 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Jun 13 09:06:47 2016 -0700
----------------------------------------------------------------------
src/uri/fetchers/docker.cpp | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5115194c/src/uri/fetchers/docker.cpp
----------------------------------------------------------------------
diff --git a/src/uri/fetchers/docker.cpp b/src/uri/fetchers/docker.cpp
index ab8f5e0..d75eaa3 100644
--- a/src/uri/fetchers/docker.cpp
+++ b/src/uri/fetchers/docker.cpp
@@ -304,7 +304,8 @@ private:
const URI& blobUri);
Future<string> getAuthToken(const http::Response& response);
- http::Headers getAuthHeader(const Option<string>& authToken);
+ http::Headers getAuthHeaderBasic(const Option<string>& credential);
+ http::Headers getAuthHeaderBearer(const Option<string>& authToken);
URI getManifestUri(const URI& uri);
URI getBlobUri(const URI& uri);
@@ -606,7 +607,9 @@ Future<string> DockerFetcherPluginProcess::getAuthToken(
"service=" + attributes.at("service") + "&" +
"scope=" + attributes.at("scope");
- return curl(uri)
+ Option<string> auth;
+
+ return curl(uri, getAuthHeaderBasic(auth)
.then([uri](const http::Response& response) -> Future<string> {
if (response.code != http::Status::OK) {
return Failure(
@@ -633,7 +636,23 @@ Future<string> DockerFetcherPluginProcess::getAuthToken(
}
-http::Headers DockerFetcherPluginProcess::getAuthHeader(
+http::Headers DockerFetcherPluginProcess::getAuthHeaderBasic(
+ const Option<string>& credential)
+{
+ http::Headers headers;
+
+ if (credential.isSome()) {
+ // NOTE: The 'Basic' credential would be attached as a header
+ // when pulling a public image from a registry, if the host
+ // of the image's repository exists in the docker config file.
+ headers["Authorization"] = "Basic " + credential.get();
+ }
+
+ return headers;
+}
+
+
+http::Headers DockerFetcherPluginProcess::getAuthHeaderBearer(
const Option<string>& authToken)
{
http::Headers headers;