druid/extensions-contrib
Jihoon Son 73ce5df22d
Add support for authorizing query context params (#12396)
The query context is a way that the user gives a hint to the Druid query engine, so that they enforce a certain behavior or at least let the query engine prefer a certain plan during query planning. Today, there are 3 types of query context params as below.

Default context params. They are set via druid.query.default.context in runtime properties. Any user context params can be default params.
User context params. They are set in the user query request. See https://druid.apache.org/docs/latest/querying/query-context.html for parameters.
System context params. They are set by the Druid query engine during query processing. These params override other context params.
Today, any context params are allowed to users. This can cause 
1) a bad UX if the context param is not matured yet or 
2) even query failure or system fault in the worst case if a sensitive param is abused, ex) maxSubqueryRows.

This PR adds an ability to limit context params per user role. That means, a query will fail if you have a context param set in the query that is not allowed to you. To do that, this PR adds a new built-in resource type, QUERY_CONTEXT. The resource to authorize has a name of the context param (such as maxSubqueryRows) and the type of QUERY_CONTEXT. To allow a certain context param for a user, the user should be granted WRITE permission on the context param resource. Here is an example of the permission.

{
  "resourceAction" : {
    "resource" : {
      "name" : "maxSubqueryRows",
      "type" : "QUERY_CONTEXT"
    },
    "action" : "WRITE"
  },
  "resourceNamePattern" : "maxSubqueryRows"
}
Each role can have multiple permissions for context params. Each permission should be set for different context params.

When a query is issued with a query context X, the query will fail if the user who issued the query does not have WRITE permission on the query context X. In this case,

HTTP endpoints will return 403 response code.
JDBC will throw ForbiddenException.
Note: there is a context param called brokerService that is used only by the router. This param is used to pin your query to run it in a specific broker. Because the authorization is done not in the router, but in the broker, if you have brokerService set in your query without a proper permission, your query will fail in the broker after routing is done. Technically, this is not right because the authorization is checked after the context param takes effect. However, this should not cause any user-facing issue and thus should be OK. The query will still fail if the user doesn’t have permission for brokerService.

The context param authorization can be enabled using druid.auth.authorizeQueryContextParams. This is disabled by default to avoid any hassle when someone upgrades his cluster blindly without reading release notes.
2022-04-21 14:21:16 +05:30
..
aliyun-oss-extensions Lazy instantiation for segmentKillers, segmentMovers, and segmentArchivers (#12207) 2022-02-08 13:02:06 -08:00
ambari-metrics-emitter Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
cassandra-storage Migrate File.mkdirs to FileUtils.mkdirp. (#11879) 2021-11-09 11:10:49 -08:00
cloudfiles-extensions Migrate File.mkdirs to FileUtils.mkdirp. (#11879) 2021-11-09 11:10:49 -08:00
distinctcount Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
dropwizard-emitter Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
gce-extensions bump version to 0.23.0-SNAPSHOT (#11670) 2021-09-08 15:56:04 -07:00
graphite-emitter Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
influx-extensions A new includeAllDimension flag for dimensionsSpec (#12276) 2022-02-25 18:27:48 -08:00
influxdb-emitter Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
kafka-emitter Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
materialized-view-maintenance A new includeAllDimension flag for dimensionsSpec (#12276) 2022-02-25 18:27:48 -08:00
materialized-view-selection Add support for authorizing query context params (#12396) 2022-04-21 14:21:16 +05:30
momentsketch Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
moving-average-query Refactor ResponseContext (#11828) 2021-12-06 17:03:12 -08:00
opentelemetry-emitter Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
opentsdb-emitter Add more metrics for Jetty server thread pool usage (#11113) 2021-11-07 16:51:44 +05:30
prometheus-emitter Added support in urls, and grouped metrics (#12296) 2022-03-22 11:22:05 -07:00
redis-cache bump version to 0.23.0-SNAPSHOT (#11670) 2021-09-08 15:56:04 -07:00
sqlserver-metadata-storage bump version to 0.23.0-SNAPSHOT (#11670) 2021-09-08 15:56:04 -07:00
statsd-emitter Bump java-dogstatsd-client from 2.13.0 to 4.0.0 (#12353) 2022-03-26 16:25:13 -07:00
tdigestsketch allow optimizing sql expressions and virtual columns (#12241) 2022-02-09 14:55:50 -08:00
thrift-extensions upgrade Error Prone to 2.11 (requires Java 11) (#12306) 2022-03-14 19:40:48 -07:00
time-min-max restore and deprecate AggregatorFactory methods (#11917) 2021-11-19 15:59:35 -08:00
virtual-columns Reduce use of mocking and simplify some tests (#12283) 2022-02-26 17:23:09 -08:00
README.md fix broken links (#9537) 2020-03-22 17:41:18 -07:00

README.md

Community Extensions

Please contribute all community extensions in this directory and include a doc of how your extension can be used under docs/development/extensions-contrib/.

Please note that community extensions are maintained by their original contributors and are not packaged with the core Druid distribution. If you'd like to take on maintenance for a community extension, please post on dev@druid.apache.org to let us know!