You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/06/26 16:49:07 UTC
[GitHub] [druid] suneet-s opened a new pull request #10085: Filter http requests by http method
suneet-s opened a new pull request #10085:
URL: https://github.com/apache/druid/pull/10085
### Description
Add a config that allows a user which http methods to allow against their
Druid server.
Druid will only accept http requests with the method: GET, PUT, POST, DELETE
and OPTIONS.
If a Druid admin wants to allow other methods, they can do so by using the
ServerConfig#allowedHttpMethods config.
If a Druid user would like to disallow OPTIONS, this can be done by changing
the AuthConfig#allowUnauthenticatedHttpOptions config
<hr>
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [x] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [x] been tested in a test Druid cluster.
<hr>
##### Key changed/added classes in this PR
* `AllowHttpMethodsResourceFilter`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] gianm commented on a change in pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
gianm commented on a change in pull request #10085:
URL: https://github.com/apache/druid/pull/10085#discussion_r447164011
##########
File path: server/src/test/java/org/apache/druid/initialization/ServerConfigTest.java
##########
@@ -51,13 +54,27 @@ public void testSerde() throws Exception
defaultConfig.getUnannouncePropagationDelay(),
defaultConfig.getInflateBufferSize(),
defaultConfig.getCompressionLevel(),
- true
+ true,
+ ImmutableList.of("OPTIONS")
Review comment:
Very small nit: `HttpMethod.OPTIONS` is better than the bare string.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suneet-s commented on a change in pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
suneet-s commented on a change in pull request #10085:
URL: https://github.com/apache/druid/pull/10085#discussion_r446450982
##########
File path: docs/configuration/index.md
##########
@@ -1312,6 +1312,7 @@ Druid uses Jetty to serve HTTP requests.
|`druid.server.http.maxQueryTimeout`|Maximum allowed value (in milliseconds) for `timeout` parameter. See [query-context](../querying/query-context.html) to know more about `timeout`. Query is rejected if the query context `timeout` is greater than this value. |Long.MAX_VALUE|
|`druid.server.http.maxRequestHeaderSize`|Maximum size of a request header in bytes. Larger headers consume more memory and can make a server more vulnerable to denial of service attacks.|8 * 1024|
|`druid.server.http.enableForwardedRequestCustomizer`|If enabled, adds Jetty ForwardedRequestCustomizer which reads X-Forwarded-* request headers to manipulate servlet request object when Druid is used behind a proxy.|false|
+|`druid.server.http.allowedHttpMethods`|List of http methods allowed in addition to the ones needed by Druid. GET, PUT, POST, DELETE and OPTIONS are always allowed. `druid.auth.allowUnauthenticatedHttpOptions` can be used to disable the OPTIONS method.|[]|
Review comment:
👍 thanks for the suggestion. Done.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] gianm commented on a change in pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
gianm commented on a change in pull request #10085:
URL: https://github.com/apache/druid/pull/10085#discussion_r447163351
##########
File path: server/src/main/java/org/apache/druid/server/security/AuthenticationUtils.java
##########
@@ -27,6 +27,16 @@
public class AuthenticationUtils
{
+ public static void addAllowHttpMethodsFilter(ServletContextHandler root, List<String> allowedHttpMethods)
Review comment:
This functionality isn't related to authentication. It would more properly belong in JettyServerInitUtils.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] gianm commented on pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
gianm commented on pull request #10085:
URL: https://github.com/apache/druid/pull/10085#issuecomment-651275412
> CI will fail because of missing code coverage for adding the filter to all the jetty services. The webconsole e2e test covers this, so would it be ok to overrule CI in this instance?
IMO it's best to deal with it somehow in this PR, rather than kicking the can down the road. I've run into an issue like this before too, where the tests for some druid-processing classes live in the druid-sql module, and the checker can't realize it. In my case I just added extra tests to the druid-processing module.
Some options that could work here:
- Add extra tests to the druid-services module.
- Add coverage suppressions for these files (https://github.com/apache/druid/blob/master/pom.xml#L1259) with a note like "these druid-services classes are tested by tests in the druid-XXX module(s)".
- Modify the coverage checker to unify coverage across all modules (this is ideal in general, but might be too much work to ask for in this particular PR).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] maytasm commented on a change in pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #10085:
URL: https://github.com/apache/druid/pull/10085#discussion_r446474691
##########
File path: web-console/script/druid
##########
@@ -73,10 +73,12 @@ function _build_distribution() {
_log "Building druid distribution"
(
+ # Add HEAD as an allowed HTTP method since this is how we check when the Druid service is ready.
Review comment:
Can't you do a GET on /status/health?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suneet-s commented on pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
suneet-s commented on pull request #10085:
URL: https://github.com/apache/druid/pull/10085#issuecomment-650461472
CI will fail because of missing code coverage for adding the filter to all the jetty services. The webconsole e2e test covers this, so would it be ok to overrule CI in this instance?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suneet-s commented on a change in pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
suneet-s commented on a change in pull request #10085:
URL: https://github.com/apache/druid/pull/10085#discussion_r446484168
##########
File path: web-console/script/druid
##########
@@ -73,10 +73,12 @@ function _build_distribution() {
_log "Building druid distribution"
(
+ # Add HEAD as an allowed HTTP method since this is how we check when the Druid service is ready.
Review comment:
I think this is checking to see if the web console is up. I'm not sure if a `GET /status/health` is equivalent. The nice side-benefit of this is I get an integration test for free 😇
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suneet-s commented on pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
suneet-s commented on pull request #10085:
URL: https://github.com/apache/druid/pull/10085#issuecomment-650490137
CI fails the 4 `other module tests` because of code-coverage. These functions are covered by integration tests in the security integration tests and the web console e2e tests to allow the OPTIONS and HEAD HTTP methods respectively.
```
Diff coverage statistics:
------------------------------------------------------------------------------
| lines | branches | functions | path
------------------------------------------------------------------------------
| 0% (0/1) | 100% (0/0) | 100% (0/0) | org/apache/druid/cli/CliOverlord.java
| 0% (0/1) | 100% (0/0) | 100% (1/1) | org/apache/druid/cli/MiddleManagerJettyServerInitializer.java
| 0% (0/1) | 100% (0/0) | 100% (1/1) | org/apache/druid/cli/CoordinatorJettyServerInitializer.java
| 0% (0/1) | 100% (0/0) | 0% (0/1) | org/apache/druid/cli/RouterJettyServerInitializer.java
| 0% (0/1) | 100% (0/0) | 100% (1/1) | org/apache/druid/cli/QueryJettyServerInitializer.java
------------------------------------------------------------------------------
Total diff coverage:
- lines: 0% (0/5)
- branches: 100% (0/0)
- functions: 75% (3/4)
ERROR: Insufficient line coverage of 0% (0/5). Required 50%.
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suneet-s commented on a change in pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
suneet-s commented on a change in pull request #10085:
URL: https://github.com/apache/druid/pull/10085#discussion_r447231614
##########
File path: server/src/test/java/org/apache/druid/initialization/ServerConfigTest.java
##########
@@ -51,13 +54,27 @@ public void testSerde() throws Exception
defaultConfig.getUnannouncePropagationDelay(),
defaultConfig.getInflateBufferSize(),
defaultConfig.getCompressionLevel(),
- true
+ true,
+ ImmutableList.of("OPTIONS")
Review comment:
Done
##########
File path: server/src/main/java/org/apache/druid/server/security/AuthenticationUtils.java
##########
@@ -27,6 +27,16 @@
public class AuthenticationUtils
{
+ public static void addAllowHttpMethodsFilter(ServletContextHandler root, List<String> allowedHttpMethods)
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] maytasm commented on a change in pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #10085:
URL: https://github.com/apache/druid/pull/10085#discussion_r446474691
##########
File path: web-console/script/druid
##########
@@ -73,10 +73,12 @@ function _build_distribution() {
_log "Building druid distribution"
(
+ # Add HEAD as an allowed HTTP method since this is how we check when the Druid service is ready.
Review comment:
nit (since not related to this PR): Can't you do a GET on /status/health?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suneet-s commented on pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
suneet-s commented on pull request #10085:
URL: https://github.com/apache/druid/pull/10085#issuecomment-650282399
integration test coming shortly
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suneet-s merged pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
suneet-s merged pull request #10085:
URL: https://github.com/apache/druid/pull/10085
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] gianm commented on a change in pull request #10085: Filter http requests by http method
Posted by GitBox <gi...@apache.org>.
gianm commented on a change in pull request #10085:
URL: https://github.com/apache/druid/pull/10085#discussion_r446305543
##########
File path: docs/configuration/index.md
##########
@@ -1312,6 +1312,7 @@ Druid uses Jetty to serve HTTP requests.
|`druid.server.http.maxQueryTimeout`|Maximum allowed value (in milliseconds) for `timeout` parameter. See [query-context](../querying/query-context.html) to know more about `timeout`. Query is rejected if the query context `timeout` is greater than this value. |Long.MAX_VALUE|
|`druid.server.http.maxRequestHeaderSize`|Maximum size of a request header in bytes. Larger headers consume more memory and can make a server more vulnerable to denial of service attacks.|8 * 1024|
|`druid.server.http.enableForwardedRequestCustomizer`|If enabled, adds Jetty ForwardedRequestCustomizer which reads X-Forwarded-* request headers to manipulate servlet request object when Druid is used behind a proxy.|false|
+|`druid.server.http.allowedHttpMethods`|List of http methods allowed in addition to the ones needed by Druid. GET, PUT, POST, DELETE and OPTIONS are always allowed. `druid.auth.allowUnauthenticatedHttpOptions` can be used to disable the OPTIONS method.|[]|
Review comment:
"HTTP" should be capitalized when it appears in normal text like this.
##########
File path: docs/configuration/index.md
##########
@@ -1312,6 +1312,7 @@ Druid uses Jetty to serve HTTP requests.
|`druid.server.http.maxQueryTimeout`|Maximum allowed value (in milliseconds) for `timeout` parameter. See [query-context](../querying/query-context.html) to know more about `timeout`. Query is rejected if the query context `timeout` is greater than this value. |Long.MAX_VALUE|
|`druid.server.http.maxRequestHeaderSize`|Maximum size of a request header in bytes. Larger headers consume more memory and can make a server more vulnerable to denial of service attacks.|8 * 1024|
|`druid.server.http.enableForwardedRequestCustomizer`|If enabled, adds Jetty ForwardedRequestCustomizer which reads X-Forwarded-* request headers to manipulate servlet request object when Druid is used behind a proxy.|false|
+|`druid.server.http.allowedHttpMethods`|List of http methods allowed in addition to the ones needed by Druid. GET, PUT, POST, DELETE and OPTIONS are always allowed. `druid.auth.allowUnauthenticatedHttpOptions` can be used to disable the OPTIONS method.|[]|
Review comment:
A couple things about the design of the properties:
1. I don't think Druid itself uses OPTIONS requests. AFAIK, they are only needed for people that are using CORS, which Druid doesn't support innately but can be supported through extensions: https://github.com/apache/druid/issues/6026. So, OPTIONS shouldn't be part of the "always allowed" list.
2. `druid.auth.allowUnauthenticatedHttpOptions` today can't be used to disable OPTIONS, it only controls whether or not it can be used without authentication.
Taking these into account, I'd suggest designing and documenting them like this:
|Property|Description|Default|
|--------|-----------|-------|
|`druid.server.http.allowedHttpMethods`|List of HTTP methods that should be allowed in addition to the ones required by Druid APIs. Druid APIs require GET, PUT, POST, and DELETE, which are always allowed. This option is not useful unless you have installed an extension that needs these additional HTTP methods or that adds functionality related to CORS. None of Druid's bundled extensions require these methods.|[]|
|`druid.auth.allowUnauthenticatedHttpOptions`|If true, allow HTTP OPTIONS requests by unauthenticated users. This is primarily useful for supporting CORS preflight requests, which Druid does not support directly, but which can be enabled using third-party extensions.<br /><br />Note that you must add "OPTIONS" to `druid.server.http.allowedHttpMethods`.<br /><br />Also note that disabling authentication checks for OPTIONS requests will allow unauthenticated users to determine what Druid endpoints are valid (by checking if the OPTIONS request returns a 200 instead of 404). Enabling this option will reveal information about server configuration, including information about what extensions are loaded, to unauthenticated users.|false|
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org