{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/comments/182117976","pull_request_review_id":112866480,"id":182117976,"diff_hunk":"@@ -12,22 +12,25 @@ def require_api_user_or_token\n         elsif request.headers[HttpHeaders::AUTH_TOKEN]\n           authenticate_with_user_token(request.headers[HttpHeaders::AUTH_TOKEN])\n         else\n-          authenticate_options = {\n-            :require_user => true,\n-            :timeout      => ::Settings.api.authentication_timeout.to_i_with_method\n-          }\n-\n-          if (user = authenticate_with_http_basic { |u, p| User.authenticate(u, p, request, authenticate_options) })\n-            auth_user_obj = userid_to_userobj(user.userid)\n-            authorize_user_group(auth_user_obj)\n-            validate_user_identity(auth_user_obj)\n-            User.current_user = auth_user_obj\n-          else\n-            request_http_basic_authentication\n-            return\n+          success = authenticate_with_http_basic do |u, p|\n+            begin\n+              timeout = ::Settings.api.authentication_timeout.to_i_with_method\n+              user = User.authenticate(u, p, request, :require_user => true, :timeout => timeout)\n+              auth_user_obj = userid_to_userobj(user.userid)\n+              authorize_user_group(auth_user_obj)\n+              validate_user_identity(auth_user_obj)\n+              User.current_user = auth_user_obj\n+            rescue MiqException::MiqEVMLoginError => e\n+              raise AuthenticationError, e.message\n+            end\n           end\n+          raise AuthenticationError unless success\n         end\n         log_api_auth\n+      rescue AuthenticationError => e\n+        api_log_error(\"AuthenticationError: #{e.message}\")\n+        response.headers[\"Content-Type\"] = \"application/json\"\n+        request_http_basic_authentication(\"Application\", ErrorSerializer.new(:unauthorized, e).serialize.to_json)","path":"app/controllers/api/base_controller/authentication.rb","position":35,"original_position":35,"commit_id":"9fe4247787aaa858a1cb9ddfc2413f8ca12318ee","original_commit_id":"1aa0675c6447e2b4bae462e15fe7ca7417fd491f","user":{"login":"imtayadeway","id":1710874,"avatar_url":"https://avatars2.githubusercontent.com/u/1710874?v=4","gravatar_id":"","url":"https://api.github.com/users/imtayadeway","html_url":"https://github.com/imtayadeway","followers_url":"https://api.github.com/users/imtayadeway/followers","following_url":"https://api.github.com/users/imtayadeway/following{/other_user}","gists_url":"https://api.github.com/users/imtayadeway/gists{/gist_id}","starred_url":"https://api.github.com/users/imtayadeway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imtayadeway/subscriptions","organizations_url":"https://api.github.com/users/imtayadeway/orgs","repos_url":"https://api.github.com/users/imtayadeway/repos","events_url":"https://api.github.com/users/imtayadeway/events{/privacy}","received_events_url":"https://api.github.com/users/imtayadeway/received_events","type":"User","site_admin":false},"body":"Addressed in https://github.com/ManageIQ/manageiq-api/pull/359/commits/9fe4247787aaa858a1cb9ddfc2413f8ca12318ee","created_at":"2018-04-17T15:34:33Z","updated_at":"2018-04-17T15:34:33Z","html_url":"https://github.com/ManageIQ/manageiq-api/pull/359#discussion_r182117976","pull_request_url":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/359","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/comments/182117976"},"html":{"href":"https://github.com/ManageIQ/manageiq-api/pull/359#discussion_r182117976"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/359"}},"in_reply_to_id":181906185},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/359","id":179757891,"html_url":"https://github.com/ManageIQ/manageiq-api/pull/359","diff_url":"https://github.com/ManageIQ/manageiq-api/pull/359.diff","patch_url":"https://github.com/ManageIQ/manageiq-api/pull/359.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq-api/issues/359","number":359,"state":"open","locked":false,"title":"Always challenge a user with no/bad credentials","user":{"login":"imtayadeway","id":1710874,"avatar_url":"https://avatars2.githubusercontent.com/u/1710874?v=4","gravatar_id":"","url":"https://api.github.com/users/imtayadeway","html_url":"https://github.com/imtayadeway","followers_url":"https://api.github.com/users/imtayadeway/followers","following_url":"https://api.github.com/users/imtayadeway/following{/other_user}","gists_url":"https://api.github.com/users/imtayadeway/gists{/gist_id}","starred_url":"https://api.github.com/users/imtayadeway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imtayadeway/subscriptions","organizations_url":"https://api.github.com/users/imtayadeway/orgs","repos_url":"https://api.github.com/users/imtayadeway/repos","events_url":"https://api.github.com/users/imtayadeway/events{/privacy}","received_events_url":"https://api.github.com/users/imtayadeway/received_events","type":"User","site_admin":false},"body":"According to RFC 2617:\r\n\r\n> The 401 (Unauthorized) response message is used by an origin server\r\n  to challenge the authorization of a user agent. This response MUST\r\n  include a WWW-Authenticate header field containing at least one\r\n  challenge applicable to the requested resource.\r\n\r\nWe currently only issue a challenge when no credentials are provided -\r\nif a user fails authentication they are not challenged again. This\r\nbroken implementation can cause some frustration for instance when\r\nusing the web browser, which will cache a mis-typed user/password\r\ncombination and not challenge the user again.\r\n\r\nThis is somewhat problematic as we only use the `Authorization` header\r\nfor Basic Authentication. It seems like a safe compromise for the user\r\nto be challenged to use Basic Authentication if authentication fails\r\nfor whatever reason.","created_at":"2018-04-05T18:23:15Z","updated_at":"2018-04-17T15:34:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"411bd12fea2891b958c20698195a9dad236042bf","assignee":{"login":"abellotti","id":5797328,"avatar_url":"https://avatars1.githubusercontent.com/u/5797328?v=4","gravatar_id":"","url":"https://api.github.com/users/abellotti","html_url":"https://github.com/abellotti","followers_url":"https://api.github.com/users/abellotti/followers","following_url":"https://api.github.com/users/abellotti/following{/other_user}","gists_url":"https://api.github.com/users/abellotti/gists{/gist_id}","starred_url":"https://api.github.com/users/abellotti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abellotti/subscriptions","organizations_url":"https://api.github.com/users/abellotti/orgs","repos_url":"https://api.github.com/users/abellotti/repos","events_url":"https://api.github.com/users/abellotti/events{/privacy}","received_events_url":"https://api.github.com/users/abellotti/received_events","type":"User","site_admin":false},"assignees":[{"login":"abellotti","id":5797328,"avatar_url":"https://avatars1.githubusercontent.com/u/5797328?v=4","gravatar_id":"","url":"https://api.github.com/users/abellotti","html_url":"https://github.com/abellotti","followers_url":"https://api.github.com/users/abellotti/followers","following_url":"https://api.github.com/users/abellotti/following{/other_user}","gists_url":"https://api.github.com/users/abellotti/gists{/gist_id}","starred_url":"https://api.github.com/users/abellotti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abellotti/subscriptions","organizations_url":"https://api.github.com/users/abellotti/orgs","repos_url":"https://api.github.com/users/abellotti/repos","events_url":"https://api.github.com/users/abellotti/events{/privacy}","received_events_url":"https://api.github.com/users/abellotti/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":663822610,"url":"https://api.github.com/repos/ManageIQ/manageiq-api/labels/bug","name":"bug","color":"ee0701","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/359/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/359/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq-api/issues/359/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq-api/statuses/9fe4247787aaa858a1cb9ddfc2413f8ca12318ee","head":{"label":"imtayadeway:basic-authentication-challenge","ref":"basic-authentication-challenge","sha":"9fe4247787aaa858a1cb9ddfc2413f8ca12318ee","user":{"login":"imtayadeway","id":1710874,"avatar_url":"https://avatars2.githubusercontent.com/u/1710874?v=4","gravatar_id":"","url":"https://api.github.com/users/imtayadeway","html_url":"https://github.com/imtayadeway","followers_url":"https://api.github.com/users/imtayadeway/followers","following_url":"https://api.github.com/users/imtayadeway/following{/other_user}","gists_url":"https://api.github.com/users/imtayadeway/gists{/gist_id}","starred_url":"https://api.github.com/users/imtayadeway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imtayadeway/subscriptions","organizations_url":"https://api.github.com/users/imtayadeway/orgs","repos_url":"https://api.github.com/users/imtayadeway/repos","events_url":"https://api.github.com/users/imtayadeway/events{/privacy}","received_events_url":"https://api.github.com/users/imtayadeway/received_events","type":"User","site_admin":false},"repo":{"id":99706646,"name":"manageiq-api","full_name":"imtayadeway/manageiq-api","owner":{"login":"imtayadeway","id":1710874,"avatar_url":"https://avatars2.githubusercontent.com/u/1710874?v=4","gravatar_id":"","url":"https://api.github.com/users/imtayadeway","html_url":"https://github.com/imtayadeway","followers_url":"https://api.github.com/users/imtayadeway/followers","following_url":"https://api.github.com/users/imtayadeway/following{/other_user}","gists_url":"https://api.github.com/users/imtayadeway/gists{/gist_id}","starred_url":"https://api.github.com/users/imtayadeway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imtayadeway/subscriptions","organizations_url":"https://api.github.com/users/imtayadeway/orgs","repos_url":"https://api.github.com/users/imtayadeway/repos","events_url":"https://api.github.com/users/imtayadeway/events{/privacy}","received_events_url":"https://api.github.com/users/imtayadeway/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/imtayadeway/manageiq-api","description":"ManageIQ API","fork":true,"url":"https://api.github.com/repos/imtayadeway/manageiq-api","forks_url":"https://api.github.com/repos/imtayadeway/manageiq-api/forks","keys_url":"https://api.github.com/repos/imtayadeway/manageiq-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/imtayadeway/manageiq-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/imtayadeway/manageiq-api/teams","hooks_url":"https://api.github.com/repos/imtayadeway/manageiq-api/hooks","issue_events_url":"https://api.github.com/repos/imtayadeway/manageiq-api/issues/events{/number}","events_url":"https://api.github.com/repos/imtayadeway/manageiq-api/events","assignees_url":"https://api.github.com/repos/imtayadeway/manageiq-api/assignees{/user}","branches_url":"https://api.github.com/repos/imtayadeway/manageiq-api/branches{/branch}","tags_url":"https://api.github.com/repos/imtayadeway/manageiq-api/tags","blobs_url":"https://api.github.com/repos/imtayadeway/manageiq-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/imtayadeway/manageiq-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/imtayadeway/manageiq-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/imtayadeway/manageiq-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/imtayadeway/manageiq-api/statuses/{sha}","languages_url":"https://api.github.com/repos/imtayadeway/manageiq-api/languages","stargazers_url":"https://api.github.com/repos/imtayadeway/manageiq-api/stargazers","contributors_url":"https://api.github.com/repos/imtayadeway/manageiq-api/contributors","subscribers_url":"https://api.github.com/repos/imtayadeway/manageiq-api/subscribers","subscription_url":"https://api.github.com/repos/imtayadeway/manageiq-api/subscription","commits_url":"https://api.github.com/repos/imtayadeway/manageiq-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/imtayadeway/manageiq-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/imtayadeway/manageiq-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/imtayadeway/manageiq-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/imtayadeway/manageiq-api/contents/{+path}","compare_url":"https://api.github.com/repos/imtayadeway/manageiq-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/imtayadeway/manageiq-api/merges","archive_url":"https://api.github.com/repos/imtayadeway/manageiq-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/imtayadeway/manageiq-api/downloads","issues_url":"https://api.github.com/repos/imtayadeway/manageiq-api/issues{/number}","pulls_url":"https://api.github.com/repos/imtayadeway/manageiq-api/pulls{/number}","milestones_url":"https://api.github.com/repos/imtayadeway/manageiq-api/milestones{/number}","notifications_url":"https://api.github.com/repos/imtayadeway/manageiq-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/imtayadeway/manageiq-api/labels{/name}","releases_url":"https://api.github.com/repos/imtayadeway/manageiq-api/releases{/id}","deployments_url":"https://api.github.com/repos/imtayadeway/manageiq-api/deployments","created_at":"2017-08-08T15:15:02Z","updated_at":"2018-04-13T15:45:53Z","pushed_at":"2018-04-17T15:34:01Z","git_url":"git://github.com/imtayadeway/manageiq-api.git","ssh_url":"git@github.com:imtayadeway/manageiq-api.git","clone_url":"https://github.com/imtayadeway/manageiq-api.git","svn_url":"https://github.com/imtayadeway/manageiq-api","homepage":null,"size":3730,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ManageIQ:master","ref":"master","sha":"8911c633901be7961c7492bcbe3bba18bf7d0bc9","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars0.githubusercontent.com/u/1125575?v=4","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":99615440,"name":"manageiq-api","full_name":"ManageIQ/manageiq-api","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars0.githubusercontent.com/u/1125575?v=4","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/manageiq-api","description":"ManageIQ API","fork":false,"url":"https://api.github.com/repos/ManageIQ/manageiq-api","forks_url":"https://api.github.com/repos/ManageIQ/manageiq-api/forks","keys_url":"https://api.github.com/repos/ManageIQ/manageiq-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/manageiq-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/manageiq-api/teams","hooks_url":"https://api.github.com/repos/ManageIQ/manageiq-api/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/manageiq-api/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/manageiq-api/events","assignees_url":"https://api.github.com/repos/ManageIQ/manageiq-api/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/manageiq-api/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/manageiq-api/tags","blobs_url":"https://api.github.com/repos/ManageIQ/manageiq-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/manageiq-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/manageiq-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/manageiq-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq-api/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/manageiq-api/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/manageiq-api/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/manageiq-api/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/manageiq-api/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/manageiq-api/subscription","commits_url":"https://api.github.com/repos/ManageIQ/manageiq-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/manageiq-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/manageiq-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/manageiq-api/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/manageiq-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/manageiq-api/merges","archive_url":"https://api.github.com/repos/ManageIQ/manageiq-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/manageiq-api/downloads","issues_url":"https://api.github.com/repos/ManageIQ/manageiq-api/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/manageiq-api/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/manageiq-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/manageiq-api/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/manageiq-api/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/manageiq-api/deployments","created_at":"2017-08-07T20:05:29Z","updated_at":"2018-04-11T20:23:08Z","pushed_at":"2018-04-17T15:34:03Z","git_url":"git://github.com/ManageIQ/manageiq-api.git","ssh_url":"git@github.com:ManageIQ/manageiq-api.git","clone_url":"https://github.com/ManageIQ/manageiq-api.git","svn_url":"https://github.com/ManageIQ/manageiq-api","homepage":null,"size":3797,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":66,"mirror_url":null,"archived":false,"open_issues_count":28,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":66,"open_issues":28,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/359"},"html":{"href":"https://github.com/ManageIQ/manageiq-api/pull/359"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/issues/359"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/issues/359/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/359/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/pulls/359/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq-api/statuses/9fe4247787aaa858a1cb9ddfc2413f8ca12318ee"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"imtayadeway"}}