{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd/pulls/comments/76181074","id":76181074,"diff_hunk":"@@ -237,8 +253,29 @@ func (as *authStore) Authenticate(ctx context.Context, username, password string\n \t\treturn &pb.AuthenticateResponse{}, ErrAuthFailed\n \t}\n \n-\ttoken := fmt.Sprintf(\"%s.%d\", simpleToken, index)\n-\tas.assignSimpleTokenToUser(username, token)\n+\tvar token string\n+\n+\tswitch as.tokenType {\n+\tcase TokenSimple:\n+\t\tsimpleToken := ctx.Value(\"simpleToken\").(string)\n+\t\ttoken = fmt.Sprintf(\"%s.%d\", simpleToken, index)\n+\t\tas.assignSimpleTokenToUser(username, token)\n+\tcase TokenJwt:\n+\t\tt := jwt.NewWithClaims(jwt.GetSigningMethod(as.signMethod),\n+\t\t\tjwt.MapClaims{\n+\t\t\t\t\"username\": username,","path":"auth/store.go","position":79,"original_position":79,"commit_id":"bd89a2d5fd3f5f56c040fffbc780f2fffec7a60e","original_commit_id":"bd89a2d5fd3f5f56c040fffbc780f2fffec7a60e","user":{"login":"mitake","id":1173955,"avatar_url":"https://avatars.githubusercontent.com/u/1173955?v=3","gravatar_id":"","url":"https://api.github.com/users/mitake","html_url":"https://github.com/mitake","followers_url":"https://api.github.com/users/mitake/followers","following_url":"https://api.github.com/users/mitake/following{/other_user}","gists_url":"https://api.github.com/users/mitake/gists{/gist_id}","starred_url":"https://api.github.com/users/mitake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitake/subscriptions","organizations_url":"https://api.github.com/users/mitake/orgs","repos_url":"https://api.github.com/users/mitake/repos","events_url":"https://api.github.com/users/mitake/events{/privacy}","received_events_url":"https://api.github.com/users/mitake/received_events","type":"User","site_admin":false},"body":"OK, is adding the TODO as a comment ok for now ?","created_at":"2016-08-25T05:11:06Z","updated_at":"2016-08-25T05:11:06Z","html_url":"https://github.com/coreos/etcd/pull/6082#discussion_r76181074","pull_request_url":"https://api.github.com/repos/coreos/etcd/pulls/6082","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments/76181074"},"html":{"href":"https://github.com/coreos/etcd/pull/6082#discussion_r76181074"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd/pulls/6082"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd/pulls/6082","id":79693152,"html_url":"https://github.com/coreos/etcd/pull/6082","diff_url":"https://github.com/coreos/etcd/pull/6082.diff","patch_url":"https://github.com/coreos/etcd/pull/6082.patch","issue_url":"https://api.github.com/repos/coreos/etcd/issues/6082","number":6082,"state":"open","locked":false,"title":"*: support jwt token in v3 auth API","user":{"login":"mitake","id":1173955,"avatar_url":"https://avatars.githubusercontent.com/u/1173955?v=3","gravatar_id":"","url":"https://api.github.com/users/mitake","html_url":"https://github.com/mitake","followers_url":"https://api.github.com/users/mitake/followers","following_url":"https://api.github.com/users/mitake/following{/other_user}","gists_url":"https://api.github.com/users/mitake/gists{/gist_id}","starred_url":"https://api.github.com/users/mitake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitake/subscriptions","organizations_url":"https://api.github.com/users/mitake/orgs","repos_url":"https://api.github.com/users/mitake/repos","events_url":"https://api.github.com/users/mitake/events{/privacy}","received_events_url":"https://api.github.com/users/mitake/received_events","type":"User","site_admin":false},"body":"This PR adds jwt token support in v3 auth API.\r\n\r\nRemaining major ToDos:\r\n- Currently token type isn't hidden from etcdserver. In the near\r\n  future the information should be completely invisible from\r\n  etcdserver package.\r\n- Configurable expiration of token. Currently tokens can be valid\r\n  until keys are changed.\r\n\r\nHow to use:\r\n1. generate keys for signing and verfying jwt tokens:\r\n $ openssl genrsa -out app.rsa 1024\r\n $ openssl rsa -in app.rsa -pubout > app.rsa.pub\r\n\r\n2.  add command line options to etcd like below:\r\n--v3-auth-token-type jwt \\\r\n--v3-auth-jwt-pub-key app.rsa.pub --v3-auth-jwt-priv-key app.rsa \\\r\n--v3-auth-jwt-sign-method RS512\r\n\r\n3. launch etcd cluster\r\n\r\nBelow is a performance comparison of serializable read w/ and w/o jwt\r\ntoken. Every (3) etcd node is executed on a single machine. Signing\r\nmethod is RS512 and key length is 1024 bit. As the results show, jwt\r\nbased token introduces a performance overhead but it would be\r\nacceptable for a case that requires authentication.\r\n\r\n### w/o jwt token auth (no auth):\r\n\r\n```\r\nSummary:\r\n  Total:        1.6172 secs.\r\n  Slowest:      0.0125 secs.\r\n  Fastest:      0.0001 secs.\r\n  Average:      0.0002 secs.\r\n  Stddev:       0.0004 secs.\r\n  Requests/sec: 6183.5877\r\n\r\nResponse time histogram:\r\n  0.000 [1]     |\r\n  0.001 [9982]  |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎\r\n  0.003 [1]     |\r\n  0.004 [1]     |\r\n  0.005 [0]     |\r\n  0.006 [0]     |\r\n  0.008 [6]     |\r\n  0.009 [0]     |\r\n  0.010 [1]     |\r\n  0.011 [5]     |\r\n  0.013 [3]     |\r\n\r\nLatency distribution:\r\n  10% in 0.0001 secs.\r\n  25% in 0.0001 secs.\r\n  50% in 0.0001 secs.\r\n  75% in 0.0001 secs.\r\n  90% in 0.0002 secs.\r\n  95% in 0.0002 secs.\r\n  99% in 0.0003 secs.\r\n```\r\n\r\n### w/ jwt token auth:\r\n\r\n```\r\nSummary:\r\n  Total:        2.5364 secs.\r\n  Slowest:      0.0182 secs.\r\n  Fastest:      0.0002 secs.\r\n  Average:      0.0003 secs.\r\n  Stddev:       0.0005 secs.\r\n  Requests/sec: 3942.5185\r\n\r\nResponse time histogram:\r\n  0.000 [1]     |\r\n  0.002 [9975]  |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎\r\n  0.004 [0]     |\r\n  0.006 [1]     |\r\n  0.007 [11]    |\r\n  0.009 [2]     |\r\n  0.011 [4]     |\r\n  0.013 [5]     |\r\n  0.015 [0]     |\r\n  0.016 [0]     |\r\n  0.018 [1]     |\r\n\r\nLatency distribution:\r\n  10% in 0.0002 secs.\r\n  25% in 0.0002 secs.\r\n  50% in 0.0002 secs.\r\n  75% in 0.0002 secs.\r\n  90% in 0.0003 secs.\r\n  95% in 0.0003 secs.\r\n  99% in 0.0004 secs.\r\n```","created_at":"2016-08-02T08:15:15Z","updated_at":"2016-08-25T05:11:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8229449fcfe47fbf46aca678aa8c22819d4c76a9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/coreos/etcd/pulls/6082/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd/pulls/6082/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/6082/comments","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/bd89a2d5fd3f5f56c040fffbc780f2fffec7a60e","head":{"label":"mitake:auth-v3-jwt","ref":"auth-v3-jwt","sha":"bd89a2d5fd3f5f56c040fffbc780f2fffec7a60e","user":{"login":"mitake","id":1173955,"avatar_url":"https://avatars.githubusercontent.com/u/1173955?v=3","gravatar_id":"","url":"https://api.github.com/users/mitake","html_url":"https://github.com/mitake","followers_url":"https://api.github.com/users/mitake/followers","following_url":"https://api.github.com/users/mitake/following{/other_user}","gists_url":"https://api.github.com/users/mitake/gists{/gist_id}","starred_url":"https://api.github.com/users/mitake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitake/subscriptions","organizations_url":"https://api.github.com/users/mitake/orgs","repos_url":"https://api.github.com/users/mitake/repos","events_url":"https://api.github.com/users/mitake/events{/privacy}","received_events_url":"https://api.github.com/users/mitake/received_events","type":"User","site_admin":false},"repo":{"id":40219422,"name":"etcd","full_name":"mitake/etcd","owner":{"login":"mitake","id":1173955,"avatar_url":"https://avatars.githubusercontent.com/u/1173955?v=3","gravatar_id":"","url":"https://api.github.com/users/mitake","html_url":"https://github.com/mitake","followers_url":"https://api.github.com/users/mitake/followers","following_url":"https://api.github.com/users/mitake/following{/other_user}","gists_url":"https://api.github.com/users/mitake/gists{/gist_id}","starred_url":"https://api.github.com/users/mitake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitake/subscriptions","organizations_url":"https://api.github.com/users/mitake/orgs","repos_url":"https://api.github.com/users/mitake/repos","events_url":"https://api.github.com/users/mitake/events{/privacy}","received_events_url":"https://api.github.com/users/mitake/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mitake/etcd","description":"A distributed consistent key-value store for shared configuration and service discovery","fork":true,"url":"https://api.github.com/repos/mitake/etcd","forks_url":"https://api.github.com/repos/mitake/etcd/forks","keys_url":"https://api.github.com/repos/mitake/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitake/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitake/etcd/teams","hooks_url":"https://api.github.com/repos/mitake/etcd/hooks","issue_events_url":"https://api.github.com/repos/mitake/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/mitake/etcd/events","assignees_url":"https://api.github.com/repos/mitake/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/mitake/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/mitake/etcd/tags","blobs_url":"https://api.github.com/repos/mitake/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitake/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitake/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitake/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitake/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/mitake/etcd/languages","stargazers_url":"https://api.github.com/repos/mitake/etcd/stargazers","contributors_url":"https://api.github.com/repos/mitake/etcd/contributors","subscribers_url":"https://api.github.com/repos/mitake/etcd/subscribers","subscription_url":"https://api.github.com/repos/mitake/etcd/subscription","commits_url":"https://api.github.com/repos/mitake/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitake/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitake/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitake/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitake/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/mitake/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitake/etcd/merges","archive_url":"https://api.github.com/repos/mitake/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitake/etcd/downloads","issues_url":"https://api.github.com/repos/mitake/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/mitake/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/mitake/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/mitake/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitake/etcd/labels{/name}","releases_url":"https://api.github.com/repos/mitake/etcd/releases{/id}","deployments_url":"https://api.github.com/repos/mitake/etcd/deployments","created_at":"2015-08-05T02:10:59Z","updated_at":"2015-08-05T02:11:01Z","pushed_at":"2016-08-23T01:55:06Z","git_url":"git://github.com/mitake/etcd.git","ssh_url":"git@github.com:mitake/etcd.git","clone_url":"https://github.com/mitake/etcd.git","svn_url":"https://github.com/mitake/etcd","homepage":"","size":23093,"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":"coreos:master","ref":"master","sha":"0504b277b65a5f236f41ad661abc3123167fb8cf","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":11225014,"name":"etcd","full_name":"coreos/etcd","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/etcd","description":"Distributed reliable key-value store for the most critical data of a distributed system","fork":false,"url":"https://api.github.com/repos/coreos/etcd","forks_url":"https://api.github.com/repos/coreos/etcd/forks","keys_url":"https://api.github.com/repos/coreos/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd/teams","hooks_url":"https://api.github.com/repos/coreos/etcd/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd/events","assignees_url":"https://api.github.com/repos/coreos/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd/tags","blobs_url":"https://api.github.com/repos/coreos/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd/subscription","commits_url":"https://api.github.com/repos/coreos/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd/merges","archive_url":"https://api.github.com/repos/coreos/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd/downloads","issues_url":"https://api.github.com/repos/coreos/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd/releases{/id}","deployments_url":"https://api.github.com/repos/coreos/etcd/deployments","created_at":"2013-07-06T21:57:21Z","updated_at":"2016-08-25T01:02:43Z","pushed_at":"2016-08-24T22:23:20Z","git_url":"git://github.com/coreos/etcd.git","ssh_url":"git@github.com:coreos/etcd.git","clone_url":"https://github.com/coreos/etcd.git","svn_url":"https://github.com/coreos/etcd","homepage":"https://coreos.com/etcd/docs/latest/","size":30237,"stargazers_count":10611,"watchers_count":10611,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1850,"mirror_url":null,"open_issues_count":118,"forks":1850,"open_issues":118,"watchers":10611,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/6082"},"html":{"href":"https://github.com/coreos/etcd/pull/6082"},"issue":{"href":"https://api.github.com/repos/coreos/etcd/issues/6082"},"comments":{"href":"https://api.github.com/repos/coreos/etcd/issues/6082/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd/pulls/6082/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd/pulls/6082/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd/statuses/bd89a2d5fd3f5f56c040fffbc780f2fffec7a60e"}}}}
{"actor":{"display_login":"mitake"}}