{"action":"created","comment":{"url":"https://api.github.com/repos/docker/notary/pulls/comments/36018057","id":36018057,"diff_hunk":"@@ -266,13 +274,89 @@ func verify(cmd *cobra.Command, args []string) {\n \treturn\n }\n \n-func getTransport() *http.Transport {\n-\tif viper.GetBool(\"skipTLSVerify\") {\n-\t\treturn &http.Transport{\n-\t\t\tTLSClientConfig: &tls.Config{\n-\t\t\t\tInsecureSkipVerify: true,\n-\t\t\t},\n-\t\t}\n+type passwordStore struct {\n+\tanonymous bool\n+}\n+\n+func (ps passwordStore) Basic(u *url.URL) (string, string) {\n+\tif ps.anonymous {\n+\t\treturn \"\", \"\"\n \t}\n-\treturn &http.Transport{}\n+\n+\tstdin := bufio.NewReader(os.Stdin)\n+\tfmt.Fprintf(os.Stdout, \"Enter username: \")\n+\n+\tuserIn, err := stdin.ReadBytes('\\n')\n+\tif err != nil {\n+\t\tlogrus.Errorf(\"error processing username input: %s\", err)\n+\t\treturn \"\", \"\"\n+\t}\n+\n+\tusername := strings.TrimSpace(string(userIn))\n+\n+\tstate, err := term.SaveState(0)\n+\tif err != nil {\n+\t\tlogrus.Errorf(\"error saving terminal state, cannot retrieve password: %s\", err)\n+\t\treturn \"\", \"\"\n+\t}\n+\tterm.DisableEcho(0, state)\n+\tdefer term.RestoreTerminal(0, state)\n+\n+\tfmt.Fprintf(os.Stdout, \"Enter password: \")\n+\n+\tuserIn, err = stdin.ReadBytes('\\n')\n+\tfmt.Fprintln(os.Stdout)\n+\tif err != nil {\n+\t\tlogrus.Errorf(\"error processing password input: %s\", err)\n+\t\treturn \"\", \"\"\n+\t}\n+\tpassword := strings.TrimSpace(string(userIn))\n+\n+\treturn username, password\n+}\n+\n+func getTransport(gun string, readOnly bool) http.RoundTripper {\n+\ttlsConfig := &tls.Config{\n+\t\tInsecureSkipVerify: viper.GetBool(\"skipTLSVerify\"),\n+\t}\n+\n+\tbase := &http.Transport{\n+\t\tProxy: http.ProxyFromEnvironment,\n+\t\tDial: (&net.Dialer{\n+\t\t\tTimeout:   30 * time.Second,\n+\t\t\tKeepAlive: 30 * time.Second,\n+\t\t\tDualStack: true,\n+\t\t}).Dial,\n+\t\tTLSHandshakeTimeout: 10 * time.Second,\n+\t\tTLSClientConfig:     tlsConfig,\n+\t\tDisableKeepAlives:   true,\n+\t}\n+\n+\t// TODO(dmcgowan): add notary specific headers\n+\tauthTransport := transport.NewTransport(base)\n+\tpingClient := &http.Client{\n+\t\tTransport: authTransport,\n+\t\tTimeout:   5 * time.Second,\n+\t}\n+\tendpointStr := \"https://notary.docker.io/v2/\"","path":"cmd/notary/tuf.go","position":164,"original_position":164,"commit_id":"f94b12db1c2182e71f43a0ba1225b28256b73b9a","original_commit_id":"f94b12db1c2182e71f43a0ba1225b28256b73b9a","user":{"login":"diogomonica","id":55332,"avatar_url":"https://avatars.githubusercontent.com/u/55332?v=3","gravatar_id":"","url":"https://api.github.com/users/diogomonica","html_url":"https://github.com/diogomonica","followers_url":"https://api.github.com/users/diogomonica/followers","following_url":"https://api.github.com/users/diogomonica/following{/other_user}","gists_url":"https://api.github.com/users/diogomonica/gists{/gist_id}","starred_url":"https://api.github.com/users/diogomonica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diogomonica/subscriptions","organizations_url":"https://api.github.com/users/diogomonica/orgs","repos_url":"https://api.github.com/users/diogomonica/repos","events_url":"https://api.github.com/users/diogomonica/events{/privacy}","received_events_url":"https://api.github.com/users/diogomonica/received_events","type":"User","site_admin":false},"body":"Will this being hardcoded require every notary action to request something to this URL? What if we're just using `notary list -s localhost:4443 diogo/repo`. Won't the way this is setup always try to get this Transport, create a request and ping the notary.docker.io server?","created_at":"2015-07-31T21:24:51Z","updated_at":"2015-07-31T21:24:51Z","html_url":"https://github.com/docker/notary/pull/162#discussion_r36018057","pull_request_url":"https://api.github.com/repos/docker/notary/pulls/162","_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/comments/36018057"},"html":{"href":"https://github.com/docker/notary/pull/162#discussion_r36018057"},"pull_request":{"href":"https://api.github.com/repos/docker/notary/pulls/162"}}},"pull_request":{"url":"https://api.github.com/repos/docker/notary/pulls/162","id":41288641,"html_url":"https://github.com/docker/notary/pull/162","diff_url":"https://github.com/docker/notary/pull/162.diff","patch_url":"https://github.com/docker/notary/pull/162.patch","issue_url":"https://api.github.com/repos/docker/notary/issues/162","number":162,"state":"open","locked":false,"title":"Notary cli auth","user":{"login":"dmcgowan","id":169601,"avatar_url":"https://avatars.githubusercontent.com/u/169601?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcgowan","html_url":"https://github.com/dmcgowan","followers_url":"https://api.github.com/users/dmcgowan/followers","following_url":"https://api.github.com/users/dmcgowan/following{/other_user}","gists_url":"https://api.github.com/users/dmcgowan/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcgowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcgowan/subscriptions","organizations_url":"https://api.github.com/users/dmcgowan/orgs","repos_url":"https://api.github.com/users/dmcgowan/repos","events_url":"https://api.github.com/users/dmcgowan/events{/privacy}","received_events_url":"https://api.github.com/users/dmcgowan/received_events","type":"User","site_admin":false},"body":"Add implementation to do authentication in notary\r\n\r\nThis is somewhat incomplete since the following does not happen\r\n- allow per endpoint username/password configuration\r\n- obfuscation of password in configuration file\r\n- properly handling failed username/password attempts (might need change in distribution client)","created_at":"2015-07-30T22:18:09Z","updated_at":"2015-07-31T21:24:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5f5781db2e4921df47a92b4ed150d752b1fac37","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/notary/pulls/162/commits","review_comments_url":"https://api.github.com/repos/docker/notary/pulls/162/comments","review_comment_url":"https://api.github.com/repos/docker/notary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/notary/issues/162/comments","statuses_url":"https://api.github.com/repos/docker/notary/statuses/f94b12db1c2182e71f43a0ba1225b28256b73b9a","head":{"label":"dmcgowan:notary-cli-auth","ref":"notary-cli-auth","sha":"f94b12db1c2182e71f43a0ba1225b28256b73b9a","user":{"login":"dmcgowan","id":169601,"avatar_url":"https://avatars.githubusercontent.com/u/169601?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcgowan","html_url":"https://github.com/dmcgowan","followers_url":"https://api.github.com/users/dmcgowan/followers","following_url":"https://api.github.com/users/dmcgowan/following{/other_user}","gists_url":"https://api.github.com/users/dmcgowan/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcgowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcgowan/subscriptions","organizations_url":"https://api.github.com/users/dmcgowan/orgs","repos_url":"https://api.github.com/users/dmcgowan/repos","events_url":"https://api.github.com/users/dmcgowan/events{/privacy}","received_events_url":"https://api.github.com/users/dmcgowan/received_events","type":"User","site_admin":false},"repo":{"id":38707263,"name":"notary","full_name":"dmcgowan/notary","owner":{"login":"dmcgowan","id":169601,"avatar_url":"https://avatars.githubusercontent.com/u/169601?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcgowan","html_url":"https://github.com/dmcgowan","followers_url":"https://api.github.com/users/dmcgowan/followers","following_url":"https://api.github.com/users/dmcgowan/following{/other_user}","gists_url":"https://api.github.com/users/dmcgowan/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcgowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcgowan/subscriptions","organizations_url":"https://api.github.com/users/dmcgowan/orgs","repos_url":"https://api.github.com/users/dmcgowan/repos","events_url":"https://api.github.com/users/dmcgowan/events{/privacy}","received_events_url":"https://api.github.com/users/dmcgowan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmcgowan/notary","description":"","fork":true,"url":"https://api.github.com/repos/dmcgowan/notary","forks_url":"https://api.github.com/repos/dmcgowan/notary/forks","keys_url":"https://api.github.com/repos/dmcgowan/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmcgowan/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmcgowan/notary/teams","hooks_url":"https://api.github.com/repos/dmcgowan/notary/hooks","issue_events_url":"https://api.github.com/repos/dmcgowan/notary/issues/events{/number}","events_url":"https://api.github.com/repos/dmcgowan/notary/events","assignees_url":"https://api.github.com/repos/dmcgowan/notary/assignees{/user}","branches_url":"https://api.github.com/repos/dmcgowan/notary/branches{/branch}","tags_url":"https://api.github.com/repos/dmcgowan/notary/tags","blobs_url":"https://api.github.com/repos/dmcgowan/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmcgowan/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmcgowan/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmcgowan/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmcgowan/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/dmcgowan/notary/languages","stargazers_url":"https://api.github.com/repos/dmcgowan/notary/stargazers","contributors_url":"https://api.github.com/repos/dmcgowan/notary/contributors","subscribers_url":"https://api.github.com/repos/dmcgowan/notary/subscribers","subscription_url":"https://api.github.com/repos/dmcgowan/notary/subscription","commits_url":"https://api.github.com/repos/dmcgowan/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmcgowan/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmcgowan/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmcgowan/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmcgowan/notary/contents/{+path}","compare_url":"https://api.github.com/repos/dmcgowan/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmcgowan/notary/merges","archive_url":"https://api.github.com/repos/dmcgowan/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmcgowan/notary/downloads","issues_url":"https://api.github.com/repos/dmcgowan/notary/issues{/number}","pulls_url":"https://api.github.com/repos/dmcgowan/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/dmcgowan/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/dmcgowan/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmcgowan/notary/labels{/name}","releases_url":"https://api.github.com/repos/dmcgowan/notary/releases{/id}","created_at":"2015-07-07T18:36:03Z","updated_at":"2015-07-07T18:36:04Z","pushed_at":"2015-07-31T21:09:28Z","git_url":"git://github.com/dmcgowan/notary.git","ssh_url":"git@github.com:dmcgowan/notary.git","clone_url":"https://github.com/dmcgowan/notary.git","svn_url":"https://github.com/dmcgowan/notary","homepage":null,"size":20646,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"056622d80135f314d45db7f0384d20a9a428a425","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":37743436,"name":"notary","full_name":"docker/notary","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/notary","description":"","fork":false,"url":"https://api.github.com/repos/docker/notary","forks_url":"https://api.github.com/repos/docker/notary/forks","keys_url":"https://api.github.com/repos/docker/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/notary/teams","hooks_url":"https://api.github.com/repos/docker/notary/hooks","issue_events_url":"https://api.github.com/repos/docker/notary/issues/events{/number}","events_url":"https://api.github.com/repos/docker/notary/events","assignees_url":"https://api.github.com/repos/docker/notary/assignees{/user}","branches_url":"https://api.github.com/repos/docker/notary/branches{/branch}","tags_url":"https://api.github.com/repos/docker/notary/tags","blobs_url":"https://api.github.com/repos/docker/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/notary/languages","stargazers_url":"https://api.github.com/repos/docker/notary/stargazers","contributors_url":"https://api.github.com/repos/docker/notary/contributors","subscribers_url":"https://api.github.com/repos/docker/notary/subscribers","subscription_url":"https://api.github.com/repos/docker/notary/subscription","commits_url":"https://api.github.com/repos/docker/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/notary/contents/{+path}","compare_url":"https://api.github.com/repos/docker/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/notary/merges","archive_url":"https://api.github.com/repos/docker/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/notary/downloads","issues_url":"https://api.github.com/repos/docker/notary/issues{/number}","pulls_url":"https://api.github.com/repos/docker/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/notary/labels{/name}","releases_url":"https://api.github.com/repos/docker/notary/releases{/id}","created_at":"2015-06-19T20:07:53Z","updated_at":"2015-07-28T21:09:03Z","pushed_at":"2015-07-31T21:09:45Z","git_url":"git://github.com/docker/notary.git","ssh_url":"git@github.com:docker/notary.git","clone_url":"https://github.com/docker/notary.git","svn_url":"https://github.com/docker/notary","homepage":null,"size":23753,"stargazers_count":327,"watchers_count":327,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":30,"forks":28,"open_issues":30,"watchers":327,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/162"},"html":{"href":"https://github.com/docker/notary/pull/162"},"issue":{"href":"https://api.github.com/repos/docker/notary/issues/162"},"comments":{"href":"https://api.github.com/repos/docker/notary/issues/162/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/notary/pulls/162/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/notary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/notary/pulls/162/commits"},"statuses":{"href":"https://api.github.com/repos/docker/notary/statuses/f94b12db1c2182e71f43a0ba1225b28256b73b9a"}}}}