{"action":"created","comment":{"url":"https://api.github.com/repos/TryGhost/Ghost/pulls/comments/222528653","pull_request_review_id":161436330,"id":222528653,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjUyODY1Mw==","diff_hunk":"@@ -98,7 +98,13 @@ authenticate = {\n                 }));\n             }\n         )(req, res, next);\n-    }\n+    },\n+\n+    // ### v2 API auth middleware\n+    rejectAdminApiKey: apiKeyAuth.admin.rejectAdminApiKey,\n+    authenticateAdminApiKey: apiKeyAuth.admin.authenticateAdminApiKey,\n+    rejectContentApiKey: apiKeyAuth.content.rejectContentApiKey,","path":"core/server/services/auth/authenticate.js","position":27,"original_position":27,"commit_id":"2cd5738dea1e729962a209bac9062eaf71d247a0","original_commit_id":"2cd5738dea1e729962a209bac9062eaf71d247a0","user":{"login":"allouis","id":3218915,"node_id":"MDQ6VXNlcjMyMTg5MTU=","avatar_url":"https://avatars3.githubusercontent.com/u/3218915?v=4","gravatar_id":"","url":"https://api.github.com/users/allouis","html_url":"https://github.com/allouis","followers_url":"https://api.github.com/users/allouis/followers","following_url":"https://api.github.com/users/allouis/following{/other_user}","gists_url":"https://api.github.com/users/allouis/gists{/gist_id}","starred_url":"https://api.github.com/users/allouis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allouis/subscriptions","organizations_url":"https://api.github.com/users/allouis/orgs","repos_url":"https://api.github.com/users/allouis/repos","events_url":"https://api.github.com/users/allouis/events{/privacy}","received_events_url":"https://api.github.com/users/allouis/received_events","type":"User","site_admin":false},"body":"And this :ghost: ","created_at":"2018-10-04T03:28:32Z","updated_at":"2018-10-04T03:28:32Z","html_url":"https://github.com/TryGhost/Ghost/pull/9915#discussion_r222528653","pull_request_url":"https://api.github.com/repos/TryGhost/Ghost/pulls/9915","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/comments/222528653"},"html":{"href":"https://github.com/TryGhost/Ghost/pull/9915#discussion_r222528653"},"pull_request":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/9915"}}},"pull_request":{"url":"https://api.github.com/repos/TryGhost/Ghost/pulls/9915","id":218377019,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE4Mzc3MDE5","html_url":"https://github.com/TryGhost/Ghost/pull/9915","diff_url":"https://github.com/TryGhost/Ghost/pull/9915.diff","patch_url":"https://github.com/TryGhost/Ghost/pull/9915.patch","issue_url":"https://api.github.com/repos/TryGhost/Ghost/issues/9915","number":9915,"state":"open","locked":false,"title":"Added API Key authentication middleware to v2 API routes","user":{"login":"kevinansfield","id":415,"node_id":"MDQ6VXNlcjQxNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/415?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinansfield","html_url":"https://github.com/kevinansfield","followers_url":"https://api.github.com/users/kevinansfield/followers","following_url":"https://api.github.com/users/kevinansfield/following{/other_user}","gists_url":"https://api.github.com/users/kevinansfield/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinansfield/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinansfield/subscriptions","organizations_url":"https://api.github.com/users/kevinansfield/orgs","repos_url":"https://api.github.com/users/kevinansfield/repos","events_url":"https://api.github.com/users/kevinansfield/events{/privacy}","received_events_url":"https://api.github.com/users/kevinansfield/received_events","type":"User","site_admin":false},"body":"refs #9865\r\n- add `auth.authenticate.authenticateAdminApiKey` middleware\r\n  - accepts signed JWT in an `Authorization: Ghost [token]` header\r\n  - sets `req.api_key` if the token is valid\r\n- add `auth.authenticate.authenticateContentApiKey` middleware\r\n  - accepts `?content_key=` query param, sets `req.api_key` if it's a known Content API key\r\n- add `requiresAuthorizedUserOrApiKey` authorization middleware\r\n  - passes if either `req.user` or `req.api_key` exists\r\n- update `authenticatePrivate` middleware stack for v2 admin routes\r\n- update `authenticatePublic` middleware stack for v2 content routes\r\n\r\nSplit out from https://github.com/TryGhost/Ghost/pull/9869 for easier review.\r\n\r\nTODO:\r\n- [x] remove oauth2 specific `Bearer` in `Authorization` header\r\n- [x] extract `rejectAdminKey` and `rejectContentKey` into separate middlewares\r\n- [x] add comment documenting `authenticateAdminApiKey` flow\r\n- [x] add `authenticateContentApiKey` middleware to v2 content API routes\r\n- [x] i18n error messages\r\n- [x] remove `rejectAdminKey` and `rejectContentKey` middleware","created_at":"2018-09-26T16:18:15Z","updated_at":"2018-10-04T03:28:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"379863f6487449857a56e07c1996075d94132e76","assignee":{"login":"kirrg001","id":1160712,"node_id":"MDQ6VXNlcjExNjA3MTI=","avatar_url":"https://avatars0.githubusercontent.com/u/1160712?v=4","gravatar_id":"","url":"https://api.github.com/users/kirrg001","html_url":"https://github.com/kirrg001","followers_url":"https://api.github.com/users/kirrg001/followers","following_url":"https://api.github.com/users/kirrg001/following{/other_user}","gists_url":"https://api.github.com/users/kirrg001/gists{/gist_id}","starred_url":"https://api.github.com/users/kirrg001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirrg001/subscriptions","organizations_url":"https://api.github.com/users/kirrg001/orgs","repos_url":"https://api.github.com/users/kirrg001/repos","events_url":"https://api.github.com/users/kirrg001/events{/privacy}","received_events_url":"https://api.github.com/users/kirrg001/received_events","type":"User","site_admin":false},"assignees":[{"login":"kirrg001","id":1160712,"node_id":"MDQ6VXNlcjExNjA3MTI=","avatar_url":"https://avatars0.githubusercontent.com/u/1160712?v=4","gravatar_id":"","url":"https://api.github.com/users/kirrg001","html_url":"https://github.com/kirrg001","followers_url":"https://api.github.com/users/kirrg001/followers","following_url":"https://api.github.com/users/kirrg001/following{/other_user}","gists_url":"https://api.github.com/users/kirrg001/gists{/gist_id}","starred_url":"https://api.github.com/users/kirrg001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirrg001/subscriptions","organizations_url":"https://api.github.com/users/kirrg001/orgs","repos_url":"https://api.github.com/users/kirrg001/repos","events_url":"https://api.github.com/users/kirrg001/events{/privacy}","received_events_url":"https://api.github.com/users/kirrg001/received_events","type":"User","site_admin":false},{"login":"allouis","id":3218915,"node_id":"MDQ6VXNlcjMyMTg5MTU=","avatar_url":"https://avatars3.githubusercontent.com/u/3218915?v=4","gravatar_id":"","url":"https://api.github.com/users/allouis","html_url":"https://github.com/allouis","followers_url":"https://api.github.com/users/allouis/followers","following_url":"https://api.github.com/users/allouis/following{/other_user}","gists_url":"https://api.github.com/users/allouis/gists{/gist_id}","starred_url":"https://api.github.com/users/allouis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allouis/subscriptions","organizations_url":"https://api.github.com/users/allouis/orgs","repos_url":"https://api.github.com/users/allouis/repos","events_url":"https://api.github.com/users/allouis/events{/privacy}","received_events_url":"https://api.github.com/users/allouis/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/TryGhost/Ghost/pulls/9915/commits","review_comments_url":"https://api.github.com/repos/TryGhost/Ghost/pulls/9915/comments","review_comment_url":"https://api.github.com/repos/TryGhost/Ghost/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TryGhost/Ghost/issues/9915/comments","statuses_url":"https://api.github.com/repos/TryGhost/Ghost/statuses/2cd5738dea1e729962a209bac9062eaf71d247a0","head":{"label":"kevinansfield:api-key/authentication","ref":"api-key/authentication","sha":"2cd5738dea1e729962a209bac9062eaf71d247a0","user":{"login":"kevinansfield","id":415,"node_id":"MDQ6VXNlcjQxNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/415?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinansfield","html_url":"https://github.com/kevinansfield","followers_url":"https://api.github.com/users/kevinansfield/followers","following_url":"https://api.github.com/users/kevinansfield/following{/other_user}","gists_url":"https://api.github.com/users/kevinansfield/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinansfield/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinansfield/subscriptions","organizations_url":"https://api.github.com/users/kevinansfield/orgs","repos_url":"https://api.github.com/users/kevinansfield/repos","events_url":"https://api.github.com/users/kevinansfield/events{/privacy}","received_events_url":"https://api.github.com/users/kevinansfield/received_events","type":"User","site_admin":false},"repo":{"id":21034607,"node_id":"MDEwOlJlcG9zaXRvcnkyMTAzNDYwNw==","name":"Ghost","full_name":"kevinansfield/Ghost","private":false,"owner":{"login":"kevinansfield","id":415,"node_id":"MDQ6VXNlcjQxNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/415?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinansfield","html_url":"https://github.com/kevinansfield","followers_url":"https://api.github.com/users/kevinansfield/followers","following_url":"https://api.github.com/users/kevinansfield/following{/other_user}","gists_url":"https://api.github.com/users/kevinansfield/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinansfield/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinansfield/subscriptions","organizations_url":"https://api.github.com/users/kevinansfield/orgs","repos_url":"https://api.github.com/users/kevinansfield/repos","events_url":"https://api.github.com/users/kevinansfield/events{/privacy}","received_events_url":"https://api.github.com/users/kevinansfield/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kevinansfield/Ghost","description":"Just a blogging platform","fork":true,"url":"https://api.github.com/repos/kevinansfield/Ghost","forks_url":"https://api.github.com/repos/kevinansfield/Ghost/forks","keys_url":"https://api.github.com/repos/kevinansfield/Ghost/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kevinansfield/Ghost/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kevinansfield/Ghost/teams","hooks_url":"https://api.github.com/repos/kevinansfield/Ghost/hooks","issue_events_url":"https://api.github.com/repos/kevinansfield/Ghost/issues/events{/number}","events_url":"https://api.github.com/repos/kevinansfield/Ghost/events","assignees_url":"https://api.github.com/repos/kevinansfield/Ghost/assignees{/user}","branches_url":"https://api.github.com/repos/kevinansfield/Ghost/branches{/branch}","tags_url":"https://api.github.com/repos/kevinansfield/Ghost/tags","blobs_url":"https://api.github.com/repos/kevinansfield/Ghost/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kevinansfield/Ghost/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kevinansfield/Ghost/git/refs{/sha}","trees_url":"https://api.github.com/repos/kevinansfield/Ghost/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kevinansfield/Ghost/statuses/{sha}","languages_url":"https://api.github.com/repos/kevinansfield/Ghost/languages","stargazers_url":"https://api.github.com/repos/kevinansfield/Ghost/stargazers","contributors_url":"https://api.github.com/repos/kevinansfield/Ghost/contributors","subscribers_url":"https://api.github.com/repos/kevinansfield/Ghost/subscribers","subscription_url":"https://api.github.com/repos/kevinansfield/Ghost/subscription","commits_url":"https://api.github.com/repos/kevinansfield/Ghost/commits{/sha}","git_commits_url":"https://api.github.com/repos/kevinansfield/Ghost/git/commits{/sha}","comments_url":"https://api.github.com/repos/kevinansfield/Ghost/comments{/number}","issue_comment_url":"https://api.github.com/repos/kevinansfield/Ghost/issues/comments{/number}","contents_url":"https://api.github.com/repos/kevinansfield/Ghost/contents/{+path}","compare_url":"https://api.github.com/repos/kevinansfield/Ghost/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kevinansfield/Ghost/merges","archive_url":"https://api.github.com/repos/kevinansfield/Ghost/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kevinansfield/Ghost/downloads","issues_url":"https://api.github.com/repos/kevinansfield/Ghost/issues{/number}","pulls_url":"https://api.github.com/repos/kevinansfield/Ghost/pulls{/number}","milestones_url":"https://api.github.com/repos/kevinansfield/Ghost/milestones{/number}","notifications_url":"https://api.github.com/repos/kevinansfield/Ghost/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kevinansfield/Ghost/labels{/name}","releases_url":"https://api.github.com/repos/kevinansfield/Ghost/releases{/id}","deployments_url":"https://api.github.com/repos/kevinansfield/Ghost/deployments","created_at":"2014-06-20T10:47:17Z","updated_at":"2018-09-24T08:40:05Z","pushed_at":"2018-10-03T12:39:29Z","git_url":"git://github.com/kevinansfield/Ghost.git","ssh_url":"git@github.com:kevinansfield/Ghost.git","clone_url":"https://github.com/kevinansfield/Ghost.git","svn_url":"https://github.com/kevinansfield/Ghost","homepage":"https://ghost.org","size":28007,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"TryGhost:master","ref":"master","sha":"15da580016c16c04319c678dd987b3c78b25209a","user":{"login":"TryGhost","id":2178663,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNzg2NjM=","avatar_url":"https://avatars3.githubusercontent.com/u/2178663?v=4","gravatar_id":"","url":"https://api.github.com/users/TryGhost","html_url":"https://github.com/TryGhost","followers_url":"https://api.github.com/users/TryGhost/followers","following_url":"https://api.github.com/users/TryGhost/following{/other_user}","gists_url":"https://api.github.com/users/TryGhost/gists{/gist_id}","starred_url":"https://api.github.com/users/TryGhost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TryGhost/subscriptions","organizations_url":"https://api.github.com/users/TryGhost/orgs","repos_url":"https://api.github.com/users/TryGhost/repos","events_url":"https://api.github.com/users/TryGhost/events{/privacy}","received_events_url":"https://api.github.com/users/TryGhost/received_events","type":"Organization","site_admin":false},"repo":{"id":9852918,"node_id":"MDEwOlJlcG9zaXRvcnk5ODUyOTE4","name":"Ghost","full_name":"TryGhost/Ghost","private":false,"owner":{"login":"TryGhost","id":2178663,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNzg2NjM=","avatar_url":"https://avatars3.githubusercontent.com/u/2178663?v=4","gravatar_id":"","url":"https://api.github.com/users/TryGhost","html_url":"https://github.com/TryGhost","followers_url":"https://api.github.com/users/TryGhost/followers","following_url":"https://api.github.com/users/TryGhost/following{/other_user}","gists_url":"https://api.github.com/users/TryGhost/gists{/gist_id}","starred_url":"https://api.github.com/users/TryGhost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TryGhost/subscriptions","organizations_url":"https://api.github.com/users/TryGhost/orgs","repos_url":"https://api.github.com/users/TryGhost/repos","events_url":"https://api.github.com/users/TryGhost/events{/privacy}","received_events_url":"https://api.github.com/users/TryGhost/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/TryGhost/Ghost","description":"The platform for professional publishers","fork":false,"url":"https://api.github.com/repos/TryGhost/Ghost","forks_url":"https://api.github.com/repos/TryGhost/Ghost/forks","keys_url":"https://api.github.com/repos/TryGhost/Ghost/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TryGhost/Ghost/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TryGhost/Ghost/teams","hooks_url":"https://api.github.com/repos/TryGhost/Ghost/hooks","issue_events_url":"https://api.github.com/repos/TryGhost/Ghost/issues/events{/number}","events_url":"https://api.github.com/repos/TryGhost/Ghost/events","assignees_url":"https://api.github.com/repos/TryGhost/Ghost/assignees{/user}","branches_url":"https://api.github.com/repos/TryGhost/Ghost/branches{/branch}","tags_url":"https://api.github.com/repos/TryGhost/Ghost/tags","blobs_url":"https://api.github.com/repos/TryGhost/Ghost/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TryGhost/Ghost/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TryGhost/Ghost/git/refs{/sha}","trees_url":"https://api.github.com/repos/TryGhost/Ghost/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TryGhost/Ghost/statuses/{sha}","languages_url":"https://api.github.com/repos/TryGhost/Ghost/languages","stargazers_url":"https://api.github.com/repos/TryGhost/Ghost/stargazers","contributors_url":"https://api.github.com/repos/TryGhost/Ghost/contributors","subscribers_url":"https://api.github.com/repos/TryGhost/Ghost/subscribers","subscription_url":"https://api.github.com/repos/TryGhost/Ghost/subscription","commits_url":"https://api.github.com/repos/TryGhost/Ghost/commits{/sha}","git_commits_url":"https://api.github.com/repos/TryGhost/Ghost/git/commits{/sha}","comments_url":"https://api.github.com/repos/TryGhost/Ghost/comments{/number}","issue_comment_url":"https://api.github.com/repos/TryGhost/Ghost/issues/comments{/number}","contents_url":"https://api.github.com/repos/TryGhost/Ghost/contents/{+path}","compare_url":"https://api.github.com/repos/TryGhost/Ghost/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TryGhost/Ghost/merges","archive_url":"https://api.github.com/repos/TryGhost/Ghost/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TryGhost/Ghost/downloads","issues_url":"https://api.github.com/repos/TryGhost/Ghost/issues{/number}","pulls_url":"https://api.github.com/repos/TryGhost/Ghost/pulls{/number}","milestones_url":"https://api.github.com/repos/TryGhost/Ghost/milestones{/number}","notifications_url":"https://api.github.com/repos/TryGhost/Ghost/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TryGhost/Ghost/labels{/name}","releases_url":"https://api.github.com/repos/TryGhost/Ghost/releases{/id}","deployments_url":"https://api.github.com/repos/TryGhost/Ghost/deployments","created_at":"2013-05-04T11:09:13Z","updated_at":"2018-10-03T23:31:38Z","pushed_at":"2018-10-03T14:51:00Z","git_url":"git://github.com/TryGhost/Ghost.git","ssh_url":"git@github.com:TryGhost/Ghost.git","clone_url":"https://github.com/TryGhost/Ghost.git","svn_url":"https://github.com/TryGhost/Ghost","homepage":"https://ghost.org","size":33409,"stargazers_count":27509,"watchers_count":27509,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5919,"mirror_url":null,"archived":false,"open_issues_count":143,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":5919,"open_issues":143,"watchers":27509,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/9915"},"html":{"href":"https://github.com/TryGhost/Ghost/pull/9915"},"issue":{"href":"https://api.github.com/repos/TryGhost/Ghost/issues/9915"},"comments":{"href":"https://api.github.com/repos/TryGhost/Ghost/issues/9915/comments"},"review_comments":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/9915/comments"},"review_comment":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/9915/commits"},"statuses":{"href":"https://api.github.com/repos/TryGhost/Ghost/statuses/2cd5738dea1e729962a209bac9062eaf71d247a0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"allouis"}}