{"action":"created","comment":{"url":"https://api.github.com/repos/druid-io/druid/pulls/comments/155904312","pull_request_review_id":82306677,"id":155904312,"diff_hunk":"@@ -0,0 +1,187 @@\n+/*\n+ * Licensed to Metamarkets Group Inc. (Metamarkets) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. Metamarkets licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package io.druid.security.basic;\n+\n+import com.fasterxml.jackson.databind.Module;\n+import com.fasterxml.jackson.databind.module.SimpleModule;\n+import com.google.common.collect.ImmutableList;\n+import com.google.inject.Binder;\n+import com.google.inject.Injector;\n+import com.google.inject.Key;\n+import com.google.inject.Provides;\n+import com.google.inject.name.Names;\n+import io.druid.guice.Jerseys;\n+import io.druid.guice.JsonConfigProvider;\n+import io.druid.guice.LazySingleton;\n+import io.druid.guice.LifecycleModule;\n+import io.druid.initialization.DruidModule;\n+import io.druid.security.basic.authentication.BasicHTTPAuthenticator;\n+import io.druid.security.basic.authentication.BasicHTTPEscalator;\n+import io.druid.security.basic.authentication.db.cache.BasicAuthenticatorCacheManager;\n+import io.druid.security.basic.authentication.db.cache.BasicAuthenticatorCacheNotifier;\n+import io.druid.security.basic.authentication.db.cache.CoordinatorBasicAuthenticatorCacheManager;\n+import io.druid.security.basic.authentication.db.cache.CoordinatorBasicAuthenticatorCacheNotifier;\n+import io.druid.security.basic.authentication.db.cache.DefaultBasicAuthenticatorCacheManager;\n+import io.druid.security.basic.authentication.db.cache.NoopBasicAuthenticatorCacheNotifier;\n+import io.druid.security.basic.authentication.db.updater.BasicAuthenticatorMetadataStorageUpdater;\n+import io.druid.security.basic.authentication.db.updater.CoordinatorBasicAuthenticatorMetadataStorageUpdater;\n+import io.druid.security.basic.authentication.db.updater.NoopBasicAuthenticatorMetadataStorageUpdater;\n+import io.druid.security.basic.authentication.endpoint.BasicAuthenticatorResource;\n+import io.druid.security.basic.authentication.endpoint.BasicAuthenticatorResourceHandler;\n+import io.druid.security.basic.authentication.endpoint.CoordinatorBasicAuthenticatorResourceHandler;\n+import io.druid.security.basic.authentication.endpoint.DefaultBasicAuthenticatorResourceHandler;\n+import io.druid.security.basic.authorization.BasicRoleBasedAuthorizer;\n+import io.druid.security.basic.authorization.db.cache.BasicAuthorizerCacheManager;\n+import io.druid.security.basic.authorization.db.cache.BasicAuthorizerCacheNotifier;\n+import io.druid.security.basic.authorization.db.cache.CoordinatorBasicAuthorizerCacheManager;\n+import io.druid.security.basic.authorization.db.cache.CoordinatorBasicAuthorizerCacheNotifier;\n+import io.druid.security.basic.authorization.db.cache.DefaultBasicAuthorizerCacheManager;\n+import io.druid.security.basic.authorization.db.cache.NoopBasicAuthorizerCacheNotifier;\n+import io.druid.security.basic.authorization.db.updater.BasicAuthorizerMetadataStorageUpdater;\n+import io.druid.security.basic.authorization.db.updater.CoordinatorBasicAuthorizerMetadataStorageUpdater;\n+import io.druid.security.basic.authorization.db.updater.NoopBasicAuthorizerMetadataStorageUpdater;\n+import io.druid.security.basic.authorization.endpoint.BasicAuthorizerResource;\n+import io.druid.security.basic.authorization.endpoint.BasicAuthorizerResourceHandler;\n+import io.druid.security.basic.authorization.endpoint.CoordinatorBasicAuthorizerResourceHandler;\n+import io.druid.security.basic.authorization.endpoint.DefaultBasicAuthorizerResourceHandler;\n+\n+import java.util.List;\n+\n+public class BasicSecurityDruidModule implements DruidModule\n+{\n+  @Override\n+  public void configure(Binder binder)\n+  {\n+    JsonConfigProvider.bind(binder, \"druid.auth.basic.common\", BasicAuthCommonCacheConfig.class);\n+\n+    LifecycleModule.register(binder, BasicAuthenticatorMetadataStorageUpdater.class);\n+    LifecycleModule.register(binder, BasicAuthorizerMetadataStorageUpdater.class);\n+    LifecycleModule.register(binder, BasicAuthenticatorCacheManager.class);\n+    LifecycleModule.register(binder, BasicAuthorizerCacheManager.class);\n+\n+    Jerseys.addResource(binder, BasicAuthenticatorResource.class);\n+    Jerseys.addResource(binder, BasicAuthorizerResource.class);\n+  }\n+\n+  @Provides @LazySingleton\n+  public static BasicAuthenticatorMetadataStorageUpdater createAuthenticatorStorageUpdater(final Injector injector)\n+  {\n+    if (isCoordinator(injector)) {\n+      return injector.getInstance(CoordinatorBasicAuthenticatorMetadataStorageUpdater.class);\n+    } else {\n+      return injector.getInstance(NoopBasicAuthenticatorMetadataStorageUpdater.class);","path":"extensions-core/druid-basic-security/src/main/java/io/druid/security/basic/BasicSecurityDruidModule.java","position":null,"original_position":89,"commit_id":"c937dc89d575ce0fe2104e75d846b9e766c4489d","original_commit_id":"ac419d3d953f2b708981474cda06471e64b29d52","user":{"login":"jon-wei","id":8729063,"avatar_url":"https://avatars3.githubusercontent.com/u/8729063?v=4","gravatar_id":"","url":"https://api.github.com/users/jon-wei","html_url":"https://github.com/jon-wei","followers_url":"https://api.github.com/users/jon-wei/followers","following_url":"https://api.github.com/users/jon-wei/following{/other_user}","gists_url":"https://api.github.com/users/jon-wei/gists{/gist_id}","starred_url":"https://api.github.com/users/jon-wei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jon-wei/subscriptions","organizations_url":"https://api.github.com/users/jon-wei/orgs","repos_url":"https://api.github.com/users/jon-wei/repos","events_url":"https://api.github.com/users/jon-wei/events{/privacy}","received_events_url":"https://api.github.com/users/jon-wei/received_events","type":"User","site_admin":false},"body":"It's not, I have this return null now","created_at":"2017-12-09T00:25:12Z","updated_at":"2017-12-09T00:25:12Z","html_url":"https://github.com/druid-io/druid/pull/5099#discussion_r155904312","pull_request_url":"https://api.github.com/repos/druid-io/druid/pulls/5099","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments/155904312"},"html":{"href":"https://github.com/druid-io/druid/pull/5099#discussion_r155904312"},"pull_request":{"href":"https://api.github.com/repos/druid-io/druid/pulls/5099"}},"in_reply_to_id":155148440},"pull_request":{"url":"https://api.github.com/repos/druid-io/druid/pulls/5099","id":153200120,"html_url":"https://github.com/druid-io/druid/pull/5099","diff_url":"https://github.com/druid-io/druid/pull/5099.diff","patch_url":"https://github.com/druid-io/druid/pull/5099.patch","issue_url":"https://api.github.com/repos/druid-io/druid/issues/5099","number":5099,"state":"open","locked":false,"title":"Basic auth extension","user":{"login":"jon-wei","id":8729063,"avatar_url":"https://avatars3.githubusercontent.com/u/8729063?v=4","gravatar_id":"","url":"https://api.github.com/users/jon-wei","html_url":"https://github.com/jon-wei","followers_url":"https://api.github.com/users/jon-wei/followers","following_url":"https://api.github.com/users/jon-wei/following{/other_user}","gists_url":"https://api.github.com/users/jon-wei/gists{/gist_id}","starred_url":"https://api.github.com/users/jon-wei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jon-wei/subscriptions","organizations_url":"https://api.github.com/users/jon-wei/orgs","repos_url":"https://api.github.com/users/jon-wei/repos","events_url":"https://api.github.com/users/jon-wei/events{/privacy}","received_events_url":"https://api.github.com/users/jon-wei/received_events","type":"User","site_admin":false},"body":"This PR adds an extension that provides implementations of the auth interfaces introduced in #4271 :\r\n- an Authenticator which supports HTTP Basic authentication\r\n- an Escalator which supports HTTP Basic authentication\r\n- an Authorizer which implements basic role-based access control\r\n\r\nWith the large amount of changes (almost a rewrite) from the last round of PR reviews on #4823, I felt like it would be easier to close the old PR and start a fresh one.\r\n\r\nSome design notes:\r\n- The user/role information is stored in the metadata store, using the \"druid_config\" table as a key-value store, user/role maps are stored as serialized byte arrays\r\n- On the coordinator a *MetadataStorageUpdater class is responsible for handling writes to the user/role DB and holds a deserialized cached copy of the latest DB state\r\n- Each node has a *CacheManager instance that polls the coordinator for the latest DB state periodically, this also syncs the auth DB state at startup time\r\n- The coordinator can also notify and push updates to remote nodes, using the *CacheNotifier classes\r\n- The BasicHTTPAuthenticator and BasicRoleBasedAuthorizer perform their checks using cached info from the *CacheManager instance, to avoid overloading the coordinator\r\n- The coordinator nodes have a jersey resource for configuring the auth DB, which also holds the endpoint that nodes poll to get the latest DB state\r\n- A jersey resource is also installed on non-coordinator nodes, containing an endpoint that listens for DB state updates\r\n","created_at":"2017-11-17T02:20:32Z","updated_at":"2017-12-09T00:25:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8b410f5748914d8a475ff7964b20a3fbe8c1d86a","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/druid-io/druid/pulls/5099/commits","review_comments_url":"https://api.github.com/repos/druid-io/druid/pulls/5099/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/5099/comments","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/c937dc89d575ce0fe2104e75d846b9e766c4489d","head":{"label":"jon-wei:new_basic_sec2","ref":"new_basic_sec2","sha":"c937dc89d575ce0fe2104e75d846b9e766c4489d","user":{"login":"jon-wei","id":8729063,"avatar_url":"https://avatars3.githubusercontent.com/u/8729063?v=4","gravatar_id":"","url":"https://api.github.com/users/jon-wei","html_url":"https://github.com/jon-wei","followers_url":"https://api.github.com/users/jon-wei/followers","following_url":"https://api.github.com/users/jon-wei/following{/other_user}","gists_url":"https://api.github.com/users/jon-wei/gists{/gist_id}","starred_url":"https://api.github.com/users/jon-wei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jon-wei/subscriptions","organizations_url":"https://api.github.com/users/jon-wei/orgs","repos_url":"https://api.github.com/users/jon-wei/repos","events_url":"https://api.github.com/users/jon-wei/events{/privacy}","received_events_url":"https://api.github.com/users/jon-wei/received_events","type":"User","site_admin":false},"repo":{"id":41450391,"name":"druid","full_name":"jon-wei/druid","owner":{"login":"jon-wei","id":8729063,"avatar_url":"https://avatars3.githubusercontent.com/u/8729063?v=4","gravatar_id":"","url":"https://api.github.com/users/jon-wei","html_url":"https://github.com/jon-wei","followers_url":"https://api.github.com/users/jon-wei/followers","following_url":"https://api.github.com/users/jon-wei/following{/other_user}","gists_url":"https://api.github.com/users/jon-wei/gists{/gist_id}","starred_url":"https://api.github.com/users/jon-wei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jon-wei/subscriptions","organizations_url":"https://api.github.com/users/jon-wei/orgs","repos_url":"https://api.github.com/users/jon-wei/repos","events_url":"https://api.github.com/users/jon-wei/events{/privacy}","received_events_url":"https://api.github.com/users/jon-wei/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jon-wei/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":true,"url":"https://api.github.com/repos/jon-wei/druid","forks_url":"https://api.github.com/repos/jon-wei/druid/forks","keys_url":"https://api.github.com/repos/jon-wei/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jon-wei/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jon-wei/druid/teams","hooks_url":"https://api.github.com/repos/jon-wei/druid/hooks","issue_events_url":"https://api.github.com/repos/jon-wei/druid/issues/events{/number}","events_url":"https://api.github.com/repos/jon-wei/druid/events","assignees_url":"https://api.github.com/repos/jon-wei/druid/assignees{/user}","branches_url":"https://api.github.com/repos/jon-wei/druid/branches{/branch}","tags_url":"https://api.github.com/repos/jon-wei/druid/tags","blobs_url":"https://api.github.com/repos/jon-wei/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jon-wei/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jon-wei/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/jon-wei/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jon-wei/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/jon-wei/druid/languages","stargazers_url":"https://api.github.com/repos/jon-wei/druid/stargazers","contributors_url":"https://api.github.com/repos/jon-wei/druid/contributors","subscribers_url":"https://api.github.com/repos/jon-wei/druid/subscribers","subscription_url":"https://api.github.com/repos/jon-wei/druid/subscription","commits_url":"https://api.github.com/repos/jon-wei/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/jon-wei/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/jon-wei/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/jon-wei/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/jon-wei/druid/contents/{+path}","compare_url":"https://api.github.com/repos/jon-wei/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jon-wei/druid/merges","archive_url":"https://api.github.com/repos/jon-wei/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jon-wei/druid/downloads","issues_url":"https://api.github.com/repos/jon-wei/druid/issues{/number}","pulls_url":"https://api.github.com/repos/jon-wei/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/jon-wei/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/jon-wei/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jon-wei/druid/labels{/name}","releases_url":"https://api.github.com/repos/jon-wei/druid/releases{/id}","deployments_url":"https://api.github.com/repos/jon-wei/druid/deployments","created_at":"2015-08-26T21:18:05Z","updated_at":"2016-01-12T02:23:00Z","pushed_at":"2017-12-09T00:08:14Z","git_url":"git://github.com/jon-wei/druid.git","ssh_url":"git@github.com:jon-wei/druid.git","clone_url":"https://github.com/jon-wei/druid.git","svn_url":"https://github.com/jon-wei/druid","homepage":"http://druid.io","size":130348,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"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":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"druid-io:master","ref":"master","sha":"4f5e2b45496559815078d5e61b4dab718a56672f","user":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars0.githubusercontent.com/u/4203474?v=4","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://avatars0.githubusercontent.com/u/4203474?v=4","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":"2017-12-08T12:21:10Z","pushed_at":"2017-12-09T00:08:15Z","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":131464,"stargazers_count":5807,"watchers_count":5807,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1418,"mirror_url":null,"archived":false,"open_issues_count":857,"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":1418,"open_issues":857,"watchers":5807,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/5099"},"html":{"href":"https://github.com/druid-io/druid/pull/5099"},"issue":{"href":"https://api.github.com/repos/druid-io/druid/issues/5099"},"comments":{"href":"https://api.github.com/repos/druid-io/druid/issues/5099/comments"},"review_comments":{"href":"https://api.github.com/repos/druid-io/druid/pulls/5099/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/5099/commits"},"statuses":{"href":"https://api.github.com/repos/druid-io/druid/statuses/c937dc89d575ce0fe2104e75d846b9e766c4489d"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jon-wei"}}