{"action":"created","comment":{"url":"https://api.github.com/repos/juju/juju/pulls/comments/88595128","pull_request_review_id":9164739,"id":88595128,"diff_hunk":"@@ -104,9 +104,58 @@ func checkPermissions(tag names.Tag, acceptFunc common.GetAuthFunc) (bool, error\n \treturn false, errors.NotValidf(\"tag kind %v\", tag.Kind())\n }\n \n-// stateForRequestAuthenticatedUser is like stateForRequestAuthenticated\n+// stateForMigration asserts that the incoming connection is from a user that\n+// has admin permissions on the controller model. The method also gets the\n+// model uuid for the model being migrated from a request header, and returns\n+// the state instance for that model.\n+func (ctxt *httpContext) stateForMigration(r *http.Request) (*state.State, error) {\n+\tst, user, err := ctxt.stateAndEntityForRequestAuthenticatedUser(r)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\tif !st.IsController() {\n+\t\treturn nil, errors.BadRequestf(\"model is not controller model\")\n+\t}\n+\tadmin, err := st.IsControllerAdmin(user.Tag().(names.UserTag))\n+\tif err != nil {\n+\t\treturn nil, errors.Trace(err)\n+\t}\n+\tif !admin {\n+\t\treturn nil, errors.Unauthorizedf(\"not a controller admin\")\n+\t}\n+\n+\tmodelUUID, err := validateModelUUID(validateArgs{\n+\t\tstatePool: ctxt.srv.statePool,\n+\t\tmodelUUID: r.Header.Get(\"Migration-Model-UUID\"),","path":"apiserver/httpcontext.go","position":34,"original_position":27,"commit_id":"3d88f8ef66568e94882e30808051cbdec1718c30","original_commit_id":"86621231c73c25ecae9a55fe1b9589ada7611dee","user":{"login":"howbazaar","id":1744247,"avatar_url":"https://avatars.githubusercontent.com/u/1744247?v=3","gravatar_id":"","url":"https://api.github.com/users/howbazaar","html_url":"https://github.com/howbazaar","followers_url":"https://api.github.com/users/howbazaar/followers","following_url":"https://api.github.com/users/howbazaar/following{/other_user}","gists_url":"https://api.github.com/users/howbazaar/gists{/gist_id}","starred_url":"https://api.github.com/users/howbazaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howbazaar/subscriptions","organizations_url":"https://api.github.com/users/howbazaar/orgs","repos_url":"https://api.github.com/users/howbazaar/repos","events_url":"https://api.github.com/users/howbazaar/events{/privacy}","received_events_url":"https://api.github.com/users/howbazaar/received_events","type":"User","site_admin":false},"body":"Yes, Updating now.","created_at":"2016-11-18T03:36:55Z","updated_at":"2016-11-18T03:36:55Z","html_url":"https://github.com/juju/juju/pull/6565#discussion_r88595128","pull_request_url":"https://api.github.com/repos/juju/juju/pulls/6565","_links":{"self":{"href":"https://api.github.com/repos/juju/juju/pulls/comments/88595128"},"html":{"href":"https://github.com/juju/juju/pull/6565#discussion_r88595128"},"pull_request":{"href":"https://api.github.com/repos/juju/juju/pulls/6565"}}},"pull_request":{"url":"https://api.github.com/repos/juju/juju/pulls/6565","id":93702250,"html_url":"https://github.com/juju/juju/pull/6565","diff_url":"https://github.com/juju/juju/pull/6565.diff","patch_url":"https://github.com/juju/juju/pull/6565.patch","issue_url":"https://api.github.com/repos/juju/juju/issues/6565","number":6565,"state":"open","locked":false,"title":"Add apiserver endpoints for migrating binaries","user":{"login":"howbazaar","id":1744247,"avatar_url":"https://avatars.githubusercontent.com/u/1744247?v=3","gravatar_id":"","url":"https://api.github.com/users/howbazaar","html_url":"https://github.com/howbazaar","followers_url":"https://api.github.com/users/howbazaar/followers","following_url":"https://api.github.com/users/howbazaar/following{/other_user}","gists_url":"https://api.github.com/users/howbazaar/gists{/gist_id}","starred_url":"https://api.github.com/users/howbazaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howbazaar/subscriptions","organizations_url":"https://api.github.com/users/howbazaar/orgs","repos_url":"https://api.github.com/users/howbazaar/repos","events_url":"https://api.github.com/users/howbazaar/events{/privacy}","received_events_url":"https://api.github.com/users/howbazaar/received_events","type":"User","site_admin":false},"body":"Add specific POST apiserver endpoints for uploading the charm and tool binaries during migration.\r\n\r\nIn order for a migration of a model that the admin user does not have access to to work, we cannot connect to that model on the migration target. To get around this, we add specific endpoints for migrating the binaries. The model UUID is set as an http header, and validated on the remote to be a model that is being imported.","created_at":"2016-11-15T05:12:09Z","updated_at":"2016-11-18T03:36:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef4b0a2d7df84c10c2786c9fd298f7994176117a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/juju/juju/pulls/6565/commits","review_comments_url":"https://api.github.com/repos/juju/juju/pulls/6565/comments","review_comment_url":"https://api.github.com/repos/juju/juju/pulls/comments{/number}","comments_url":"https://api.github.com/repos/juju/juju/issues/6565/comments","statuses_url":"https://api.github.com/repos/juju/juju/statuses/3d88f8ef66568e94882e30808051cbdec1718c30","head":{"label":"howbazaar:migrate-binary-endoints","ref":"migrate-binary-endoints","sha":"3d88f8ef66568e94882e30808051cbdec1718c30","user":{"login":"howbazaar","id":1744247,"avatar_url":"https://avatars.githubusercontent.com/u/1744247?v=3","gravatar_id":"","url":"https://api.github.com/users/howbazaar","html_url":"https://github.com/howbazaar","followers_url":"https://api.github.com/users/howbazaar/followers","following_url":"https://api.github.com/users/howbazaar/following{/other_user}","gists_url":"https://api.github.com/users/howbazaar/gists{/gist_id}","starred_url":"https://api.github.com/users/howbazaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howbazaar/subscriptions","organizations_url":"https://api.github.com/users/howbazaar/orgs","repos_url":"https://api.github.com/users/howbazaar/repos","events_url":"https://api.github.com/users/howbazaar/events{/privacy}","received_events_url":"https://api.github.com/users/howbazaar/received_events","type":"User","site_admin":false},"repo":{"id":20467403,"name":"juju","full_name":"howbazaar/juju","owner":{"login":"howbazaar","id":1744247,"avatar_url":"https://avatars.githubusercontent.com/u/1744247?v=3","gravatar_id":"","url":"https://api.github.com/users/howbazaar","html_url":"https://github.com/howbazaar","followers_url":"https://api.github.com/users/howbazaar/followers","following_url":"https://api.github.com/users/howbazaar/following{/other_user}","gists_url":"https://api.github.com/users/howbazaar/gists{/gist_id}","starred_url":"https://api.github.com/users/howbazaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/howbazaar/subscriptions","organizations_url":"https://api.github.com/users/howbazaar/orgs","repos_url":"https://api.github.com/users/howbazaar/repos","events_url":"https://api.github.com/users/howbazaar/events{/privacy}","received_events_url":"https://api.github.com/users/howbazaar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/howbazaar/juju","description":"juju is devops distilled","fork":true,"url":"https://api.github.com/repos/howbazaar/juju","forks_url":"https://api.github.com/repos/howbazaar/juju/forks","keys_url":"https://api.github.com/repos/howbazaar/juju/keys{/key_id}","collaborators_url":"https://api.github.com/repos/howbazaar/juju/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/howbazaar/juju/teams","hooks_url":"https://api.github.com/repos/howbazaar/juju/hooks","issue_events_url":"https://api.github.com/repos/howbazaar/juju/issues/events{/number}","events_url":"https://api.github.com/repos/howbazaar/juju/events","assignees_url":"https://api.github.com/repos/howbazaar/juju/assignees{/user}","branches_url":"https://api.github.com/repos/howbazaar/juju/branches{/branch}","tags_url":"https://api.github.com/repos/howbazaar/juju/tags","blobs_url":"https://api.github.com/repos/howbazaar/juju/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/howbazaar/juju/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/howbazaar/juju/git/refs{/sha}","trees_url":"https://api.github.com/repos/howbazaar/juju/git/trees{/sha}","statuses_url":"https://api.github.com/repos/howbazaar/juju/statuses/{sha}","languages_url":"https://api.github.com/repos/howbazaar/juju/languages","stargazers_url":"https://api.github.com/repos/howbazaar/juju/stargazers","contributors_url":"https://api.github.com/repos/howbazaar/juju/contributors","subscribers_url":"https://api.github.com/repos/howbazaar/juju/subscribers","subscription_url":"https://api.github.com/repos/howbazaar/juju/subscription","commits_url":"https://api.github.com/repos/howbazaar/juju/commits{/sha}","git_commits_url":"https://api.github.com/repos/howbazaar/juju/git/commits{/sha}","comments_url":"https://api.github.com/repos/howbazaar/juju/comments{/number}","issue_comment_url":"https://api.github.com/repos/howbazaar/juju/issues/comments{/number}","contents_url":"https://api.github.com/repos/howbazaar/juju/contents/{+path}","compare_url":"https://api.github.com/repos/howbazaar/juju/compare/{base}...{head}","merges_url":"https://api.github.com/repos/howbazaar/juju/merges","archive_url":"https://api.github.com/repos/howbazaar/juju/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/howbazaar/juju/downloads","issues_url":"https://api.github.com/repos/howbazaar/juju/issues{/number}","pulls_url":"https://api.github.com/repos/howbazaar/juju/pulls{/number}","milestones_url":"https://api.github.com/repos/howbazaar/juju/milestones{/number}","notifications_url":"https://api.github.com/repos/howbazaar/juju/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/howbazaar/juju/labels{/name}","releases_url":"https://api.github.com/repos/howbazaar/juju/releases{/id}","deployments_url":"https://api.github.com/repos/howbazaar/juju/deployments","created_at":"2014-06-04T02:27:18Z","updated_at":"2016-01-15T01:18:35Z","pushed_at":"2016-11-18T03:28:29Z","git_url":"git://github.com/howbazaar/juju.git","ssh_url":"git@github.com:howbazaar/juju.git","clone_url":"https://github.com/howbazaar/juju.git","svn_url":"https://github.com/howbazaar/juju","homepage":null,"size":93811,"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":"juju:develop","ref":"develop","sha":"045041638d694d2ebea8227f908eeb84ccabad07","user":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"repo":{"id":20445947,"name":"juju","full_name":"juju/juju","owner":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juju/juju","description":"juju is devops distilled","fork":false,"url":"https://api.github.com/repos/juju/juju","forks_url":"https://api.github.com/repos/juju/juju/forks","keys_url":"https://api.github.com/repos/juju/juju/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juju/juju/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juju/juju/teams","hooks_url":"https://api.github.com/repos/juju/juju/hooks","issue_events_url":"https://api.github.com/repos/juju/juju/issues/events{/number}","events_url":"https://api.github.com/repos/juju/juju/events","assignees_url":"https://api.github.com/repos/juju/juju/assignees{/user}","branches_url":"https://api.github.com/repos/juju/juju/branches{/branch}","tags_url":"https://api.github.com/repos/juju/juju/tags","blobs_url":"https://api.github.com/repos/juju/juju/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juju/juju/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juju/juju/git/refs{/sha}","trees_url":"https://api.github.com/repos/juju/juju/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juju/juju/statuses/{sha}","languages_url":"https://api.github.com/repos/juju/juju/languages","stargazers_url":"https://api.github.com/repos/juju/juju/stargazers","contributors_url":"https://api.github.com/repos/juju/juju/contributors","subscribers_url":"https://api.github.com/repos/juju/juju/subscribers","subscription_url":"https://api.github.com/repos/juju/juju/subscription","commits_url":"https://api.github.com/repos/juju/juju/commits{/sha}","git_commits_url":"https://api.github.com/repos/juju/juju/git/commits{/sha}","comments_url":"https://api.github.com/repos/juju/juju/comments{/number}","issue_comment_url":"https://api.github.com/repos/juju/juju/issues/comments{/number}","contents_url":"https://api.github.com/repos/juju/juju/contents/{+path}","compare_url":"https://api.github.com/repos/juju/juju/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juju/juju/merges","archive_url":"https://api.github.com/repos/juju/juju/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juju/juju/downloads","issues_url":"https://api.github.com/repos/juju/juju/issues{/number}","pulls_url":"https://api.github.com/repos/juju/juju/pulls{/number}","milestones_url":"https://api.github.com/repos/juju/juju/milestones{/number}","notifications_url":"https://api.github.com/repos/juju/juju/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juju/juju/labels{/name}","releases_url":"https://api.github.com/repos/juju/juju/releases{/id}","deployments_url":"https://api.github.com/repos/juju/juju/deployments","created_at":"2014-06-03T14:28:10Z","updated_at":"2016-11-16T21:13:07Z","pushed_at":"2016-11-18T03:28:29Z","git_url":"git://github.com/juju/juju.git","ssh_url":"git@github.com:juju/juju.git","clone_url":"https://github.com/juju/juju.git","svn_url":"https://github.com/juju/juju","homepage":"juju.ubuntu.com","size":128651,"stargazers_count":531,"watchers_count":531,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":164,"mirror_url":null,"open_issues_count":22,"forks":164,"open_issues":22,"watchers":531,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/juju/juju/pulls/6565"},"html":{"href":"https://github.com/juju/juju/pull/6565"},"issue":{"href":"https://api.github.com/repos/juju/juju/issues/6565"},"comments":{"href":"https://api.github.com/repos/juju/juju/issues/6565/comments"},"review_comments":{"href":"https://api.github.com/repos/juju/juju/pulls/6565/comments"},"review_comment":{"href":"https://api.github.com/repos/juju/juju/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/juju/juju/pulls/6565/commits"},"statuses":{"href":"https://api.github.com/repos/juju/juju/statuses/3d88f8ef66568e94882e30808051cbdec1718c30"}}}}
{"actor":{"display_login":"howbazaar"}}