{"action":"created","comment":{"url":"https://api.github.com/repos/druid-io/druid/pulls/comments/59319249","id":59319249,"diff_hunk":"@@ -24,23 +24,36 @@\n import com.google.common.collect.SetMultimap;\n import com.google.common.util.concurrent.ListenableFuture;\n import com.google.common.util.concurrent.MoreExecutors;\n+import com.metamx.common.IAE;\n+import io.druid.query.DataSource;\n import io.druid.query.Query;\n+import io.druid.query.QueryDataSource;\n import io.druid.query.QueryWatcher;\n+import io.druid.query.TableDataSource;\n+import io.druid.query.UnionDataSource;\n \n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.Map;\n import java.util.Set;\n+import java.util.concurrent.ConcurrentHashMap;\n \n public class QueryManager implements QueryWatcher\n {\n+\n   final SetMultimap<String, ListenableFuture> queries;\n+  final Map<String, List<String>> queryDatasources;","path":"server/src/main/java/io/druid/server/QueryManager.java","position":22,"original_position":22,"commit_id":"2fbc8208fd40453b3a700d07ac718065373896bd","original_commit_id":"2fbc8208fd40453b3a700d07ac718065373896bd","user":{"login":"himanshug","id":246308,"avatar_url":"https://avatars.githubusercontent.com/u/246308?v=3","gravatar_id":"","url":"https://api.github.com/users/himanshug","html_url":"https://github.com/himanshug","followers_url":"https://api.github.com/users/himanshug/followers","following_url":"https://api.github.com/users/himanshug/following{/other_user}","gists_url":"https://api.github.com/users/himanshug/gists{/gist_id}","starred_url":"https://api.github.com/users/himanshug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himanshug/subscriptions","organizations_url":"https://api.github.com/users/himanshug/orgs","repos_url":"https://api.github.com/users/himanshug/repos","events_url":"https://api.github.com/users/himanshug/events{/privacy}","received_events_url":"https://api.github.com/users/himanshug/received_events","type":"User","site_admin":false},"body":"can the 2 of these be private?","created_at":"2016-04-12T04:25:45Z","updated_at":"2016-04-12T04:25:45Z","html_url":"https://github.com/druid-io/druid/pull/2424#discussion_r59319249","pull_request_url":"https://api.github.com/repos/druid-io/druid/pulls/2424","_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments/59319249"},"html":{"href":"https://github.com/druid-io/druid/pull/2424#discussion_r59319249"},"pull_request":{"href":"https://api.github.com/repos/druid-io/druid/pulls/2424"}}},"pull_request":{"url":"https://api.github.com/repos/druid-io/druid/pulls/2424","id":58775740,"html_url":"https://github.com/druid-io/druid/pull/2424","diff_url":"https://github.com/druid-io/druid/pull/2424.diff","patch_url":"https://github.com/druid-io/druid/pull/2424.patch","issue_url":"https://api.github.com/repos/druid-io/druid/issues/2424","number":2424,"state":"open","locked":false,"title":"Enabling datasource level authorization in Druid","user":{"login":"pjain1","id":11787983,"avatar_url":"https://avatars.githubusercontent.com/u/11787983?v=3","gravatar_id":"","url":"https://api.github.com/users/pjain1","html_url":"https://github.com/pjain1","followers_url":"https://api.github.com/users/pjain1/followers","following_url":"https://api.github.com/users/pjain1/following{/other_user}","gists_url":"https://api.github.com/users/pjain1/gists{/gist_id}","starred_url":"https://api.github.com/users/pjain1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjain1/subscriptions","organizations_url":"https://api.github.com/users/pjain1/orgs","repos_url":"https://api.github.com/users/pjain1/repos","events_url":"https://api.github.com/users/pjain1/events{/privacy}","received_events_url":"https://api.github.com/users/pjain1/received_events","type":"User","site_admin":false},"body":"Fixes #2355. This PR is meant to put necessary abstractions inside Druid for enabling authorization as discussed in #2355 \r\n\r\n- Introduce `AuthorizationInfo` interface, specific implementations of which would be provided by extensions\r\n- If the `druid.auth.enabled` is set to `true` then the `isAuthorized` method of `AuthorizationInfo` will be called to perform authorization checks\r\n-  `AuthorizationInfo` object will be created in the servlet filters of specific extension and will be passed as a request attribute with attribute name as `AuthConfig.DRUID_AUTH_TOKEN`\r\n- As per the scope of this PR, all resources that needs to be secured are divided into 3 types - `DATASOURCE`, `CONFIG` and `STATE`. For any type of resource, possible actions are  - `READ` or `WRITE`\r\n- Specific ResourceFilters are used to perform auth checks for all endpoints that corresponds to a specific resource type. This prevents duplication of logic and need to inject HttpServletRequest inside each endpoint. For example \r\n - `DatasourceResourceFilter` is used for endpoints with prefix `/druid/coordinator/v1/datasources/`, `/druid/coordinator/v1/metadata/datasources/`, `/druid/v2/datasources/` and `/druid/coordinator/v1/rules/`\r\n - `TaskResourceFilter` is used for endpoints with prefix `druid/indexer/v1/task`\r\n - `ConfigResourceFilter` is used for endpoints like `/druid/coordinator/v1/config`, `/druid/indexer/v1/worker`, `/druid/worker/v1` etc\r\n - `StateResourceFilter` is used for endpoints like `/druid/broker/v1/loadstatus`, `/druid/coordinator/v1/leader`, `/druid/coordinator/v1/loadqueue`, `/druid/coordinator/v1/rules` etc\r\n- For endpoints where a list of resources is returned like `/druid/coordinator/v1/datasources`, `/druid/indexer/v1/completeTasks` etc. the list is filtered to return only the resources to which the requested user has access. In these cases, `HttpServletRequest` instance needs to be injected in the endpoint method.\r\n","created_at":"2016-02-09T16:53:59Z","updated_at":"2016-04-12T04:25:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb18ec3b6145b7658b409653881222ca75d451e6","assignee":null,"milestone":{"url":"https://api.github.com/repos/druid-io/druid/milestones/18","html_url":"https://github.com/druid-io/druid/milestones/0.9.1","labels_url":"https://api.github.com/repos/druid-io/druid/milestones/18/labels","id":1526819,"number":18,"title":"0.9.1","description":"","creator":{"login":"fjy","id":428325,"avatar_url":"https://avatars.githubusercontent.com/u/428325?v=3","gravatar_id":"","url":"https://api.github.com/users/fjy","html_url":"https://github.com/fjy","followers_url":"https://api.github.com/users/fjy/followers","following_url":"https://api.github.com/users/fjy/following{/other_user}","gists_url":"https://api.github.com/users/fjy/gists{/gist_id}","starred_url":"https://api.github.com/users/fjy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fjy/subscriptions","organizations_url":"https://api.github.com/users/fjy/orgs","repos_url":"https://api.github.com/users/fjy/repos","events_url":"https://api.github.com/users/fjy/events{/privacy}","received_events_url":"https://api.github.com/users/fjy/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":131,"state":"open","created_at":"2016-01-20T19:04:22Z","updated_at":"2016-04-12T03:28:01Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/druid-io/druid/pulls/2424/commits","review_comments_url":"https://api.github.com/repos/druid-io/druid/pulls/2424/comments","review_comment_url":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/druid-io/druid/issues/2424/comments","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/2fbc8208fd40453b3a700d07ac718065373896bd","head":{"label":"pjain1:security","ref":"security","sha":"2fbc8208fd40453b3a700d07ac718065373896bd","user":{"login":"pjain1","id":11787983,"avatar_url":"https://avatars.githubusercontent.com/u/11787983?v=3","gravatar_id":"","url":"https://api.github.com/users/pjain1","html_url":"https://github.com/pjain1","followers_url":"https://api.github.com/users/pjain1/followers","following_url":"https://api.github.com/users/pjain1/following{/other_user}","gists_url":"https://api.github.com/users/pjain1/gists{/gist_id}","starred_url":"https://api.github.com/users/pjain1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjain1/subscriptions","organizations_url":"https://api.github.com/users/pjain1/orgs","repos_url":"https://api.github.com/users/pjain1/repos","events_url":"https://api.github.com/users/pjain1/events{/privacy}","received_events_url":"https://api.github.com/users/pjain1/received_events","type":"User","site_admin":false},"repo":{"id":33489992,"name":"druid","full_name":"pjain1/druid","owner":{"login":"pjain1","id":11787983,"avatar_url":"https://avatars.githubusercontent.com/u/11787983?v=3","gravatar_id":"","url":"https://api.github.com/users/pjain1","html_url":"https://github.com/pjain1","followers_url":"https://api.github.com/users/pjain1/followers","following_url":"https://api.github.com/users/pjain1/following{/other_user}","gists_url":"https://api.github.com/users/pjain1/gists{/gist_id}","starred_url":"https://api.github.com/users/pjain1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjain1/subscriptions","organizations_url":"https://api.github.com/users/pjain1/orgs","repos_url":"https://api.github.com/users/pjain1/repos","events_url":"https://api.github.com/users/pjain1/events{/privacy}","received_events_url":"https://api.github.com/users/pjain1/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pjain1/druid","description":"Real²time Exploratory Analytics on Large Datasets","fork":true,"url":"https://api.github.com/repos/pjain1/druid","forks_url":"https://api.github.com/repos/pjain1/druid/forks","keys_url":"https://api.github.com/repos/pjain1/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pjain1/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pjain1/druid/teams","hooks_url":"https://api.github.com/repos/pjain1/druid/hooks","issue_events_url":"https://api.github.com/repos/pjain1/druid/issues/events{/number}","events_url":"https://api.github.com/repos/pjain1/druid/events","assignees_url":"https://api.github.com/repos/pjain1/druid/assignees{/user}","branches_url":"https://api.github.com/repos/pjain1/druid/branches{/branch}","tags_url":"https://api.github.com/repos/pjain1/druid/tags","blobs_url":"https://api.github.com/repos/pjain1/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pjain1/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pjain1/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/pjain1/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pjain1/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/pjain1/druid/languages","stargazers_url":"https://api.github.com/repos/pjain1/druid/stargazers","contributors_url":"https://api.github.com/repos/pjain1/druid/contributors","subscribers_url":"https://api.github.com/repos/pjain1/druid/subscribers","subscription_url":"https://api.github.com/repos/pjain1/druid/subscription","commits_url":"https://api.github.com/repos/pjain1/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/pjain1/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/pjain1/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/pjain1/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/pjain1/druid/contents/{+path}","compare_url":"https://api.github.com/repos/pjain1/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pjain1/druid/merges","archive_url":"https://api.github.com/repos/pjain1/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pjain1/druid/downloads","issues_url":"https://api.github.com/repos/pjain1/druid/issues{/number}","pulls_url":"https://api.github.com/repos/pjain1/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/pjain1/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/pjain1/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pjain1/druid/labels{/name}","releases_url":"https://api.github.com/repos/pjain1/druid/releases{/id}","deployments_url":"https://api.github.com/repos/pjain1/druid/deployments","created_at":"2015-04-06T15:44:13Z","updated_at":"2015-05-06T21:31:13Z","pushed_at":"2016-04-06T15:33:48Z","git_url":"git://github.com/pjain1/druid.git","ssh_url":"git@github.com:pjain1/druid.git","clone_url":"https://github.com/pjain1/druid.git","svn_url":"https://github.com/pjain1/druid","homepage":"http://druid.io","size":106518,"stargazers_count":1,"watchers_count":1,"language":"Java","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":1,"default_branch":"master"}},"base":{"label":"druid-io:master","ref":"master","sha":"f82044bdb6d1342862d0299540813f2174255037","user":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"repo":{"id":6358188,"name":"druid","full_name":"druid-io/druid","owner":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/druid-io/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":false,"url":"https://api.github.com/repos/druid-io/druid","forks_url":"https://api.github.com/repos/druid-io/druid/forks","keys_url":"https://api.github.com/repos/druid-io/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/druid-io/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/druid-io/druid/teams","hooks_url":"https://api.github.com/repos/druid-io/druid/hooks","issue_events_url":"https://api.github.com/repos/druid-io/druid/issues/events{/number}","events_url":"https://api.github.com/repos/druid-io/druid/events","assignees_url":"https://api.github.com/repos/druid-io/druid/assignees{/user}","branches_url":"https://api.github.com/repos/druid-io/druid/branches{/branch}","tags_url":"https://api.github.com/repos/druid-io/druid/tags","blobs_url":"https://api.github.com/repos/druid-io/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/druid-io/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/druid-io/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/druid-io/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/druid-io/druid/languages","stargazers_url":"https://api.github.com/repos/druid-io/druid/stargazers","contributors_url":"https://api.github.com/repos/druid-io/druid/contributors","subscribers_url":"https://api.github.com/repos/druid-io/druid/subscribers","subscription_url":"https://api.github.com/repos/druid-io/druid/subscription","commits_url":"https://api.github.com/repos/druid-io/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/druid-io/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/druid-io/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/druid-io/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/druid-io/druid/contents/{+path}","compare_url":"https://api.github.com/repos/druid-io/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/druid-io/druid/merges","archive_url":"https://api.github.com/repos/druid-io/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/druid-io/druid/downloads","issues_url":"https://api.github.com/repos/druid-io/druid/issues{/number}","pulls_url":"https://api.github.com/repos/druid-io/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/druid-io/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/druid-io/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/druid-io/druid/labels{/name}","releases_url":"https://api.github.com/repos/druid-io/druid/releases{/id}","deployments_url":"https://api.github.com/repos/druid-io/druid/deployments","created_at":"2012-10-23T19:08:07Z","updated_at":"2016-04-12T04:02:16Z","pushed_at":"2016-04-12T03:28:02Z","git_url":"git://github.com/druid-io/druid.git","ssh_url":"git@github.com:druid-io/druid.git","clone_url":"https://github.com/druid-io/druid.git","svn_url":"https://github.com/druid-io/druid","homepage":"http://druid.io","size":128725,"stargazers_count":3010,"watchers_count":3010,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":662,"mirror_url":null,"open_issues_count":404,"forks":662,"open_issues":404,"watchers":3010,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/2424"},"html":{"href":"https://github.com/druid-io/druid/pull/2424"},"issue":{"href":"https://api.github.com/repos/druid-io/druid/issues/2424"},"comments":{"href":"https://api.github.com/repos/druid-io/druid/issues/2424/comments"},"review_comments":{"href":"https://api.github.com/repos/druid-io/druid/pulls/2424/comments"},"review_comment":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/druid-io/druid/pulls/2424/commits"},"statuses":{"href":"https://api.github.com/repos/druid-io/druid/statuses/2fbc8208fd40453b3a700d07ac718065373896bd"}}}}