{"action":"created","comment":{"url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/comments/64057707","id":64057707,"diff_hunk":"@@ -161,6 +165,62 @@ func newMacaroonAuthenticator(macaroon string, discharges []string) *MacaroonAut\n \t}\n }\n \n+// MacaroonSerialize returns a store-compatible serialized representation of the given macaroon\n+func MacaroonSerialize(m *macaroon.Macaroon) (string, error) {\n+\tmarshalled, err := m.MarshalBinary()\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\tencoded := base64.URLEncoding.EncodeToString(marshalled)\n+\treturn encoded, nil\n+}\n+\n+// base64Decode decodes base64 data that might be missing trailing pad characters\n+// (copied from macaroon package; store serialized macaroons miss trailing padding)\n+func base64Decode(b64String string) ([]byte, error) {\n+\tpaddedLen := (len(b64String) + 3) / 4 * 4\n+\tb64data := make([]byte, len(b64String), paddedLen)\n+\tcopy(b64data, b64String)\n+\tfor i := len(b64String); i < paddedLen; i++ {\n+\t\tb64data = append(b64data, '=')\n+\t}\n+\tdata := make([]byte, base64.URLEncoding.DecodedLen(len(b64data)))\n+\tn, err := base64.URLEncoding.Decode(data, b64data)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\treturn data[0:n], nil\n+}\n+\n+// MacaroonDeserialize returns a deserialized macaroon from a given store-compatible serialization\n+func MacaroonDeserialize(serializedMacaroon string) (*macaroon.Macaroon, error) {\n+\tvar m macaroon.Macaroon\n+\tdecoded, err := base64Decode(serializedMacaroon)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\terr = m.UnmarshalBinary(decoded)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\treturn &m, nil\n+}\n+\n+// UbuntuoneCaveatForDischarge returns the 3rd party caveat from the macaroon to be discharged by Ubuntuone\n+func UbuntuoneCaveatForDischarge(m *macaroon.Macaroon) (string, error) {","path":"overlord/auth/auth.go","position":62,"original_position":62,"commit_id":"68d90a6056f1a2d3bba00a5e13abda0fbdc8c975","original_commit_id":"68d90a6056f1a2d3bba00a5e13abda0fbdc8c975","user":{"login":"niemeyer","id":378683,"avatar_url":"https://avatars.githubusercontent.com/u/378683?v=3","gravatar_id":"","url":"https://api.github.com/users/niemeyer","html_url":"https://github.com/niemeyer","followers_url":"https://api.github.com/users/niemeyer/followers","following_url":"https://api.github.com/users/niemeyer/following{/other_user}","gists_url":"https://api.github.com/users/niemeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/niemeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niemeyer/subscriptions","organizations_url":"https://api.github.com/users/niemeyer/orgs","repos_url":"https://api.github.com/users/niemeyer/repos","events_url":"https://api.github.com/users/niemeyer/events{/privacy}","received_events_url":"https://api.github.com/users/niemeyer/received_events","type":"User","site_admin":false},"body":"Would it be fair to call this one `LoginCaveatID`? Is that what it is?","created_at":"2016-05-20T15:15:45Z","updated_at":"2016-05-20T15:15:45Z","html_url":"https://github.com/ubuntu-core/snappy/pull/1146#discussion_r64057707","pull_request_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/1146","_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/comments/64057707"},"html":{"href":"https://github.com/ubuntu-core/snappy/pull/1146#discussion_r64057707"},"pull_request":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/1146"}}},"pull_request":{"url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/1146","id":69404265,"html_url":"https://github.com/ubuntu-core/snappy/pull/1146","diff_url":"https://github.com/ubuntu-core/snappy/pull/1146.diff","patch_url":"https://github.com/ubuntu-core/snappy/pull/1146.patch","issue_url":"https://api.github.com/repos/ubuntu-core/snappy/issues/1146","number":1146,"state":"open","locked":false,"title":"overlord/auth,store: add macaroon serialization/deserialization helpers","user":{"login":"matiasb","id":260710,"avatar_url":"https://avatars.githubusercontent.com/u/260710?v=3","gravatar_id":"","url":"https://api.github.com/users/matiasb","html_url":"https://github.com/matiasb","followers_url":"https://api.github.com/users/matiasb/followers","following_url":"https://api.github.com/users/matiasb/following{/other_user}","gists_url":"https://api.github.com/users/matiasb/gists{/gist_id}","starred_url":"https://api.github.com/users/matiasb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matiasb/subscriptions","organizations_url":"https://api.github.com/users/matiasb/orgs","repos_url":"https://api.github.com/users/matiasb/repos","events_url":"https://api.github.com/users/matiasb/events{/privacy}","received_events_url":"https://api.github.com/users/matiasb/received_events","type":"User","site_admin":false},"body":"Adds macaroon package dependency, and introduces macaroon serialization/deserialization helpers (compatible with store macaroon serialization).\r\nThese helpers will be used to extract macaroon information (which will be needed when requesting the discharge macaroon in the updated flow), and also to be able to prepare the discharge macaroon for request (ie. bind the discharge macaroon to the root macaroon).","created_at":"2016-05-09T20:20:59Z","updated_at":"2016-05-20T15:15:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0bb7aa6e19d6a024698b66b5c1b4c70a4895e5c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/1146/commits","review_comments_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/1146/comments","review_comment_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ubuntu-core/snappy/issues/1146/comments","statuses_url":"https://api.github.com/repos/ubuntu-core/snappy/statuses/68d90a6056f1a2d3bba00a5e13abda0fbdc8c975","head":{"label":"matiasb:adding-macaroon-package-dep","ref":"adding-macaroon-package-dep","sha":"68d90a6056f1a2d3bba00a5e13abda0fbdc8c975","user":{"login":"matiasb","id":260710,"avatar_url":"https://avatars.githubusercontent.com/u/260710?v=3","gravatar_id":"","url":"https://api.github.com/users/matiasb","html_url":"https://github.com/matiasb","followers_url":"https://api.github.com/users/matiasb/followers","following_url":"https://api.github.com/users/matiasb/following{/other_user}","gists_url":"https://api.github.com/users/matiasb/gists{/gist_id}","starred_url":"https://api.github.com/users/matiasb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matiasb/subscriptions","organizations_url":"https://api.github.com/users/matiasb/orgs","repos_url":"https://api.github.com/users/matiasb/repos","events_url":"https://api.github.com/users/matiasb/events{/privacy}","received_events_url":"https://api.github.com/users/matiasb/received_events","type":"User","site_admin":false},"repo":{"id":55512895,"name":"snappy","full_name":"matiasb/snappy","owner":{"login":"matiasb","id":260710,"avatar_url":"https://avatars.githubusercontent.com/u/260710?v=3","gravatar_id":"","url":"https://api.github.com/users/matiasb","html_url":"https://github.com/matiasb","followers_url":"https://api.github.com/users/matiasb/followers","following_url":"https://api.github.com/users/matiasb/following{/other_user}","gists_url":"https://api.github.com/users/matiasb/gists{/gist_id}","starred_url":"https://api.github.com/users/matiasb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matiasb/subscriptions","organizations_url":"https://api.github.com/users/matiasb/orgs","repos_url":"https://api.github.com/users/matiasb/repos","events_url":"https://api.github.com/users/matiasb/events{/privacy}","received_events_url":"https://api.github.com/users/matiasb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matiasb/snappy","description":"Snappy is the software at the heart of Ubuntu Core.","fork":true,"url":"https://api.github.com/repos/matiasb/snappy","forks_url":"https://api.github.com/repos/matiasb/snappy/forks","keys_url":"https://api.github.com/repos/matiasb/snappy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matiasb/snappy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matiasb/snappy/teams","hooks_url":"https://api.github.com/repos/matiasb/snappy/hooks","issue_events_url":"https://api.github.com/repos/matiasb/snappy/issues/events{/number}","events_url":"https://api.github.com/repos/matiasb/snappy/events","assignees_url":"https://api.github.com/repos/matiasb/snappy/assignees{/user}","branches_url":"https://api.github.com/repos/matiasb/snappy/branches{/branch}","tags_url":"https://api.github.com/repos/matiasb/snappy/tags","blobs_url":"https://api.github.com/repos/matiasb/snappy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matiasb/snappy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matiasb/snappy/git/refs{/sha}","trees_url":"https://api.github.com/repos/matiasb/snappy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matiasb/snappy/statuses/{sha}","languages_url":"https://api.github.com/repos/matiasb/snappy/languages","stargazers_url":"https://api.github.com/repos/matiasb/snappy/stargazers","contributors_url":"https://api.github.com/repos/matiasb/snappy/contributors","subscribers_url":"https://api.github.com/repos/matiasb/snappy/subscribers","subscription_url":"https://api.github.com/repos/matiasb/snappy/subscription","commits_url":"https://api.github.com/repos/matiasb/snappy/commits{/sha}","git_commits_url":"https://api.github.com/repos/matiasb/snappy/git/commits{/sha}","comments_url":"https://api.github.com/repos/matiasb/snappy/comments{/number}","issue_comment_url":"https://api.github.com/repos/matiasb/snappy/issues/comments{/number}","contents_url":"https://api.github.com/repos/matiasb/snappy/contents/{+path}","compare_url":"https://api.github.com/repos/matiasb/snappy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matiasb/snappy/merges","archive_url":"https://api.github.com/repos/matiasb/snappy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matiasb/snappy/downloads","issues_url":"https://api.github.com/repos/matiasb/snappy/issues{/number}","pulls_url":"https://api.github.com/repos/matiasb/snappy/pulls{/number}","milestones_url":"https://api.github.com/repos/matiasb/snappy/milestones{/number}","notifications_url":"https://api.github.com/repos/matiasb/snappy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matiasb/snappy/labels{/name}","releases_url":"https://api.github.com/repos/matiasb/snappy/releases{/id}","deployments_url":"https://api.github.com/repos/matiasb/snappy/deployments","created_at":"2016-04-05T14:04:31Z","updated_at":"2016-04-05T14:04:32Z","pushed_at":"2016-05-17T19:45:10Z","git_url":"git://github.com/matiasb/snappy.git","ssh_url":"git@github.com:matiasb/snappy.git","clone_url":"https://github.com/matiasb/snappy.git","svn_url":"https://github.com/matiasb/snappy","homepage":null,"size":29626,"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":"ubuntu-core:master","ref":"master","sha":"1400bc098c675ab5ec6a885be6b1f67273e1bf3a","user":{"login":"ubuntu-core","id":15022473,"avatar_url":"https://avatars.githubusercontent.com/u/15022473?v=3","gravatar_id":"","url":"https://api.github.com/users/ubuntu-core","html_url":"https://github.com/ubuntu-core","followers_url":"https://api.github.com/users/ubuntu-core/followers","following_url":"https://api.github.com/users/ubuntu-core/following{/other_user}","gists_url":"https://api.github.com/users/ubuntu-core/gists{/gist_id}","starred_url":"https://api.github.com/users/ubuntu-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubuntu-core/subscriptions","organizations_url":"https://api.github.com/users/ubuntu-core/orgs","repos_url":"https://api.github.com/users/ubuntu-core/repos","events_url":"https://api.github.com/users/ubuntu-core/events{/privacy}","received_events_url":"https://api.github.com/users/ubuntu-core/received_events","type":"Organization","site_admin":false},"repo":{"id":44672744,"name":"snappy","full_name":"ubuntu-core/snappy","owner":{"login":"ubuntu-core","id":15022473,"avatar_url":"https://avatars.githubusercontent.com/u/15022473?v=3","gravatar_id":"","url":"https://api.github.com/users/ubuntu-core","html_url":"https://github.com/ubuntu-core","followers_url":"https://api.github.com/users/ubuntu-core/followers","following_url":"https://api.github.com/users/ubuntu-core/following{/other_user}","gists_url":"https://api.github.com/users/ubuntu-core/gists{/gist_id}","starred_url":"https://api.github.com/users/ubuntu-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubuntu-core/subscriptions","organizations_url":"https://api.github.com/users/ubuntu-core/orgs","repos_url":"https://api.github.com/users/ubuntu-core/repos","events_url":"https://api.github.com/users/ubuntu-core/events{/privacy}","received_events_url":"https://api.github.com/users/ubuntu-core/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ubuntu-core/snappy","description":"Snappy is the software at the heart of Ubuntu Core.","fork":false,"url":"https://api.github.com/repos/ubuntu-core/snappy","forks_url":"https://api.github.com/repos/ubuntu-core/snappy/forks","keys_url":"https://api.github.com/repos/ubuntu-core/snappy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubuntu-core/snappy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubuntu-core/snappy/teams","hooks_url":"https://api.github.com/repos/ubuntu-core/snappy/hooks","issue_events_url":"https://api.github.com/repos/ubuntu-core/snappy/issues/events{/number}","events_url":"https://api.github.com/repos/ubuntu-core/snappy/events","assignees_url":"https://api.github.com/repos/ubuntu-core/snappy/assignees{/user}","branches_url":"https://api.github.com/repos/ubuntu-core/snappy/branches{/branch}","tags_url":"https://api.github.com/repos/ubuntu-core/snappy/tags","blobs_url":"https://api.github.com/repos/ubuntu-core/snappy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubuntu-core/snappy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubuntu-core/snappy/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubuntu-core/snappy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubuntu-core/snappy/statuses/{sha}","languages_url":"https://api.github.com/repos/ubuntu-core/snappy/languages","stargazers_url":"https://api.github.com/repos/ubuntu-core/snappy/stargazers","contributors_url":"https://api.github.com/repos/ubuntu-core/snappy/contributors","subscribers_url":"https://api.github.com/repos/ubuntu-core/snappy/subscribers","subscription_url":"https://api.github.com/repos/ubuntu-core/snappy/subscription","commits_url":"https://api.github.com/repos/ubuntu-core/snappy/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubuntu-core/snappy/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubuntu-core/snappy/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubuntu-core/snappy/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubuntu-core/snappy/contents/{+path}","compare_url":"https://api.github.com/repos/ubuntu-core/snappy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubuntu-core/snappy/merges","archive_url":"https://api.github.com/repos/ubuntu-core/snappy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubuntu-core/snappy/downloads","issues_url":"https://api.github.com/repos/ubuntu-core/snappy/issues{/number}","pulls_url":"https://api.github.com/repos/ubuntu-core/snappy/pulls{/number}","milestones_url":"https://api.github.com/repos/ubuntu-core/snappy/milestones{/number}","notifications_url":"https://api.github.com/repos/ubuntu-core/snappy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubuntu-core/snappy/labels{/name}","releases_url":"https://api.github.com/repos/ubuntu-core/snappy/releases{/id}","deployments_url":"https://api.github.com/repos/ubuntu-core/snappy/deployments","created_at":"2015-10-21T11:51:46Z","updated_at":"2016-05-18T07:28:59Z","pushed_at":"2016-05-20T15:05:19Z","git_url":"git://github.com/ubuntu-core/snappy.git","ssh_url":"git@github.com:ubuntu-core/snappy.git","clone_url":"https://github.com/ubuntu-core/snappy.git","svn_url":"https://github.com/ubuntu-core/snappy","homepage":null,"size":31051,"stargazers_count":194,"watchers_count":194,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":42,"mirror_url":null,"open_issues_count":20,"forks":42,"open_issues":20,"watchers":194,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/1146"},"html":{"href":"https://github.com/ubuntu-core/snappy/pull/1146"},"issue":{"href":"https://api.github.com/repos/ubuntu-core/snappy/issues/1146"},"comments":{"href":"https://api.github.com/repos/ubuntu-core/snappy/issues/1146/comments"},"review_comments":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/1146/comments"},"review_comment":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ubuntu-core/snappy/pulls/1146/commits"},"statuses":{"href":"https://api.github.com/repos/ubuntu-core/snappy/statuses/68d90a6056f1a2d3bba00a5e13abda0fbdc8c975"}}}}
{"actor":{"display_login":"niemeyer"}}