{"action":"created","comment":{"url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/comments/82491759","pull_request_review_id":3399079,"id":82491759,"diff_hunk":"@@ -2,35 +2,40 @@\n \n const Boom = require('boom');\n const Hoek = require('hoek');\n+const Joi = require('joi');\n \n // Declare Internals\n \n const internals = {};\n \n-exports.register = (server, options, next) => {\n-\n-    server.auth.scheme('bearer-access-token', internals.implementation);\n-    next();\n+internals.defaults = {\n+    accessTokenName: 'access_token',\n+    allowQueryToken: true,\n+    allowCookieToken: false,\n+    allowMultipleHeaders: false,\n+    allowChaining: false,\n+    tokenType: 'Bearer'\n };\n \n-exports.register.attributes = {\n-    pkg: require('../package.json')\n-};\n+internals.schema = Joi.object().keys({\n+    validateFunc: Joi.func().required(),\n+    accessTokenName: Joi.string().required(),\n+    allowQueryToken: Joi.boolean(),\n+    allowCookieToken: Joi.boolean(),\n+    allowMultipleHeaders: Joi.boolean(),\n+    allowChaining: Joi.boolean(),\n+    tokenType: Joi.string().required()\n+});\n \n internals.implementation = (server, options) => {\n \n     Hoek.assert(options, 'Missing bearer auth strategy options');","path":"lib/index.js","position":38,"original_position":38,"commit_id":"d0598b518b855f075cd480269bc27eb07a592b19","original_commit_id":"d0598b518b855f075cd480269bc27eb07a592b19","user":{"login":"jonathansamines","id":1268268,"avatar_url":"https://avatars.githubusercontent.com/u/1268268?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathansamines","html_url":"https://github.com/jonathansamines","followers_url":"https://api.github.com/users/jonathansamines/followers","following_url":"https://api.github.com/users/jonathansamines/following{/other_user}","gists_url":"https://api.github.com/users/jonathansamines/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathansamines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathansamines/subscriptions","organizations_url":"https://api.github.com/users/jonathansamines/orgs","repos_url":"https://api.github.com/users/jonathansamines/repos","events_url":"https://api.github.com/users/jonathansamines/events{/privacy}","received_events_url":"https://api.github.com/users/jonathansamines/received_events","type":"User","site_admin":false},"body":"The real reason to leave this assert, is because now that I am using `Hoek.applyToDefaults` if no options are passed, it will [return null](https://github.com/hapijs/hoek/blob/master/lib/index.js#L156) instead of the default values. So this is just a security guard against that. \r\n\r\nThe above problem could be easily solved by doing:\r\n\r\n```js\r\n   const settings = Hoek.applyToDefaults(internals.defaults, options || {});\r\n```\r\nHowever, since I am adding a new code branch, I am not sure how to add a test-case for that branch in the current test file. In that way we could just leverage on the joi's output.","created_at":"2016-10-08T01:14:36Z","updated_at":"2016-10-08T01:14:36Z","html_url":"https://github.com/johnbrett/hapi-auth-bearer-token/pull/101#discussion_r82491759","pull_request_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/101","_links":{"self":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/comments/82491759"},"html":{"href":"https://github.com/johnbrett/hapi-auth-bearer-token/pull/101#discussion_r82491759"},"pull_request":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/101"}}},"pull_request":{"url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/101","id":88194461,"html_url":"https://github.com/johnbrett/hapi-auth-bearer-token/pull/101","diff_url":"https://github.com/johnbrett/hapi-auth-bearer-token/pull/101.diff","patch_url":"https://github.com/johnbrett/hapi-auth-bearer-token/pull/101.patch","issue_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/issues/101","number":101,"state":"open","locked":false,"title":"Add support to specify the options schema by using joi","user":{"login":"jonathansamines","id":1268268,"avatar_url":"https://avatars.githubusercontent.com/u/1268268?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathansamines","html_url":"https://github.com/jonathansamines","followers_url":"https://api.github.com/users/jonathansamines/followers","following_url":"https://api.github.com/users/jonathansamines/following{/other_user}","gists_url":"https://api.github.com/users/jonathansamines/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathansamines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathansamines/subscriptions","organizations_url":"https://api.github.com/users/jonathansamines/orgs","repos_url":"https://api.github.com/users/jonathansamines/repos","events_url":"https://api.github.com/users/jonathansamines/events{/privacy}","received_events_url":"https://api.github.com/users/jonathansamines/received_events","type":"User","site_admin":false},"body":"I just added options validations through **joi schemas**. Not sure however if having fixed versions as dependencies is an intended behaviour.\r\n\r\nLet me know what you think about this change.\r\n\r\nSolves #99 ","created_at":"2016-10-06T03:43:09Z","updated_at":"2016-10-08T01:14:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"61329c699b17b4b05b0e1597232fd353af381e27","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/101/commits","review_comments_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/101/comments","review_comment_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/comments{/number}","comments_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/issues/101/comments","statuses_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/statuses/d0598b518b855f075cd480269bc27eb07a592b19","head":{"label":"jonathansamines:feature/add-joi-options","ref":"feature/add-joi-options","sha":"d0598b518b855f075cd480269bc27eb07a592b19","user":{"login":"jonathansamines","id":1268268,"avatar_url":"https://avatars.githubusercontent.com/u/1268268?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathansamines","html_url":"https://github.com/jonathansamines","followers_url":"https://api.github.com/users/jonathansamines/followers","following_url":"https://api.github.com/users/jonathansamines/following{/other_user}","gists_url":"https://api.github.com/users/jonathansamines/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathansamines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathansamines/subscriptions","organizations_url":"https://api.github.com/users/jonathansamines/orgs","repos_url":"https://api.github.com/users/jonathansamines/repos","events_url":"https://api.github.com/users/jonathansamines/events{/privacy}","received_events_url":"https://api.github.com/users/jonathansamines/received_events","type":"User","site_admin":false},"repo":{"id":70118133,"name":"hapi-auth-bearer-token","full_name":"jonathansamines/hapi-auth-bearer-token","owner":{"login":"jonathansamines","id":1268268,"avatar_url":"https://avatars.githubusercontent.com/u/1268268?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathansamines","html_url":"https://github.com/jonathansamines","followers_url":"https://api.github.com/users/jonathansamines/followers","following_url":"https://api.github.com/users/jonathansamines/following{/other_user}","gists_url":"https://api.github.com/users/jonathansamines/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathansamines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathansamines/subscriptions","organizations_url":"https://api.github.com/users/jonathansamines/orgs","repos_url":"https://api.github.com/users/jonathansamines/repos","events_url":"https://api.github.com/users/jonathansamines/events{/privacy}","received_events_url":"https://api.github.com/users/jonathansamines/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jonathansamines/hapi-auth-bearer-token","description":"Simple Bearer authentication scheme plugin for hapi, accepts token by Header, Cookie or Query parameter.","fork":true,"url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token","forks_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/forks","keys_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/teams","hooks_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/hooks","issue_events_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/issues/events{/number}","events_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/events","assignees_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/assignees{/user}","branches_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/branches{/branch}","tags_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/tags","blobs_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/statuses/{sha}","languages_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/languages","stargazers_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/stargazers","contributors_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/contributors","subscribers_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/subscribers","subscription_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/subscription","commits_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/contents/{+path}","compare_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/merges","archive_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/downloads","issues_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/issues{/number}","pulls_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/pulls{/number}","milestones_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/milestones{/number}","notifications_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/labels{/name}","releases_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/releases{/id}","deployments_url":"https://api.github.com/repos/jonathansamines/hapi-auth-bearer-token/deployments","created_at":"2016-10-06T03:00:56Z","updated_at":"2016-10-06T03:00:57Z","pushed_at":"2016-10-06T03:40:14Z","git_url":"git://github.com/jonathansamines/hapi-auth-bearer-token.git","ssh_url":"git@github.com:jonathansamines/hapi-auth-bearer-token.git","clone_url":"https://github.com/jonathansamines/hapi-auth-bearer-token.git","svn_url":"https://github.com/jonathansamines/hapi-auth-bearer-token","homepage":"","size":89,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"johnbrett:master","ref":"master","sha":"1e1d3091a8160898beab4d91dba4114e563a623b","user":{"login":"johnbrett","id":4015939,"avatar_url":"https://avatars.githubusercontent.com/u/4015939?v=3","gravatar_id":"","url":"https://api.github.com/users/johnbrett","html_url":"https://github.com/johnbrett","followers_url":"https://api.github.com/users/johnbrett/followers","following_url":"https://api.github.com/users/johnbrett/following{/other_user}","gists_url":"https://api.github.com/users/johnbrett/gists{/gist_id}","starred_url":"https://api.github.com/users/johnbrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnbrett/subscriptions","organizations_url":"https://api.github.com/users/johnbrett/orgs","repos_url":"https://api.github.com/users/johnbrett/repos","events_url":"https://api.github.com/users/johnbrett/events{/privacy}","received_events_url":"https://api.github.com/users/johnbrett/received_events","type":"User","site_admin":false},"repo":{"id":21957627,"name":"hapi-auth-bearer-token","full_name":"johnbrett/hapi-auth-bearer-token","owner":{"login":"johnbrett","id":4015939,"avatar_url":"https://avatars.githubusercontent.com/u/4015939?v=3","gravatar_id":"","url":"https://api.github.com/users/johnbrett","html_url":"https://github.com/johnbrett","followers_url":"https://api.github.com/users/johnbrett/followers","following_url":"https://api.github.com/users/johnbrett/following{/other_user}","gists_url":"https://api.github.com/users/johnbrett/gists{/gist_id}","starred_url":"https://api.github.com/users/johnbrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnbrett/subscriptions","organizations_url":"https://api.github.com/users/johnbrett/orgs","repos_url":"https://api.github.com/users/johnbrett/repos","events_url":"https://api.github.com/users/johnbrett/events{/privacy}","received_events_url":"https://api.github.com/users/johnbrett/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johnbrett/hapi-auth-bearer-token","description":"Simple Bearer authentication scheme plugin for hapi, accepts token by Header, Cookie or Query parameter.","fork":false,"url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token","forks_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/forks","keys_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/teams","hooks_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/hooks","issue_events_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/issues/events{/number}","events_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/events","assignees_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/assignees{/user}","branches_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/branches{/branch}","tags_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/tags","blobs_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/git/refs{/sha}","trees_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/statuses/{sha}","languages_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/languages","stargazers_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/stargazers","contributors_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/contributors","subscribers_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/subscribers","subscription_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/subscription","commits_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/commits{/sha}","git_commits_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/git/commits{/sha}","comments_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/comments{/number}","issue_comment_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/issues/comments{/number}","contents_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/contents/{+path}","compare_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/merges","archive_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/downloads","issues_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/issues{/number}","pulls_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls{/number}","milestones_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/milestones{/number}","notifications_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/labels{/name}","releases_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/releases{/id}","deployments_url":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/deployments","created_at":"2014-07-17T21:06:31Z","updated_at":"2016-10-07T12:41:11Z","pushed_at":"2016-10-06T03:43:10Z","git_url":"git://github.com/johnbrett/hapi-auth-bearer-token.git","ssh_url":"git@github.com:johnbrett/hapi-auth-bearer-token.git","clone_url":"https://github.com/johnbrett/hapi-auth-bearer-token.git","svn_url":"https://github.com/johnbrett/hapi-auth-bearer-token","homepage":"","size":119,"stargazers_count":134,"watchers_count":134,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":3,"forks":27,"open_issues":3,"watchers":134,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/101"},"html":{"href":"https://github.com/johnbrett/hapi-auth-bearer-token/pull/101"},"issue":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/issues/101"},"comments":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/issues/101/comments"},"review_comments":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/101/comments"},"review_comment":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/pulls/101/commits"},"statuses":{"href":"https://api.github.com/repos/johnbrett/hapi-auth-bearer-token/statuses/d0598b518b855f075cd480269bc27eb07a592b19"}}}}
{"actor":{"display_login":"jonathansamines"}}