{"action":"created","comment":{"url":"https://api.github.com/repos/iZettle/tentales/pulls/comments/172221582","pull_request_review_id":101201308,"id":172221582,"diff_hunk":"@@ -1,24 +1,49 @@\n-import { Hook } from \"tentales\"\n+import { Hook, Config } from \"tentales\"\n+import { Log } from \"tentales-log\"\n+import { path } from \"ramda\"\n import { bodyParserMiddleware } from \"./middlewares/body-parser-middleware\"\n import { renderMiddleware } from \"./middlewares/render-middleware\"\n import { fourOhFourMiddleware } from \"./middlewares/four-oh-four-middleware\"\n import { errorMiddleware } from \"./middlewares/error-middleware\"\n import { protectServiceRoutesMiddleware } from \"./middlewares/protect-service-routes-middelware\"\n \n-const DEFAULT_HOOKS_PUBLIC: Hook[] = [\n-  [\"errorMiddleware\", [errorMiddleware]],\n-  [\"bodyParserMiddleware\", [bodyParserMiddleware]],\n-  [\"renderMiddleware\", [renderMiddleware]],\n-  [\"protectServiceRoutesMiddleware\", [protectServiceRoutesMiddleware]],\n-  [\"fourOhFourMiddleware\", [fourOhFourMiddleware]],\n-]\n+const DEFAULT_HOOKS_PUBLIC = (log: Log, config: Config): Hook[] => {\n+  const middlewares: Hook[] = [\n+    [\"errorMiddleware\", [errorMiddleware]],\n+    [\"bodyParserMiddleware\", [bodyParserMiddleware]],\n+    [\"renderMiddleware\", [renderMiddleware]],\n+  ]\n+\n+  if (path([\"auth\", \"serverSecret\"], config)) {\n+    middlewares.push([\n+      \"protectServiceRoutesMiddleware\",\n+      [protectServiceRoutesMiddleware],\n+    ])\n+  } else {\n+    log.warn(\n+      \"Authorization secret not set; no authorization will be carried out.\",","path":"packages/tentales/src/middleware/default-hooks.ts","position":32,"original_position":32,"commit_id":"6a5593922529f6a45f428de70523203f6b3e78ee","original_commit_id":"6a5593922529f6a45f428de70523203f6b3e78ee","user":{"login":"emiloberg","id":4673048,"avatar_url":"https://avatars3.githubusercontent.com/u/4673048?v=4","gravatar_id":"","url":"https://api.github.com/users/emiloberg","html_url":"https://github.com/emiloberg","followers_url":"https://api.github.com/users/emiloberg/followers","following_url":"https://api.github.com/users/emiloberg/following{/other_user}","gists_url":"https://api.github.com/users/emiloberg/gists{/gist_id}","starred_url":"https://api.github.com/users/emiloberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emiloberg/subscriptions","organizations_url":"https://api.github.com/users/emiloberg/orgs","repos_url":"https://api.github.com/users/emiloberg/repos","events_url":"https://api.github.com/users/emiloberg/events{/privacy}","received_events_url":"https://api.github.com/users/emiloberg/received_events","type":"User","site_admin":false},"body":"Maybe be explicit and say \"... no server-to-server auth...\"\r\n\r\nFootnote: I've explicitly said \"Auth\" and not `authorization` and `authentication` in the code. In this case, I guess what we're doing is _authentication_ - checking that the caller really is who s/he says s/he is.\r\n\r\nNice usage, of semicolon! ","created_at":"2018-03-05T15:22:24Z","updated_at":"2018-03-05T15:50:26Z","html_url":"https://github.com/iZettle/tentales/pull/9#discussion_r172221582","pull_request_url":"https://api.github.com/repos/iZettle/tentales/pulls/9","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/iZettle/tentales/pulls/comments/172221582"},"html":{"href":"https://github.com/iZettle/tentales/pull/9#discussion_r172221582"},"pull_request":{"href":"https://api.github.com/repos/iZettle/tentales/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/iZettle/tentales/pulls/9","id":172894553,"html_url":"https://github.com/iZettle/tentales/pull/9","diff_url":"https://github.com/iZettle/tentales/pull/9.diff","patch_url":"https://github.com/iZettle/tentales/pull/9.patch","issue_url":"https://api.github.com/repos/iZettle/tentales/issues/9","number":9,"state":"open","locked":false,"title":"Make authorization optional","user":{"login":"dnjstrom","id":1033276,"avatar_url":"https://avatars0.githubusercontent.com/u/1033276?v=4","gravatar_id":"","url":"https://api.github.com/users/dnjstrom","html_url":"https://github.com/dnjstrom","followers_url":"https://api.github.com/users/dnjstrom/followers","following_url":"https://api.github.com/users/dnjstrom/following{/other_user}","gists_url":"https://api.github.com/users/dnjstrom/gists{/gist_id}","starred_url":"https://api.github.com/users/dnjstrom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnjstrom/subscriptions","organizations_url":"https://api.github.com/users/dnjstrom/orgs","repos_url":"https://api.github.com/users/dnjstrom/repos","events_url":"https://api.github.com/users/dnjstrom/events{/privacy}","received_events_url":"https://api.github.com/users/dnjstrom/received_events","type":"User","site_admin":false},"body":"Authorization will now only be carried out if an auth secret is specified. If not, a warning will be printed during startup.","created_at":"2018-03-05T15:12:38Z","updated_at":"2018-03-05T15:50:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd939fc823d0bfb3c6d737f14ad89e1a6902e898","assignee":{"login":"dnjstrom","id":1033276,"avatar_url":"https://avatars0.githubusercontent.com/u/1033276?v=4","gravatar_id":"","url":"https://api.github.com/users/dnjstrom","html_url":"https://github.com/dnjstrom","followers_url":"https://api.github.com/users/dnjstrom/followers","following_url":"https://api.github.com/users/dnjstrom/following{/other_user}","gists_url":"https://api.github.com/users/dnjstrom/gists{/gist_id}","starred_url":"https://api.github.com/users/dnjstrom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnjstrom/subscriptions","organizations_url":"https://api.github.com/users/dnjstrom/orgs","repos_url":"https://api.github.com/users/dnjstrom/repos","events_url":"https://api.github.com/users/dnjstrom/events{/privacy}","received_events_url":"https://api.github.com/users/dnjstrom/received_events","type":"User","site_admin":false},"assignees":[{"login":"dnjstrom","id":1033276,"avatar_url":"https://avatars0.githubusercontent.com/u/1033276?v=4","gravatar_id":"","url":"https://api.github.com/users/dnjstrom","html_url":"https://github.com/dnjstrom","followers_url":"https://api.github.com/users/dnjstrom/followers","following_url":"https://api.github.com/users/dnjstrom/following{/other_user}","gists_url":"https://api.github.com/users/dnjstrom/gists{/gist_id}","starred_url":"https://api.github.com/users/dnjstrom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnjstrom/subscriptions","organizations_url":"https://api.github.com/users/dnjstrom/orgs","repos_url":"https://api.github.com/users/dnjstrom/repos","events_url":"https://api.github.com/users/dnjstrom/events{/privacy}","received_events_url":"https://api.github.com/users/dnjstrom/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/iZettle/tentales/pulls/9/commits","review_comments_url":"https://api.github.com/repos/iZettle/tentales/pulls/9/comments","review_comment_url":"https://api.github.com/repos/iZettle/tentales/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iZettle/tentales/issues/9/comments","statuses_url":"https://api.github.com/repos/iZettle/tentales/statuses/6a5593922529f6a45f428de70523203f6b3e78ee","head":{"label":"iZettle:bypass-authorization","ref":"bypass-authorization","sha":"6a5593922529f6a45f428de70523203f6b3e78ee","user":{"login":"iZettle","id":1272526,"avatar_url":"https://avatars2.githubusercontent.com/u/1272526?v=4","gravatar_id":"","url":"https://api.github.com/users/iZettle","html_url":"https://github.com/iZettle","followers_url":"https://api.github.com/users/iZettle/followers","following_url":"https://api.github.com/users/iZettle/following{/other_user}","gists_url":"https://api.github.com/users/iZettle/gists{/gist_id}","starred_url":"https://api.github.com/users/iZettle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iZettle/subscriptions","organizations_url":"https://api.github.com/users/iZettle/orgs","repos_url":"https://api.github.com/users/iZettle/repos","events_url":"https://api.github.com/users/iZettle/events{/privacy}","received_events_url":"https://api.github.com/users/iZettle/received_events","type":"Organization","site_admin":false},"repo":{"id":119398536,"name":"tentales","full_name":"iZettle/tentales","owner":{"login":"iZettle","id":1272526,"avatar_url":"https://avatars2.githubusercontent.com/u/1272526?v=4","gravatar_id":"","url":"https://api.github.com/users/iZettle","html_url":"https://github.com/iZettle","followers_url":"https://api.github.com/users/iZettle/followers","following_url":"https://api.github.com/users/iZettle/following{/other_user}","gists_url":"https://api.github.com/users/iZettle/gists{/gist_id}","starred_url":"https://api.github.com/users/iZettle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iZettle/subscriptions","organizations_url":"https://api.github.com/users/iZettle/orgs","repos_url":"https://api.github.com/users/iZettle/repos","events_url":"https://api.github.com/users/iZettle/events{/privacy}","received_events_url":"https://api.github.com/users/iZettle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iZettle/tentales","description":"An open source web site CMS written in JavaScript","fork":false,"url":"https://api.github.com/repos/iZettle/tentales","forks_url":"https://api.github.com/repos/iZettle/tentales/forks","keys_url":"https://api.github.com/repos/iZettle/tentales/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iZettle/tentales/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iZettle/tentales/teams","hooks_url":"https://api.github.com/repos/iZettle/tentales/hooks","issue_events_url":"https://api.github.com/repos/iZettle/tentales/issues/events{/number}","events_url":"https://api.github.com/repos/iZettle/tentales/events","assignees_url":"https://api.github.com/repos/iZettle/tentales/assignees{/user}","branches_url":"https://api.github.com/repos/iZettle/tentales/branches{/branch}","tags_url":"https://api.github.com/repos/iZettle/tentales/tags","blobs_url":"https://api.github.com/repos/iZettle/tentales/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iZettle/tentales/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iZettle/tentales/git/refs{/sha}","trees_url":"https://api.github.com/repos/iZettle/tentales/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iZettle/tentales/statuses/{sha}","languages_url":"https://api.github.com/repos/iZettle/tentales/languages","stargazers_url":"https://api.github.com/repos/iZettle/tentales/stargazers","contributors_url":"https://api.github.com/repos/iZettle/tentales/contributors","subscribers_url":"https://api.github.com/repos/iZettle/tentales/subscribers","subscription_url":"https://api.github.com/repos/iZettle/tentales/subscription","commits_url":"https://api.github.com/repos/iZettle/tentales/commits{/sha}","git_commits_url":"https://api.github.com/repos/iZettle/tentales/git/commits{/sha}","comments_url":"https://api.github.com/repos/iZettle/tentales/comments{/number}","issue_comment_url":"https://api.github.com/repos/iZettle/tentales/issues/comments{/number}","contents_url":"https://api.github.com/repos/iZettle/tentales/contents/{+path}","compare_url":"https://api.github.com/repos/iZettle/tentales/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iZettle/tentales/merges","archive_url":"https://api.github.com/repos/iZettle/tentales/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iZettle/tentales/downloads","issues_url":"https://api.github.com/repos/iZettle/tentales/issues{/number}","pulls_url":"https://api.github.com/repos/iZettle/tentales/pulls{/number}","milestones_url":"https://api.github.com/repos/iZettle/tentales/milestones{/number}","notifications_url":"https://api.github.com/repos/iZettle/tentales/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iZettle/tentales/labels{/name}","releases_url":"https://api.github.com/repos/iZettle/tentales/releases{/id}","deployments_url":"https://api.github.com/repos/iZettle/tentales/deployments","created_at":"2018-01-29T15:09:13Z","updated_at":"2018-02-28T10:25:57Z","pushed_at":"2018-03-05T15:12:59Z","git_url":"git://github.com/iZettle/tentales.git","ssh_url":"git@github.com:iZettle/tentales.git","clone_url":"https://github.com/iZettle/tentales.git","svn_url":"https://github.com/iZettle/tentales","homepage":null,"size":110,"stargazers_count":1,"watchers_count":1,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"iZettle:master","ref":"master","sha":"d355aa094ec8513143c0f2cdf19fd13f723c3cf5","user":{"login":"iZettle","id":1272526,"avatar_url":"https://avatars2.githubusercontent.com/u/1272526?v=4","gravatar_id":"","url":"https://api.github.com/users/iZettle","html_url":"https://github.com/iZettle","followers_url":"https://api.github.com/users/iZettle/followers","following_url":"https://api.github.com/users/iZettle/following{/other_user}","gists_url":"https://api.github.com/users/iZettle/gists{/gist_id}","starred_url":"https://api.github.com/users/iZettle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iZettle/subscriptions","organizations_url":"https://api.github.com/users/iZettle/orgs","repos_url":"https://api.github.com/users/iZettle/repos","events_url":"https://api.github.com/users/iZettle/events{/privacy}","received_events_url":"https://api.github.com/users/iZettle/received_events","type":"Organization","site_admin":false},"repo":{"id":119398536,"name":"tentales","full_name":"iZettle/tentales","owner":{"login":"iZettle","id":1272526,"avatar_url":"https://avatars2.githubusercontent.com/u/1272526?v=4","gravatar_id":"","url":"https://api.github.com/users/iZettle","html_url":"https://github.com/iZettle","followers_url":"https://api.github.com/users/iZettle/followers","following_url":"https://api.github.com/users/iZettle/following{/other_user}","gists_url":"https://api.github.com/users/iZettle/gists{/gist_id}","starred_url":"https://api.github.com/users/iZettle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iZettle/subscriptions","organizations_url":"https://api.github.com/users/iZettle/orgs","repos_url":"https://api.github.com/users/iZettle/repos","events_url":"https://api.github.com/users/iZettle/events{/privacy}","received_events_url":"https://api.github.com/users/iZettle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iZettle/tentales","description":"An open source web site CMS written in JavaScript","fork":false,"url":"https://api.github.com/repos/iZettle/tentales","forks_url":"https://api.github.com/repos/iZettle/tentales/forks","keys_url":"https://api.github.com/repos/iZettle/tentales/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iZettle/tentales/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iZettle/tentales/teams","hooks_url":"https://api.github.com/repos/iZettle/tentales/hooks","issue_events_url":"https://api.github.com/repos/iZettle/tentales/issues/events{/number}","events_url":"https://api.github.com/repos/iZettle/tentales/events","assignees_url":"https://api.github.com/repos/iZettle/tentales/assignees{/user}","branches_url":"https://api.github.com/repos/iZettle/tentales/branches{/branch}","tags_url":"https://api.github.com/repos/iZettle/tentales/tags","blobs_url":"https://api.github.com/repos/iZettle/tentales/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iZettle/tentales/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iZettle/tentales/git/refs{/sha}","trees_url":"https://api.github.com/repos/iZettle/tentales/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iZettle/tentales/statuses/{sha}","languages_url":"https://api.github.com/repos/iZettle/tentales/languages","stargazers_url":"https://api.github.com/repos/iZettle/tentales/stargazers","contributors_url":"https://api.github.com/repos/iZettle/tentales/contributors","subscribers_url":"https://api.github.com/repos/iZettle/tentales/subscribers","subscription_url":"https://api.github.com/repos/iZettle/tentales/subscription","commits_url":"https://api.github.com/repos/iZettle/tentales/commits{/sha}","git_commits_url":"https://api.github.com/repos/iZettle/tentales/git/commits{/sha}","comments_url":"https://api.github.com/repos/iZettle/tentales/comments{/number}","issue_comment_url":"https://api.github.com/repos/iZettle/tentales/issues/comments{/number}","contents_url":"https://api.github.com/repos/iZettle/tentales/contents/{+path}","compare_url":"https://api.github.com/repos/iZettle/tentales/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iZettle/tentales/merges","archive_url":"https://api.github.com/repos/iZettle/tentales/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iZettle/tentales/downloads","issues_url":"https://api.github.com/repos/iZettle/tentales/issues{/number}","pulls_url":"https://api.github.com/repos/iZettle/tentales/pulls{/number}","milestones_url":"https://api.github.com/repos/iZettle/tentales/milestones{/number}","notifications_url":"https://api.github.com/repos/iZettle/tentales/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iZettle/tentales/labels{/name}","releases_url":"https://api.github.com/repos/iZettle/tentales/releases{/id}","deployments_url":"https://api.github.com/repos/iZettle/tentales/deployments","created_at":"2018-01-29T15:09:13Z","updated_at":"2018-02-28T10:25:57Z","pushed_at":"2018-03-05T15:12:59Z","git_url":"git://github.com/iZettle/tentales.git","ssh_url":"git@github.com:iZettle/tentales.git","clone_url":"https://github.com/iZettle/tentales.git","svn_url":"https://github.com/iZettle/tentales","homepage":null,"size":110,"stargazers_count":1,"watchers_count":1,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iZettle/tentales/pulls/9"},"html":{"href":"https://github.com/iZettle/tentales/pull/9"},"issue":{"href":"https://api.github.com/repos/iZettle/tentales/issues/9"},"comments":{"href":"https://api.github.com/repos/iZettle/tentales/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/iZettle/tentales/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/iZettle/tentales/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iZettle/tentales/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/iZettle/tentales/statuses/6a5593922529f6a45f428de70523203f6b3e78ee"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"emiloberg"}}