{"action":"created","comment":{"url":"https://api.github.com/repos/Mashape/kong/pulls/comments/41206298","id":41206298,"diff_hunk":"@@ -61,6 +61,8 @@ local function send_response(status_code)\n         ngx.log(ngx.ERR, tostring(content))\n       end\n       ngx.ctx.stop_phases = true -- interrupt other phases of this request\n+    elseif status_code == _M.status_codes.HTTP_UNAUTHORIZED then\n+      ngx.header[\"WWW-Authenticate\"] = \"Key realm=\\\"\"..constants.NAME..\"\\\"\" -- respond with a challenge","path":"kong/tools/responses.lua","position":5,"original_position":5,"commit_id":"993e36a0c75baf0009bce8d9ab5cb54a4df5807a","original_commit_id":"993e36a0c75baf0009bce8d9ab5cb54a4df5807a","user":{"login":"ybv","id":4458116,"avatar_url":"https://avatars.githubusercontent.com/u/4458116?v=3","gravatar_id":"","url":"https://api.github.com/users/ybv","html_url":"https://github.com/ybv","followers_url":"https://api.github.com/users/ybv/followers","following_url":"https://api.github.com/users/ybv/following{/other_user}","gists_url":"https://api.github.com/users/ybv/gists{/gist_id}","starred_url":"https://api.github.com/users/ybv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ybv/subscriptions","organizations_url":"https://api.github.com/users/ybv/orgs","repos_url":"https://api.github.com/users/ybv/repos","events_url":"https://api.github.com/users/ybv/events{/privacy}","received_events_url":"https://api.github.com/users/ybv/received_events","type":"User","site_admin":false},"body":"@thibaultCha definitely, I'm so new to lua/kong land. Just made this PR after 30 mins of going through code, I'll update the PR soon, thanks so much for pointing in the right direction!","created_at":"2015-10-05T22:30:01Z","updated_at":"2015-10-05T22:30:01Z","html_url":"https://github.com/Mashape/kong/pull/588#discussion_r41206298","pull_request_url":"https://api.github.com/repos/Mashape/kong/pulls/588","_links":{"self":{"href":"https://api.github.com/repos/Mashape/kong/pulls/comments/41206298"},"html":{"href":"https://github.com/Mashape/kong/pull/588#discussion_r41206298"},"pull_request":{"href":"https://api.github.com/repos/Mashape/kong/pulls/588"}}},"pull_request":{"url":"https://api.github.com/repos/Mashape/kong/pulls/588","id":46720555,"html_url":"https://github.com/Mashape/kong/pull/588","diff_url":"https://github.com/Mashape/kong/pull/588.diff","patch_url":"https://github.com/Mashape/kong/pull/588.patch","issue_url":"https://api.github.com/repos/Mashape/kong/issues/588","number":588,"state":"open","locked":false,"title":"Add 'WWW-Authenticate' header for reponses w/ status code 401 Unauthorized.","user":{"login":"ybv","id":4458116,"avatar_url":"https://avatars.githubusercontent.com/u/4458116?v=3","gravatar_id":"","url":"https://api.github.com/users/ybv","html_url":"https://github.com/ybv","followers_url":"https://api.github.com/users/ybv/followers","following_url":"https://api.github.com/users/ybv/following{/other_user}","gists_url":"https://api.github.com/users/ybv/gists{/gist_id}","starred_url":"https://api.github.com/users/ybv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ybv/subscriptions","organizations_url":"https://api.github.com/users/ybv/orgs","repos_url":"https://api.github.com/users/ybv/repos","events_url":"https://api.github.com/users/ybv/events{/privacy}","received_events_url":"https://api.github.com/users/ybv/received_events","type":"User","site_admin":false},"body":"Adds a new header 'WWW-Authenticate' for 401 responses, the header value typically should include a [challenge](http://stackoverflow.com/questions/17687876/authorization-in-restful-http-api-401-www-authenticate?answertab=votes#tab-top) with some information about the authentication scheme (key-auth) #587 ","created_at":"2015-10-04T06:57:26Z","updated_at":"2015-10-05T22:30:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac8a5f9d4aec4c9f57d158bb003296397049cf69","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Mashape/kong/pulls/588/commits","review_comments_url":"https://api.github.com/repos/Mashape/kong/pulls/588/comments","review_comment_url":"https://api.github.com/repos/Mashape/kong/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Mashape/kong/issues/588/comments","statuses_url":"https://api.github.com/repos/Mashape/kong/statuses/993e36a0c75baf0009bce8d9ab5cb54a4df5807a","head":{"label":"ybv:www-auth-header-401","ref":"www-auth-header-401","sha":"993e36a0c75baf0009bce8d9ab5cb54a4df5807a","user":{"login":"ybv","id":4458116,"avatar_url":"https://avatars.githubusercontent.com/u/4458116?v=3","gravatar_id":"","url":"https://api.github.com/users/ybv","html_url":"https://github.com/ybv","followers_url":"https://api.github.com/users/ybv/followers","following_url":"https://api.github.com/users/ybv/following{/other_user}","gists_url":"https://api.github.com/users/ybv/gists{/gist_id}","starred_url":"https://api.github.com/users/ybv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ybv/subscriptions","organizations_url":"https://api.github.com/users/ybv/orgs","repos_url":"https://api.github.com/users/ybv/repos","events_url":"https://api.github.com/users/ybv/events{/privacy}","received_events_url":"https://api.github.com/users/ybv/received_events","type":"User","site_admin":false},"repo":{"id":43627741,"name":"kong","full_name":"ybv/kong","owner":{"login":"ybv","id":4458116,"avatar_url":"https://avatars.githubusercontent.com/u/4458116?v=3","gravatar_id":"","url":"https://api.github.com/users/ybv","html_url":"https://github.com/ybv","followers_url":"https://api.github.com/users/ybv/followers","following_url":"https://api.github.com/users/ybv/following{/other_user}","gists_url":"https://api.github.com/users/ybv/gists{/gist_id}","starred_url":"https://api.github.com/users/ybv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ybv/subscriptions","organizations_url":"https://api.github.com/users/ybv/orgs","repos_url":"https://api.github.com/users/ybv/repos","events_url":"https://api.github.com/users/ybv/events{/privacy}","received_events_url":"https://api.github.com/users/ybv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ybv/kong","description":"Open-source, Microservice & API Management Layer","fork":true,"url":"https://api.github.com/repos/ybv/kong","forks_url":"https://api.github.com/repos/ybv/kong/forks","keys_url":"https://api.github.com/repos/ybv/kong/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ybv/kong/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ybv/kong/teams","hooks_url":"https://api.github.com/repos/ybv/kong/hooks","issue_events_url":"https://api.github.com/repos/ybv/kong/issues/events{/number}","events_url":"https://api.github.com/repos/ybv/kong/events","assignees_url":"https://api.github.com/repos/ybv/kong/assignees{/user}","branches_url":"https://api.github.com/repos/ybv/kong/branches{/branch}","tags_url":"https://api.github.com/repos/ybv/kong/tags","blobs_url":"https://api.github.com/repos/ybv/kong/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ybv/kong/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ybv/kong/git/refs{/sha}","trees_url":"https://api.github.com/repos/ybv/kong/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ybv/kong/statuses/{sha}","languages_url":"https://api.github.com/repos/ybv/kong/languages","stargazers_url":"https://api.github.com/repos/ybv/kong/stargazers","contributors_url":"https://api.github.com/repos/ybv/kong/contributors","subscribers_url":"https://api.github.com/repos/ybv/kong/subscribers","subscription_url":"https://api.github.com/repos/ybv/kong/subscription","commits_url":"https://api.github.com/repos/ybv/kong/commits{/sha}","git_commits_url":"https://api.github.com/repos/ybv/kong/git/commits{/sha}","comments_url":"https://api.github.com/repos/ybv/kong/comments{/number}","issue_comment_url":"https://api.github.com/repos/ybv/kong/issues/comments{/number}","contents_url":"https://api.github.com/repos/ybv/kong/contents/{+path}","compare_url":"https://api.github.com/repos/ybv/kong/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ybv/kong/merges","archive_url":"https://api.github.com/repos/ybv/kong/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ybv/kong/downloads","issues_url":"https://api.github.com/repos/ybv/kong/issues{/number}","pulls_url":"https://api.github.com/repos/ybv/kong/pulls{/number}","milestones_url":"https://api.github.com/repos/ybv/kong/milestones{/number}","notifications_url":"https://api.github.com/repos/ybv/kong/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ybv/kong/labels{/name}","releases_url":"https://api.github.com/repos/ybv/kong/releases{/id}","created_at":"2015-10-04T06:47:23Z","updated_at":"2015-10-04T06:47:24Z","pushed_at":"2015-10-04T06:52:00Z","git_url":"git://github.com/ybv/kong.git","ssh_url":"git@github.com:ybv/kong.git","clone_url":"https://github.com/ybv/kong.git","svn_url":"https://github.com/ybv/kong","homepage":"https://getkong.org","size":110795,"stargazers_count":0,"watchers_count":0,"language":"Lua","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":"Mashape:master","ref":"master","sha":"ab0bf4dfd7d74ad24871105764b92c99c20d504f","user":{"login":"Mashape","id":962416,"avatar_url":"https://avatars.githubusercontent.com/u/962416?v=3","gravatar_id":"","url":"https://api.github.com/users/Mashape","html_url":"https://github.com/Mashape","followers_url":"https://api.github.com/users/Mashape/followers","following_url":"https://api.github.com/users/Mashape/following{/other_user}","gists_url":"https://api.github.com/users/Mashape/gists{/gist_id}","starred_url":"https://api.github.com/users/Mashape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mashape/subscriptions","organizations_url":"https://api.github.com/users/Mashape/orgs","repos_url":"https://api.github.com/users/Mashape/repos","events_url":"https://api.github.com/users/Mashape/events{/privacy}","received_events_url":"https://api.github.com/users/Mashape/received_events","type":"Organization","site_admin":false},"repo":{"id":26783295,"name":"kong","full_name":"Mashape/kong","owner":{"login":"Mashape","id":962416,"avatar_url":"https://avatars.githubusercontent.com/u/962416?v=3","gravatar_id":"","url":"https://api.github.com/users/Mashape","html_url":"https://github.com/Mashape","followers_url":"https://api.github.com/users/Mashape/followers","following_url":"https://api.github.com/users/Mashape/following{/other_user}","gists_url":"https://api.github.com/users/Mashape/gists{/gist_id}","starred_url":"https://api.github.com/users/Mashape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mashape/subscriptions","organizations_url":"https://api.github.com/users/Mashape/orgs","repos_url":"https://api.github.com/users/Mashape/repos","events_url":"https://api.github.com/users/Mashape/events{/privacy}","received_events_url":"https://api.github.com/users/Mashape/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Mashape/kong","description":"Open-source, Microservice & API Management Layer","fork":false,"url":"https://api.github.com/repos/Mashape/kong","forks_url":"https://api.github.com/repos/Mashape/kong/forks","keys_url":"https://api.github.com/repos/Mashape/kong/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mashape/kong/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mashape/kong/teams","hooks_url":"https://api.github.com/repos/Mashape/kong/hooks","issue_events_url":"https://api.github.com/repos/Mashape/kong/issues/events{/number}","events_url":"https://api.github.com/repos/Mashape/kong/events","assignees_url":"https://api.github.com/repos/Mashape/kong/assignees{/user}","branches_url":"https://api.github.com/repos/Mashape/kong/branches{/branch}","tags_url":"https://api.github.com/repos/Mashape/kong/tags","blobs_url":"https://api.github.com/repos/Mashape/kong/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mashape/kong/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mashape/kong/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mashape/kong/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mashape/kong/statuses/{sha}","languages_url":"https://api.github.com/repos/Mashape/kong/languages","stargazers_url":"https://api.github.com/repos/Mashape/kong/stargazers","contributors_url":"https://api.github.com/repos/Mashape/kong/contributors","subscribers_url":"https://api.github.com/repos/Mashape/kong/subscribers","subscription_url":"https://api.github.com/repos/Mashape/kong/subscription","commits_url":"https://api.github.com/repos/Mashape/kong/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mashape/kong/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mashape/kong/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mashape/kong/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mashape/kong/contents/{+path}","compare_url":"https://api.github.com/repos/Mashape/kong/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mashape/kong/merges","archive_url":"https://api.github.com/repos/Mashape/kong/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mashape/kong/downloads","issues_url":"https://api.github.com/repos/Mashape/kong/issues{/number}","pulls_url":"https://api.github.com/repos/Mashape/kong/pulls{/number}","milestones_url":"https://api.github.com/repos/Mashape/kong/milestones{/number}","notifications_url":"https://api.github.com/repos/Mashape/kong/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mashape/kong/labels{/name}","releases_url":"https://api.github.com/repos/Mashape/kong/releases{/id}","created_at":"2014-11-17T23:56:08Z","updated_at":"2015-10-05T21:15:40Z","pushed_at":"2015-10-05T19:22:29Z","git_url":"git://github.com/Mashape/kong.git","ssh_url":"git@github.com:Mashape/kong.git","clone_url":"https://github.com/Mashape/kong.git","svn_url":"https://github.com/Mashape/kong","homepage":"https://getkong.org","size":110795,"stargazers_count":2798,"watchers_count":2798,"language":"Lua","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":175,"mirror_url":null,"open_issues_count":111,"forks":175,"open_issues":111,"watchers":2798,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Mashape/kong/pulls/588"},"html":{"href":"https://github.com/Mashape/kong/pull/588"},"issue":{"href":"https://api.github.com/repos/Mashape/kong/issues/588"},"comments":{"href":"https://api.github.com/repos/Mashape/kong/issues/588/comments"},"review_comments":{"href":"https://api.github.com/repos/Mashape/kong/pulls/588/comments"},"review_comment":{"href":"https://api.github.com/repos/Mashape/kong/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Mashape/kong/pulls/588/commits"},"statuses":{"href":"https://api.github.com/repos/Mashape/kong/statuses/993e36a0c75baf0009bce8d9ab5cb54a4df5807a"}}}}