{"action":"created","comment":{"url":"https://api.github.com/repos/apache/phoenix/pulls/comments/124409157","pull_request_review_id":46687497,"id":124409157,"diff_hunk":"@@ -273,6 +282,54 @@ public int run(String[] args) throws Exception {\n     }\n   }\n \n+  // add remoteUserExtractor to builder if enabled\n+  @VisibleForTesting\n+  public void setRemoteUserExtractorIfNecessary(HttpServer.Builder builder, Configuration conf) {\n+    if (conf.getBoolean(QueryServices.QUERY_SERVER_WITH_REMOTEUSEREXTRACTOR_ATTRIB,\n+            QueryServicesOptions.DEFAULT_QUERY_SERVER_WITH_REMOTEUSEREXTRACTOR)) {\n+      builder.withRemoteUserExtractor(new PhoenixRemoteUserExtractor(conf));\n+    }\n+  }\n+\n+  /**\n+   * Use the correctly way to extract end user.\n+   */\n+\n+  static class PhoenixRemoteUserExtractor implements RemoteUserExtractor{\n+    private final HttpQueryStringParameterRemoteUserExtractor paramRemoteUserExtractor;\n+    private final HttpRequestRemoteUserExtractor requestRemoteUserExtractor;\n+    private final String userExtractParam;\n+\n+    public PhoenixRemoteUserExtractor(Configuration conf) {\n+      this.requestRemoteUserExtractor = new HttpRequestRemoteUserExtractor();\n+      this.userExtractParam = conf.get(QueryServices.QUERY_SERVER_REMOTEUSEREXTRACTOR_PARAM,\n+              QueryServicesOptions.DEFAULT_QUERY_SERVER_REMOTEUSEREXTRACTOR_PARAM);\n+      this.paramRemoteUserExtractor = new HttpQueryStringParameterRemoteUserExtractor(userExtractParam);\n+    }\n+\n+    @Override\n+    public String extract(HttpServletRequest request) throws RemoteUserExtractionException {\n+      if (request.getParameter(userExtractParam) != null) {\n+        String extractedUser = paramRemoteUserExtractor.extract(request);\n+        UserGroupInformation ugi = UserGroupInformation.createRemoteUser(request.getRemoteUser());\n+        UserGroupInformation proxyUser = UserGroupInformation.createProxyUser(extractedUser, ugi);","path":"phoenix-queryserver/src/main/java/org/apache/phoenix/queryserver/server/QueryServer.java","position":72,"original_position":72,"commit_id":"96fa3e29132efbee088481c2a015a3d40e4a3fab","original_commit_id":"96fa3e29132efbee088481c2a015a3d40e4a3fab","user":{"login":"joshelser","id":67863,"avatar_url":"https://avatars0.githubusercontent.com/u/67863?v=3","gravatar_id":"","url":"https://api.github.com/users/joshelser","html_url":"https://github.com/joshelser","followers_url":"https://api.github.com/users/joshelser/followers","following_url":"https://api.github.com/users/joshelser/following{/other_user}","gists_url":"https://api.github.com/users/joshelser/gists{/gist_id}","starred_url":"https://api.github.com/users/joshelser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshelser/subscriptions","organizations_url":"https://api.github.com/users/joshelser/orgs","repos_url":"https://api.github.com/users/joshelser/repos","events_url":"https://api.github.com/users/joshelser/events{/privacy}","received_events_url":"https://api.github.com/users/joshelser/received_events","type":"User","site_admin":false},"body":"In re-reading the above, I'm a little worried about the edge-cases. With PQS right now, we have the following cases \"supported\"\r\n\r\n1) Kerberos+SPNEGO as the Kerberos user (elserj@EXAMPLE.COM authenticates to PQS and the PQS credentials are used to query Phoenix as elserj@EXAMPLE.COM)\r\n2) Kerberos auth with HBase but no SPNEGO for PQS clients (legacy support for how things used to work before the SPNEGO auth was built -- PQS user does everything for users)\r\n3) Without Kerberos, all queries run as the PQS user (out of the box).\r\n\r\nAvatica supports more than what point 3 above does, but we haven't prioritized wiring that up as most people just want point 1. @Wancy, I had originally thought you were just trying to enable a PQS client with Kerberos credentials to say that they are someone else (extension of point 1 -- Credentials to PQS are for \"elserj\" but instead of querying Phoenix as \"elserj\", query as \"bob\").\r\n\r\nDid you also want this to work for cases when Kerberos is not in the mix? I think that would require some additional changes as I don't think this will work as-is.","created_at":"2017-06-27T22:08:08Z","updated_at":"2017-06-27T22:15:36Z","html_url":"https://github.com/apache/phoenix/pull/265#discussion_r124409157","pull_request_url":"https://api.github.com/repos/apache/phoenix/pulls/265","_links":{"self":{"href":"https://api.github.com/repos/apache/phoenix/pulls/comments/124409157"},"html":{"href":"https://github.com/apache/phoenix/pull/265#discussion_r124409157"},"pull_request":{"href":"https://api.github.com/repos/apache/phoenix/pulls/265"}}},"pull_request":{"url":"https://api.github.com/repos/apache/phoenix/pulls/265","id":127406646,"html_url":"https://github.com/apache/phoenix/pull/265","diff_url":"https://github.com/apache/phoenix/pull/265.diff","patch_url":"https://github.com/apache/phoenix/pull/265.patch","issue_url":"https://api.github.com/repos/apache/phoenix/issues/265","number":265,"state":"open","locked":false,"title":"PHOENIX-3598","user":{"login":"Wancy","id":10297460,"avatar_url":"https://avatars1.githubusercontent.com/u/10297460?v=3","gravatar_id":"","url":"https://api.github.com/users/Wancy","html_url":"https://github.com/Wancy","followers_url":"https://api.github.com/users/Wancy/followers","following_url":"https://api.github.com/users/Wancy/following{/other_user}","gists_url":"https://api.github.com/users/Wancy/gists{/gist_id}","starred_url":"https://api.github.com/users/Wancy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wancy/subscriptions","organizations_url":"https://api.github.com/users/Wancy/orgs","repos_url":"https://api.github.com/users/Wancy/repos","events_url":"https://api.github.com/users/Wancy/events{/privacy}","received_events_url":"https://api.github.com/users/Wancy/received_events","type":"User","site_admin":false},"body":"Add two params \"phoenix.queryserver.doAs.enabled\" and \"phoenix.queryserver.doAs.param\" to control whether to get enduser from request parameters and what is the parameter key name.","created_at":"2017-06-26T06:35:07Z","updated_at":"2017-06-27T22:15:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ffb96aafc4ed6b90c4ce1c82781320bdee7a1f91","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/phoenix/pulls/265/commits","review_comments_url":"https://api.github.com/repos/apache/phoenix/pulls/265/comments","review_comment_url":"https://api.github.com/repos/apache/phoenix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/phoenix/issues/265/comments","statuses_url":"https://api.github.com/repos/apache/phoenix/statuses/96fa3e29132efbee088481c2a015a3d40e4a3fab","head":{"label":"Wancy:master","ref":"master","sha":"96fa3e29132efbee088481c2a015a3d40e4a3fab","user":{"login":"Wancy","id":10297460,"avatar_url":"https://avatars1.githubusercontent.com/u/10297460?v=3","gravatar_id":"","url":"https://api.github.com/users/Wancy","html_url":"https://github.com/Wancy","followers_url":"https://api.github.com/users/Wancy/followers","following_url":"https://api.github.com/users/Wancy/following{/other_user}","gists_url":"https://api.github.com/users/Wancy/gists{/gist_id}","starred_url":"https://api.github.com/users/Wancy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wancy/subscriptions","organizations_url":"https://api.github.com/users/Wancy/orgs","repos_url":"https://api.github.com/users/Wancy/repos","events_url":"https://api.github.com/users/Wancy/events{/privacy}","received_events_url":"https://api.github.com/users/Wancy/received_events","type":"User","site_admin":false},"repo":{"id":89031863,"name":"phoenix","full_name":"Wancy/phoenix","owner":{"login":"Wancy","id":10297460,"avatar_url":"https://avatars1.githubusercontent.com/u/10297460?v=3","gravatar_id":"","url":"https://api.github.com/users/Wancy","html_url":"https://github.com/Wancy","followers_url":"https://api.github.com/users/Wancy/followers","following_url":"https://api.github.com/users/Wancy/following{/other_user}","gists_url":"https://api.github.com/users/Wancy/gists{/gist_id}","starred_url":"https://api.github.com/users/Wancy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wancy/subscriptions","organizations_url":"https://api.github.com/users/Wancy/orgs","repos_url":"https://api.github.com/users/Wancy/repos","events_url":"https://api.github.com/users/Wancy/events{/privacy}","received_events_url":"https://api.github.com/users/Wancy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Wancy/phoenix","description":"Mirror of Apache Phoenix","fork":true,"url":"https://api.github.com/repos/Wancy/phoenix","forks_url":"https://api.github.com/repos/Wancy/phoenix/forks","keys_url":"https://api.github.com/repos/Wancy/phoenix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wancy/phoenix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wancy/phoenix/teams","hooks_url":"https://api.github.com/repos/Wancy/phoenix/hooks","issue_events_url":"https://api.github.com/repos/Wancy/phoenix/issues/events{/number}","events_url":"https://api.github.com/repos/Wancy/phoenix/events","assignees_url":"https://api.github.com/repos/Wancy/phoenix/assignees{/user}","branches_url":"https://api.github.com/repos/Wancy/phoenix/branches{/branch}","tags_url":"https://api.github.com/repos/Wancy/phoenix/tags","blobs_url":"https://api.github.com/repos/Wancy/phoenix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wancy/phoenix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wancy/phoenix/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wancy/phoenix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wancy/phoenix/statuses/{sha}","languages_url":"https://api.github.com/repos/Wancy/phoenix/languages","stargazers_url":"https://api.github.com/repos/Wancy/phoenix/stargazers","contributors_url":"https://api.github.com/repos/Wancy/phoenix/contributors","subscribers_url":"https://api.github.com/repos/Wancy/phoenix/subscribers","subscription_url":"https://api.github.com/repos/Wancy/phoenix/subscription","commits_url":"https://api.github.com/repos/Wancy/phoenix/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wancy/phoenix/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wancy/phoenix/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wancy/phoenix/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wancy/phoenix/contents/{+path}","compare_url":"https://api.github.com/repos/Wancy/phoenix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wancy/phoenix/merges","archive_url":"https://api.github.com/repos/Wancy/phoenix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wancy/phoenix/downloads","issues_url":"https://api.github.com/repos/Wancy/phoenix/issues{/number}","pulls_url":"https://api.github.com/repos/Wancy/phoenix/pulls{/number}","milestones_url":"https://api.github.com/repos/Wancy/phoenix/milestones{/number}","notifications_url":"https://api.github.com/repos/Wancy/phoenix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wancy/phoenix/labels{/name}","releases_url":"https://api.github.com/repos/Wancy/phoenix/releases{/id}","deployments_url":"https://api.github.com/repos/Wancy/phoenix/deployments","created_at":"2017-04-21T23:44:39Z","updated_at":"2017-04-21T23:44:47Z","pushed_at":"2017-06-27T18:20:30Z","git_url":"git://github.com/Wancy/phoenix.git","ssh_url":"git@github.com:Wancy/phoenix.git","clone_url":"https://github.com/Wancy/phoenix.git","svn_url":"https://github.com/Wancy/phoenix","homepage":null,"size":33403,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"apache:master","ref":"master","sha":"9a65ee9bcac4f270c1f7f46346f18ed539928d68","user":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":20473418,"name":"phoenix","full_name":"apache/phoenix","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars3.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/phoenix","description":"Mirror of Apache Phoenix","fork":false,"url":"https://api.github.com/repos/apache/phoenix","forks_url":"https://api.github.com/repos/apache/phoenix/forks","keys_url":"https://api.github.com/repos/apache/phoenix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/phoenix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/phoenix/teams","hooks_url":"https://api.github.com/repos/apache/phoenix/hooks","issue_events_url":"https://api.github.com/repos/apache/phoenix/issues/events{/number}","events_url":"https://api.github.com/repos/apache/phoenix/events","assignees_url":"https://api.github.com/repos/apache/phoenix/assignees{/user}","branches_url":"https://api.github.com/repos/apache/phoenix/branches{/branch}","tags_url":"https://api.github.com/repos/apache/phoenix/tags","blobs_url":"https://api.github.com/repos/apache/phoenix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/phoenix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/phoenix/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/phoenix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/phoenix/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/phoenix/languages","stargazers_url":"https://api.github.com/repos/apache/phoenix/stargazers","contributors_url":"https://api.github.com/repos/apache/phoenix/contributors","subscribers_url":"https://api.github.com/repos/apache/phoenix/subscribers","subscription_url":"https://api.github.com/repos/apache/phoenix/subscription","commits_url":"https://api.github.com/repos/apache/phoenix/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/phoenix/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/phoenix/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/phoenix/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/phoenix/contents/{+path}","compare_url":"https://api.github.com/repos/apache/phoenix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/phoenix/merges","archive_url":"https://api.github.com/repos/apache/phoenix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/phoenix/downloads","issues_url":"https://api.github.com/repos/apache/phoenix/issues{/number}","pulls_url":"https://api.github.com/repos/apache/phoenix/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/phoenix/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/phoenix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/phoenix/labels{/name}","releases_url":"https://api.github.com/repos/apache/phoenix/releases{/id}","deployments_url":"https://api.github.com/repos/apache/phoenix/deployments","created_at":"2014-06-04T07:00:08Z","updated_at":"2017-06-27T13:58:51Z","pushed_at":"2017-06-27T18:20:32Z","git_url":"git://github.com/apache/phoenix.git","ssh_url":"git@github.com:apache/phoenix.git","clone_url":"https://github.com/apache/phoenix.git","svn_url":"https://github.com/apache/phoenix","homepage":null,"size":34087,"stargazers_count":325,"watchers_count":325,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":460,"mirror_url":"git://git.apache.org/phoenix.git","open_issues_count":140,"forks":460,"open_issues":140,"watchers":325,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/phoenix/pulls/265"},"html":{"href":"https://github.com/apache/phoenix/pull/265"},"issue":{"href":"https://api.github.com/repos/apache/phoenix/issues/265"},"comments":{"href":"https://api.github.com/repos/apache/phoenix/issues/265/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/phoenix/pulls/265/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/phoenix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/phoenix/pulls/265/commits"},"statuses":{"href":"https://api.github.com/repos/apache/phoenix/statuses/96fa3e29132efbee088481c2a015a3d40e4a3fab"}}}}
{"actor":{"display_login":"joshelser"}}