{"action":"created","comment":{"url":"https://api.github.com/repos/mendersoftware/mender/pulls/comments/67864174","id":67864174,"diff_hunk":"@@ -0,0 +1,69 @@\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\"math\"\n+\t\"os\"\n+\t\"strconv\"\n+\n+\t\"github.com/pkg/errors\"\n+)\n+\n+// Numeric sequence generator preserving its state in a file. The file will be\n+// saved in 'store' under name 'name'.\n+type FileSeqnum struct {\n+\tname  string\n+\tstore Store\n+}\n+\n+func NewFileSeqnum(name string, store Store) *FileSeqnum {\n+\treturn &FileSeqnum{\n+\t\tname:  name,\n+\t\tstore: store,\n+\t}\n+}\n+\n+// Obtain next sequence number. In case of errors (read, write, parse etc.)\n+// returned value is 0 and error is returned.\n+func (fs *FileSeqnum) Get() (uint64, error) {\n+\n+\td, err := fs.store.ReadAll(fs.name)\n+\tif err != nil && !os.IsNotExist(err) {\n+\t\treturn 0, errors.Wrapf(err, \"seqnum data read failed\")\n+\t}\n+\n+\tnewval := uint64(1)\n+\n+\tif !os.IsNotExist(err) {\n+\t\tv, err := strconv.ParseUint(string(d), 10, 64)\n+\t\tif err != nil {\n+\t\t\treturn 0, errors.Wrapf(err, \"seqnum data parse failed\")\n+\t\t}\n+\n+\t\t// check for overflow\n+\t\tif math.MaxUint64 == v {\n+\t\t\tnewval = SeqnumStartVal","path":"fileseqnum.go","position":57,"original_position":57,"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":"Let's just make sure to document this somewhere and that server will support this as well. What is more, this seems to be a bit tricky and vulnerable. Depending on how server-side will be implemented, if we will send `SeqnumStartVal` after any previously sent number it should be accepted since server couldn't know what client-side `math.MaxUint64`is.\r\n\r\nAny thoughts? ","created_at":"2016-06-21T13:10:48Z","updated_at":"2016-06-21T13:10:48Z","html_url":"https://github.com/mendersoftware/mender/pull/70#discussion_r67864174","pull_request_url":"https://api.github.com/repos/mendersoftware/mender/pulls/70","_links":{"self":{"href":"https://api.github.com/repos/mendersoftware/mender/pulls/comments/67864174"},"html":{"href":"https://github.com/mendersoftware/mender/pull/70#discussion_r67864174"},"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-21T13:10:48Z","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"}}