{"action":"created","comment":{"url":"https://api.github.com/repos/mendersoftware/mender/pulls/comments/67856679","id":67856679,"diff_hunk":"@@ -0,0 +1,218 @@\n+// Copyright 2016 Mender Software AS\n+//\n+//    Licensed under the Apache License, Version 2.0 (the \"License\");\n+//    you may not use this file except in compliance with the License.\n+//    You may obtain a copy of the License at\n+//\n+//        http://www.apache.org/licenses/LICENSE-2.0\n+//\n+//    Unless required by applicable law or agreed to in writing, software\n+//    distributed under the License is distributed on an \"AS IS\" BASIS,\n+//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+//    See the License for the specific language governing permissions and\n+//    limitations under the License.\n+package main\n+\n+import (\n+\t\"bytes\"\n+\t\"encoding/json\"\n+\t\"os\"\n+\n+\t\"github.com/mendersoftware/log\"\n+\t\"github.com/pkg/errors\"\n+)\n+\n+type AuthCode string\n+\n+type AuthReqData struct {\n+\tIdData      string `json:\"id_data\"`\n+\tTenantToken string `json:\"tenant_token\"`\n+\tPubkey      string `json:\"pubkey\"`\n+\tSeqNumber   uint64 `json:\"seq_no\"`\n+}\n+\n+type AuthRequest struct {\n+\t// request message data\n+\tData []byte\n+\t// authorization code\n+\tCode AuthCode\n+\t// request signature\n+\tSignature []byte\n+}\n+\n+// handler for authorization message data\n+type AuthDataMessenger interface {\n+\t// build authorization request data, returns auth request and authorization\n+\t// code for the request\n+\tMakeAuthRequest() (*AuthRequest, error)\n+\t// receive authoiriation data response, returns error if response is invalid\n+\tRecvAuthResponse([]byte) error\n+}\n+\n+type AuthManager interface {\n+\t// returns true if authorization data is current and valid\n+\tIsValid() bool\n+\t// return device's authoirization code\n+\tAuthCode() (AuthCode, error)\n+\t// check if device key is available\n+\tHasKey() bool\n+\t// generate device key (will overwrite an already existing key)\n+\tGenerateKey() error\n+\n+\tAuthDataMessenger\n+}\n+\n+const (\n+\tauthTokenName       = \"authtoken\"\n+\tauthTenantTokenName = \"authtentoken\"\n+\tauthSeqName         = \"authseq\"\n+\n+\tnoAuthCode = AuthCode(\"\")\n+)\n+\n+type MenderAuthManager struct {\n+\tstore    Store\n+\tkeystore *Keystore\n+\tkeyname  string\n+\tidsrc    IdentityDataGetter\n+\tseqnum   SeqnumGetter\n+}\n+\n+func NewAuthManager(store Store, keyname string, idsrc IdentityDataGetter) AuthManager {","path":"auth.go","position":81,"original_position":81,"commit_id":"9d148618d014608eb8b074403ad32945654d5c4a","original_commit_id":"9d148618d014608eb8b074403ad32945654d5c4a","user":{"login":"pasinskim","id":6329055,"avatar_url":"https://avatars.githubusercontent.com/u/6329055?v=3","gravatar_id":"","url":"https://api.github.com/users/pasinskim","html_url":"https://github.com/pasinskim","followers_url":"https://api.github.com/users/pasinskim/followers","following_url":"https://api.github.com/users/pasinskim/following{/other_user}","gists_url":"https://api.github.com/users/pasinskim/gists{/gist_id}","starred_url":"https://api.github.com/users/pasinskim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pasinskim/subscriptions","organizations_url":"https://api.github.com/users/pasinskim/orgs","repos_url":"https://api.github.com/users/pasinskim/repos","events_url":"https://api.github.com/users/pasinskim/events{/privacy}","received_events_url":"https://api.github.com/users/pasinskim/received_events","type":"User","site_admin":false},"body":"s/idsrc/idSrc/","created_at":"2016-06-21T12:16:10Z","updated_at":"2016-06-21T12:16:10Z","html_url":"https://github.com/mendersoftware/mender/pull/70#discussion_r67856679","pull_request_url":"https://api.github.com/repos/mendersoftware/mender/pulls/70","_links":{"self":{"href":"https://api.github.com/repos/mendersoftware/mender/pulls/comments/67856679"},"html":{"href":"https://github.com/mendersoftware/mender/pull/70#discussion_r67856679"},"pull_request":{"href":"https://api.github.com/repos/mendersoftware/mender/pulls/70"}}},"pull_request":{"url":"https://api.github.com/repos/mendersoftware/mender/pulls/70","id":74443323,"html_url":"https://github.com/mendersoftware/mender/pull/70","diff_url":"https://github.com/mendersoftware/mender/pull/70.diff","patch_url":"https://github.com/mendersoftware/mender/pull/70.patch","issue_url":"https://api.github.com/repos/mendersoftware/mender/issues/70","number":70,"state":"open","locked":false,"title":"Authorization workflow","user":{"login":"bboozzoo","id":41870,"avatar_url":"https://avatars.githubusercontent.com/u/41870?v=3","gravatar_id":"","url":"https://api.github.com/users/bboozzoo","html_url":"https://github.com/bboozzoo","followers_url":"https://api.github.com/users/bboozzoo/followers","following_url":"https://api.github.com/users/bboozzoo/following{/other_user}","gists_url":"https://api.github.com/users/bboozzoo/gists{/gist_id}","starred_url":"https://api.github.com/users/bboozzoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bboozzoo/subscriptions","organizations_url":"https://api.github.com/users/bboozzoo/orgs","repos_url":"https://api.github.com/users/bboozzoo/repos","events_url":"https://api.github.com/users/bboozzoo/events{/privacy}","received_events_url":"https://api.github.com/users/bboozzoo/received_events","type":"User","site_admin":false},"body":"The series of patches implemens a workflow for client authorization.\r\n\r\nThe first 5 patches are mostly cleanups/refactoring of things/helpers that were spotted along the way.\r\n\r\nDevice identity data is obtained using the helper script `support/mender-device-identity`. Right now the script outputs a per line `key=value` of identity data. This is parsed and collected into a single structure. @pasinskim suggested refactoring the script to just produce JSON output without the need for further parsing.\r\n\r\nSeqnum is a sequence generator with storage backing. This is needed for authorization requests.\r\n\r\nAn authorization client is implemented by `AuthManager` interface, with `AuthDataMessenger` being a helper interface that wraps producing/consuming of authorization requests. Tried to make the interface useful for other transports than HTTP as well. \r\n\r\n@pasinskim @kacf ","created_at":"2016-06-20T13:30:28Z","updated_at":"2016-06-21T12:16:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"066bafbd5f17c19c0465e7a73852a09b3798783d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mendersoftware/mender/pulls/70/commits","review_comments_url":"https://api.github.com/repos/mendersoftware/mender/pulls/70/comments","review_comment_url":"https://api.github.com/repos/mendersoftware/mender/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mendersoftware/mender/issues/70/comments","statuses_url":"https://api.github.com/repos/mendersoftware/mender/statuses/9d148618d014608eb8b074403ad32945654d5c4a","head":{"label":"bboozzoo:bboozzoo/bootstrap-states-with-auth","ref":"bboozzoo/bootstrap-states-with-auth","sha":"9d148618d014608eb8b074403ad32945654d5c4a","user":{"login":"bboozzoo","id":41870,"avatar_url":"https://avatars.githubusercontent.com/u/41870?v=3","gravatar_id":"","url":"https://api.github.com/users/bboozzoo","html_url":"https://github.com/bboozzoo","followers_url":"https://api.github.com/users/bboozzoo/followers","following_url":"https://api.github.com/users/bboozzoo/following{/other_user}","gists_url":"https://api.github.com/users/bboozzoo/gists{/gist_id}","starred_url":"https://api.github.com/users/bboozzoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bboozzoo/subscriptions","organizations_url":"https://api.github.com/users/bboozzoo/orgs","repos_url":"https://api.github.com/users/bboozzoo/repos","events_url":"https://api.github.com/users/bboozzoo/events{/privacy}","received_events_url":"https://api.github.com/users/bboozzoo/received_events","type":"User","site_admin":false},"repo":{"id":58195891,"name":"mender","full_name":"bboozzoo/mender","owner":{"login":"bboozzoo","id":41870,"avatar_url":"https://avatars.githubusercontent.com/u/41870?v=3","gravatar_id":"","url":"https://api.github.com/users/bboozzoo","html_url":"https://github.com/bboozzoo","followers_url":"https://api.github.com/users/bboozzoo/followers","following_url":"https://api.github.com/users/bboozzoo/following{/other_user}","gists_url":"https://api.github.com/users/bboozzoo/gists{/gist_id}","starred_url":"https://api.github.com/users/bboozzoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bboozzoo/subscriptions","organizations_url":"https://api.github.com/users/bboozzoo/orgs","repos_url":"https://api.github.com/users/bboozzoo/repos","events_url":"https://api.github.com/users/bboozzoo/events{/privacy}","received_events_url":"https://api.github.com/users/bboozzoo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bboozzoo/mender","description":"Mender over-the-air software updates.","fork":true,"url":"https://api.github.com/repos/bboozzoo/mender","forks_url":"https://api.github.com/repos/bboozzoo/mender/forks","keys_url":"https://api.github.com/repos/bboozzoo/mender/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bboozzoo/mender/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bboozzoo/mender/teams","hooks_url":"https://api.github.com/repos/bboozzoo/mender/hooks","issue_events_url":"https://api.github.com/repos/bboozzoo/mender/issues/events{/number}","events_url":"https://api.github.com/repos/bboozzoo/mender/events","assignees_url":"https://api.github.com/repos/bboozzoo/mender/assignees{/user}","branches_url":"https://api.github.com/repos/bboozzoo/mender/branches{/branch}","tags_url":"https://api.github.com/repos/bboozzoo/mender/tags","blobs_url":"https://api.github.com/repos/bboozzoo/mender/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bboozzoo/mender/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bboozzoo/mender/git/refs{/sha}","trees_url":"https://api.github.com/repos/bboozzoo/mender/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bboozzoo/mender/statuses/{sha}","languages_url":"https://api.github.com/repos/bboozzoo/mender/languages","stargazers_url":"https://api.github.com/repos/bboozzoo/mender/stargazers","contributors_url":"https://api.github.com/repos/bboozzoo/mender/contributors","subscribers_url":"https://api.github.com/repos/bboozzoo/mender/subscribers","subscription_url":"https://api.github.com/repos/bboozzoo/mender/subscription","commits_url":"https://api.github.com/repos/bboozzoo/mender/commits{/sha}","git_commits_url":"https://api.github.com/repos/bboozzoo/mender/git/commits{/sha}","comments_url":"https://api.github.com/repos/bboozzoo/mender/comments{/number}","issue_comment_url":"https://api.github.com/repos/bboozzoo/mender/issues/comments{/number}","contents_url":"https://api.github.com/repos/bboozzoo/mender/contents/{+path}","compare_url":"https://api.github.com/repos/bboozzoo/mender/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bboozzoo/mender/merges","archive_url":"https://api.github.com/repos/bboozzoo/mender/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bboozzoo/mender/downloads","issues_url":"https://api.github.com/repos/bboozzoo/mender/issues{/number}","pulls_url":"https://api.github.com/repos/bboozzoo/mender/pulls{/number}","milestones_url":"https://api.github.com/repos/bboozzoo/mender/milestones{/number}","notifications_url":"https://api.github.com/repos/bboozzoo/mender/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bboozzoo/mender/labels{/name}","releases_url":"https://api.github.com/repos/bboozzoo/mender/releases{/id}","deployments_url":"https://api.github.com/repos/bboozzoo/mender/deployments","created_at":"2016-05-06T09:20:01Z","updated_at":"2016-05-06T09:20:02Z","pushed_at":"2016-06-20T15:49:39Z","git_url":"git://github.com/bboozzoo/mender.git","ssh_url":"git@github.com:bboozzoo/mender.git","clone_url":"https://github.com/bboozzoo/mender.git","svn_url":"https://github.com/bboozzoo/mender","homepage":"https://mender.io","size":912,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"mendersoftware:master","ref":"master","sha":"5d6116dfa96eb06e2a282288feeeb19df98305f9","user":{"login":"mendersoftware","id":15040539,"avatar_url":"https://avatars.githubusercontent.com/u/15040539?v=3","gravatar_id":"","url":"https://api.github.com/users/mendersoftware","html_url":"https://github.com/mendersoftware","followers_url":"https://api.github.com/users/mendersoftware/followers","following_url":"https://api.github.com/users/mendersoftware/following{/other_user}","gists_url":"https://api.github.com/users/mendersoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/mendersoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mendersoftware/subscriptions","organizations_url":"https://api.github.com/users/mendersoftware/orgs","repos_url":"https://api.github.com/users/mendersoftware/repos","events_url":"https://api.github.com/users/mendersoftware/events{/privacy}","received_events_url":"https://api.github.com/users/mendersoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":47542798,"name":"mender","full_name":"mendersoftware/mender","owner":{"login":"mendersoftware","id":15040539,"avatar_url":"https://avatars.githubusercontent.com/u/15040539?v=3","gravatar_id":"","url":"https://api.github.com/users/mendersoftware","html_url":"https://github.com/mendersoftware","followers_url":"https://api.github.com/users/mendersoftware/followers","following_url":"https://api.github.com/users/mendersoftware/following{/other_user}","gists_url":"https://api.github.com/users/mendersoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/mendersoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mendersoftware/subscriptions","organizations_url":"https://api.github.com/users/mendersoftware/orgs","repos_url":"https://api.github.com/users/mendersoftware/repos","events_url":"https://api.github.com/users/mendersoftware/events{/privacy}","received_events_url":"https://api.github.com/users/mendersoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mendersoftware/mender","description":"Mender over-the-air software updates.","fork":false,"url":"https://api.github.com/repos/mendersoftware/mender","forks_url":"https://api.github.com/repos/mendersoftware/mender/forks","keys_url":"https://api.github.com/repos/mendersoftware/mender/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mendersoftware/mender/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mendersoftware/mender/teams","hooks_url":"https://api.github.com/repos/mendersoftware/mender/hooks","issue_events_url":"https://api.github.com/repos/mendersoftware/mender/issues/events{/number}","events_url":"https://api.github.com/repos/mendersoftware/mender/events","assignees_url":"https://api.github.com/repos/mendersoftware/mender/assignees{/user}","branches_url":"https://api.github.com/repos/mendersoftware/mender/branches{/branch}","tags_url":"https://api.github.com/repos/mendersoftware/mender/tags","blobs_url":"https://api.github.com/repos/mendersoftware/mender/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mendersoftware/mender/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mendersoftware/mender/git/refs{/sha}","trees_url":"https://api.github.com/repos/mendersoftware/mender/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mendersoftware/mender/statuses/{sha}","languages_url":"https://api.github.com/repos/mendersoftware/mender/languages","stargazers_url":"https://api.github.com/repos/mendersoftware/mender/stargazers","contributors_url":"https://api.github.com/repos/mendersoftware/mender/contributors","subscribers_url":"https://api.github.com/repos/mendersoftware/mender/subscribers","subscription_url":"https://api.github.com/repos/mendersoftware/mender/subscription","commits_url":"https://api.github.com/repos/mendersoftware/mender/commits{/sha}","git_commits_url":"https://api.github.com/repos/mendersoftware/mender/git/commits{/sha}","comments_url":"https://api.github.com/repos/mendersoftware/mender/comments{/number}","issue_comment_url":"https://api.github.com/repos/mendersoftware/mender/issues/comments{/number}","contents_url":"https://api.github.com/repos/mendersoftware/mender/contents/{+path}","compare_url":"https://api.github.com/repos/mendersoftware/mender/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mendersoftware/mender/merges","archive_url":"https://api.github.com/repos/mendersoftware/mender/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mendersoftware/mender/downloads","issues_url":"https://api.github.com/repos/mendersoftware/mender/issues{/number}","pulls_url":"https://api.github.com/repos/mendersoftware/mender/pulls{/number}","milestones_url":"https://api.github.com/repos/mendersoftware/mender/milestones{/number}","notifications_url":"https://api.github.com/repos/mendersoftware/mender/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mendersoftware/mender/labels{/name}","releases_url":"https://api.github.com/repos/mendersoftware/mender/releases{/id}","deployments_url":"https://api.github.com/repos/mendersoftware/mender/deployments","created_at":"2015-12-07T09:36:43Z","updated_at":"2016-05-11T10:44:26Z","pushed_at":"2016-06-20T15:49:39Z","git_url":"git://github.com/mendersoftware/mender.git","ssh_url":"git@github.com:mendersoftware/mender.git","clone_url":"https://github.com/mendersoftware/mender.git","svn_url":"https://github.com/mendersoftware/mender","homepage":"https://mender.io","size":859,"stargazers_count":10,"watchers_count":10,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":1,"forks":11,"open_issues":1,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mendersoftware/mender/pulls/70"},"html":{"href":"https://github.com/mendersoftware/mender/pull/70"},"issue":{"href":"https://api.github.com/repos/mendersoftware/mender/issues/70"},"comments":{"href":"https://api.github.com/repos/mendersoftware/mender/issues/70/comments"},"review_comments":{"href":"https://api.github.com/repos/mendersoftware/mender/pulls/70/comments"},"review_comment":{"href":"https://api.github.com/repos/mendersoftware/mender/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mendersoftware/mender/pulls/70/commits"},"statuses":{"href":"https://api.github.com/repos/mendersoftware/mender/statuses/9d148618d014608eb8b074403ad32945654d5c4a"}}}}
{"actor":{"display_login":"pasinskim"}}