{"action":"created","comment":{"url":"https://api.github.com/repos/ardanlabs/service/pulls/comments/201338474","pull_request_review_id":135818901,"id":201338474,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTMzODQ3NA==","diff_hunk":"@@ -0,0 +1,87 @@\n+package auth\n+\n+import (\n+\t\"crypto/rsa\"\n+\n+\tjwt \"github.com/dgrijalva/jwt-go\"\n+\t\"github.com/pkg/errors\"\n+)\n+\n+const (\n+\tRoleAdmin = \"ADMIN\"\n+\tRoleTODO  = \"TODO:MORE_ROLES\"\n+)\n+\n+// signingAlg is the agreed-upon algorithm that this application uses to sign\n+// and validate tokens.\n+//\n+// The method used to sign the JWT must be validated to avoid a critical\n+// vulnerability:\n+// https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/\n+var signingAlg = jwt.SigningMethodRS256\n+\n+// Claims represents the authorization claims transmitted via a JWT.\n+type Claims struct {\n+\tRoles []string `json:\"roles\"`\n+\tjwt.StandardClaims\n+}\n+\n+// GenerateToken generates a JWT token string.\n+func GenerateToken(key *rsa.PrivateKey, kid string, claims Claims) (string, error) {\n+\ttkn := jwt.NewWithClaims(signingAlg, claims)\n+\ttkn.Header[\"kid\"] = kid\n+\treturn tkn.SignedString(key)\n+}\n+\n+// KeyFunc is used to map a JWT key id (kid) to the corresponding public key.\n+// USE CASE:\n+// Private keys should be rotated. During the transition\n+// period, tokens signed with the old and new keys can coexist by looking up\n+// the correct public key by key id (kid).\n+//","path":"internal/auth/claims.go","position":41,"original_position":41,"commit_id":"4cc9d68f100c79004bac484361427c626e99e821","original_commit_id":"4cc9d68f100c79004bac484361427c626e99e821","user":{"login":"ardan-bkennedy","id":2280005,"node_id":"MDQ6VXNlcjIyODAwMDU=","avatar_url":"https://avatars3.githubusercontent.com/u/2280005?v=4","gravatar_id":"","url":"https://api.github.com/users/ardan-bkennedy","html_url":"https://github.com/ardan-bkennedy","followers_url":"https://api.github.com/users/ardan-bkennedy/followers","following_url":"https://api.github.com/users/ardan-bkennedy/following{/other_user}","gists_url":"https://api.github.com/users/ardan-bkennedy/gists{/gist_id}","starred_url":"https://api.github.com/users/ardan-bkennedy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardan-bkennedy/subscriptions","organizations_url":"https://api.github.com/users/ardan-bkennedy/orgs","repos_url":"https://api.github.com/users/ardan-bkennedy/repos","events_url":"https://api.github.com/users/ardan-bkennedy/events{/privacy}","received_events_url":"https://api.github.com/users/ardan-bkennedy/received_events","type":"User","site_admin":false},"body":"This space in the comment is bothering me. Maybe use a `*` for each point?","created_at":"2018-07-10T13:20:25Z","updated_at":"2018-07-10T13:20:25Z","html_url":"https://github.com/ardanlabs/service/pull/23#discussion_r201338474","pull_request_url":"https://api.github.com/repos/ardanlabs/service/pulls/23","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ardanlabs/service/pulls/comments/201338474"},"html":{"href":"https://github.com/ardanlabs/service/pull/23#discussion_r201338474"},"pull_request":{"href":"https://api.github.com/repos/ardanlabs/service/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/ardanlabs/service/pulls/23","id":198384588,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4Mzg0NTg4","html_url":"https://github.com/ardanlabs/service/pull/23","diff_url":"https://github.com/ardanlabs/service/pull/23.diff","patch_url":"https://github.com/ardanlabs/service/pull/23.patch","issue_url":"https://api.github.com/repos/ardanlabs/service/issues/23","number":23,"state":"open","locked":false,"title":"WIP: Add JWT auth middleware","user":{"login":"nstogner","id":10274189,"node_id":"MDQ6VXNlcjEwMjc0MTg5","avatar_url":"https://avatars1.githubusercontent.com/u/10274189?v=4","gravatar_id":"","url":"https://api.github.com/users/nstogner","html_url":"https://github.com/nstogner","followers_url":"https://api.github.com/users/nstogner/followers","following_url":"https://api.github.com/users/nstogner/following{/other_user}","gists_url":"https://api.github.com/users/nstogner/gists{/gist_id}","starred_url":"https://api.github.com/users/nstogner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nstogner/subscriptions","organizations_url":"https://api.github.com/users/nstogner/orgs","repos_url":"https://api.github.com/users/nstogner/repos","events_url":"https://api.github.com/users/nstogner/events{/privacy}","received_events_url":"https://api.github.com/users/nstogner/received_events","type":"User","site_admin":false},"body":"Currently a WIP... Adding middleware for auth via JWTs. Addresses #18.","created_at":"2018-06-29T17:57:30Z","updated_at":"2018-07-10T13:20:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbcd23ba5e0c90d288048b690e8c38d8f985e28f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ardanlabs/service/pulls/23/commits","review_comments_url":"https://api.github.com/repos/ardanlabs/service/pulls/23/comments","review_comment_url":"https://api.github.com/repos/ardanlabs/service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ardanlabs/service/issues/23/comments","statuses_url":"https://api.github.com/repos/ardanlabs/service/statuses/4cc9d68f100c79004bac484361427c626e99e821","head":{"label":"ardanlabs:feature/jwt-auth","ref":"feature/jwt-auth","sha":"4cc9d68f100c79004bac484361427c626e99e821","user":{"login":"ardanlabs","id":14281853,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MjgxODUz","avatar_url":"https://avatars2.githubusercontent.com/u/14281853?v=4","gravatar_id":"","url":"https://api.github.com/users/ardanlabs","html_url":"https://github.com/ardanlabs","followers_url":"https://api.github.com/users/ardanlabs/followers","following_url":"https://api.github.com/users/ardanlabs/following{/other_user}","gists_url":"https://api.github.com/users/ardanlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ardanlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardanlabs/subscriptions","organizations_url":"https://api.github.com/users/ardanlabs/orgs","repos_url":"https://api.github.com/users/ardanlabs/repos","events_url":"https://api.github.com/users/ardanlabs/events{/privacy}","received_events_url":"https://api.github.com/users/ardanlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":111423359,"node_id":"MDEwOlJlcG9zaXRvcnkxMTE0MjMzNTk=","name":"service","full_name":"ardanlabs/service","owner":{"login":"ardanlabs","id":14281853,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MjgxODUz","avatar_url":"https://avatars2.githubusercontent.com/u/14281853?v=4","gravatar_id":"","url":"https://api.github.com/users/ardanlabs","html_url":"https://github.com/ardanlabs","followers_url":"https://api.github.com/users/ardanlabs/followers","following_url":"https://api.github.com/users/ardanlabs/following{/other_user}","gists_url":"https://api.github.com/users/ardanlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ardanlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardanlabs/subscriptions","organizations_url":"https://api.github.com/users/ardanlabs/orgs","repos_url":"https://api.github.com/users/ardanlabs/repos","events_url":"https://api.github.com/users/ardanlabs/events{/privacy}","received_events_url":"https://api.github.com/users/ardanlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ardanlabs/service","description":"Starter code for writing web services in Go","fork":false,"url":"https://api.github.com/repos/ardanlabs/service","forks_url":"https://api.github.com/repos/ardanlabs/service/forks","keys_url":"https://api.github.com/repos/ardanlabs/service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ardanlabs/service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ardanlabs/service/teams","hooks_url":"https://api.github.com/repos/ardanlabs/service/hooks","issue_events_url":"https://api.github.com/repos/ardanlabs/service/issues/events{/number}","events_url":"https://api.github.com/repos/ardanlabs/service/events","assignees_url":"https://api.github.com/repos/ardanlabs/service/assignees{/user}","branches_url":"https://api.github.com/repos/ardanlabs/service/branches{/branch}","tags_url":"https://api.github.com/repos/ardanlabs/service/tags","blobs_url":"https://api.github.com/repos/ardanlabs/service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ardanlabs/service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ardanlabs/service/git/refs{/sha}","trees_url":"https://api.github.com/repos/ardanlabs/service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ardanlabs/service/statuses/{sha}","languages_url":"https://api.github.com/repos/ardanlabs/service/languages","stargazers_url":"https://api.github.com/repos/ardanlabs/service/stargazers","contributors_url":"https://api.github.com/repos/ardanlabs/service/contributors","subscribers_url":"https://api.github.com/repos/ardanlabs/service/subscribers","subscription_url":"https://api.github.com/repos/ardanlabs/service/subscription","commits_url":"https://api.github.com/repos/ardanlabs/service/commits{/sha}","git_commits_url":"https://api.github.com/repos/ardanlabs/service/git/commits{/sha}","comments_url":"https://api.github.com/repos/ardanlabs/service/comments{/number}","issue_comment_url":"https://api.github.com/repos/ardanlabs/service/issues/comments{/number}","contents_url":"https://api.github.com/repos/ardanlabs/service/contents/{+path}","compare_url":"https://api.github.com/repos/ardanlabs/service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ardanlabs/service/merges","archive_url":"https://api.github.com/repos/ardanlabs/service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ardanlabs/service/downloads","issues_url":"https://api.github.com/repos/ardanlabs/service/issues{/number}","pulls_url":"https://api.github.com/repos/ardanlabs/service/pulls{/number}","milestones_url":"https://api.github.com/repos/ardanlabs/service/milestones{/number}","notifications_url":"https://api.github.com/repos/ardanlabs/service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ardanlabs/service/labels{/name}","releases_url":"https://api.github.com/repos/ardanlabs/service/releases{/id}","deployments_url":"https://api.github.com/repos/ardanlabs/service/deployments","created_at":"2017-11-20T14:51:17Z","updated_at":"2018-07-10T08:49:34Z","pushed_at":"2018-07-07T02:11:59Z","git_url":"git://github.com/ardanlabs/service.git","ssh_url":"git@github.com:ardanlabs/service.git","clone_url":"https://github.com/ardanlabs/service.git","svn_url":"https://github.com/ardanlabs/service","homepage":"","size":12172,"stargazers_count":69,"watchers_count":69,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":18,"open_issues":9,"watchers":69,"default_branch":"master"}},"base":{"label":"ardanlabs:master","ref":"master","sha":"35faace8e7e7d1486eb24488c6e32854ff6ced69","user":{"login":"ardanlabs","id":14281853,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MjgxODUz","avatar_url":"https://avatars2.githubusercontent.com/u/14281853?v=4","gravatar_id":"","url":"https://api.github.com/users/ardanlabs","html_url":"https://github.com/ardanlabs","followers_url":"https://api.github.com/users/ardanlabs/followers","following_url":"https://api.github.com/users/ardanlabs/following{/other_user}","gists_url":"https://api.github.com/users/ardanlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ardanlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardanlabs/subscriptions","organizations_url":"https://api.github.com/users/ardanlabs/orgs","repos_url":"https://api.github.com/users/ardanlabs/repos","events_url":"https://api.github.com/users/ardanlabs/events{/privacy}","received_events_url":"https://api.github.com/users/ardanlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":111423359,"node_id":"MDEwOlJlcG9zaXRvcnkxMTE0MjMzNTk=","name":"service","full_name":"ardanlabs/service","owner":{"login":"ardanlabs","id":14281853,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MjgxODUz","avatar_url":"https://avatars2.githubusercontent.com/u/14281853?v=4","gravatar_id":"","url":"https://api.github.com/users/ardanlabs","html_url":"https://github.com/ardanlabs","followers_url":"https://api.github.com/users/ardanlabs/followers","following_url":"https://api.github.com/users/ardanlabs/following{/other_user}","gists_url":"https://api.github.com/users/ardanlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/ardanlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ardanlabs/subscriptions","organizations_url":"https://api.github.com/users/ardanlabs/orgs","repos_url":"https://api.github.com/users/ardanlabs/repos","events_url":"https://api.github.com/users/ardanlabs/events{/privacy}","received_events_url":"https://api.github.com/users/ardanlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ardanlabs/service","description":"Starter code for writing web services in Go","fork":false,"url":"https://api.github.com/repos/ardanlabs/service","forks_url":"https://api.github.com/repos/ardanlabs/service/forks","keys_url":"https://api.github.com/repos/ardanlabs/service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ardanlabs/service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ardanlabs/service/teams","hooks_url":"https://api.github.com/repos/ardanlabs/service/hooks","issue_events_url":"https://api.github.com/repos/ardanlabs/service/issues/events{/number}","events_url":"https://api.github.com/repos/ardanlabs/service/events","assignees_url":"https://api.github.com/repos/ardanlabs/service/assignees{/user}","branches_url":"https://api.github.com/repos/ardanlabs/service/branches{/branch}","tags_url":"https://api.github.com/repos/ardanlabs/service/tags","blobs_url":"https://api.github.com/repos/ardanlabs/service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ardanlabs/service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ardanlabs/service/git/refs{/sha}","trees_url":"https://api.github.com/repos/ardanlabs/service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ardanlabs/service/statuses/{sha}","languages_url":"https://api.github.com/repos/ardanlabs/service/languages","stargazers_url":"https://api.github.com/repos/ardanlabs/service/stargazers","contributors_url":"https://api.github.com/repos/ardanlabs/service/contributors","subscribers_url":"https://api.github.com/repos/ardanlabs/service/subscribers","subscription_url":"https://api.github.com/repos/ardanlabs/service/subscription","commits_url":"https://api.github.com/repos/ardanlabs/service/commits{/sha}","git_commits_url":"https://api.github.com/repos/ardanlabs/service/git/commits{/sha}","comments_url":"https://api.github.com/repos/ardanlabs/service/comments{/number}","issue_comment_url":"https://api.github.com/repos/ardanlabs/service/issues/comments{/number}","contents_url":"https://api.github.com/repos/ardanlabs/service/contents/{+path}","compare_url":"https://api.github.com/repos/ardanlabs/service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ardanlabs/service/merges","archive_url":"https://api.github.com/repos/ardanlabs/service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ardanlabs/service/downloads","issues_url":"https://api.github.com/repos/ardanlabs/service/issues{/number}","pulls_url":"https://api.github.com/repos/ardanlabs/service/pulls{/number}","milestones_url":"https://api.github.com/repos/ardanlabs/service/milestones{/number}","notifications_url":"https://api.github.com/repos/ardanlabs/service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ardanlabs/service/labels{/name}","releases_url":"https://api.github.com/repos/ardanlabs/service/releases{/id}","deployments_url":"https://api.github.com/repos/ardanlabs/service/deployments","created_at":"2017-11-20T14:51:17Z","updated_at":"2018-07-10T08:49:34Z","pushed_at":"2018-07-07T02:11:59Z","git_url":"git://github.com/ardanlabs/service.git","ssh_url":"git@github.com:ardanlabs/service.git","clone_url":"https://github.com/ardanlabs/service.git","svn_url":"https://github.com/ardanlabs/service","homepage":"","size":12172,"stargazers_count":69,"watchers_count":69,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":18,"open_issues":9,"watchers":69,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ardanlabs/service/pulls/23"},"html":{"href":"https://github.com/ardanlabs/service/pull/23"},"issue":{"href":"https://api.github.com/repos/ardanlabs/service/issues/23"},"comments":{"href":"https://api.github.com/repos/ardanlabs/service/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/ardanlabs/service/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/ardanlabs/service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ardanlabs/service/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/ardanlabs/service/statuses/4cc9d68f100c79004bac484361427c626e99e821"}},"author_association":"NONE"}}
{"actor":{"display_login":"ardan-bkennedy"}}