-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add config to disable pull queries when validation is required #3879
Conversation
c1cec2c
to
4b91f21
Compare
Perf out of box (Kafka does not have ACLs)
|
With validation turned on in Kafka Pull queries fail
Failure is swift
Has no spurious clients allocated and push queries work
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @vinothchandar! LGTM +1 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vinothchandar,
Pull queries are supported by the websocket endpoint, WSQueryEndpoint
, so that class will need similar changes put in place.
I'm a little nervous of approving this PR for two main reasons:
- All the more functional tests, (
CliTest
,RestQueryTranslationTest
,PullQueryFunctionalTest
,RestApiTest
etc), have been switched over to set this 'skip validation' config to true. This feels very wrong. Where's the test testing our normal / recommended path? - It looks like this PR disables pull queries for any KSQL server running against a secured Kafka cluster, e.g. one secured with ACLs or some custom auth mech, i.e. it disabled pull queries for anyone using KSQL in a modern production environment. Is this really what we want? I guess we're releasing this as a preview and we can look to quickly iterate and remove this restriction. But just wanted to call this out and make sure this is indeed our intent with this PR.
ksql-common/src/main/java/io/confluent/ksql/util/KsqlConfig.java
Outdated
Show resolved
Hide resolved
ksql-common/src/main/java/io/confluent/ksql/util/KsqlConfig.java
Outdated
Show resolved
Hide resolved
ksql-functional-tests/src/test/java/io/confluent/ksql/test/rest/RestTestExecutor.java
Show resolved
Hide resolved
...p/src/main/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResource.java
Outdated
Show resolved
Hide resolved
...p/src/main/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResource.java
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Outdated
Show resolved
Hide resolved
...est-app/src/main/java/io/confluent/ksql/rest/server/resources/streaming/WSQueryEndpoint.java
Outdated
Show resolved
Hide resolved
"ksql.query.pull.skip.access.validator"; | ||
public static final boolean KSQL_PULL_QUERIES_SKIP_ACCESS_VALIDATOR_DEFAULT = false; | ||
public static final String KSQL_PULL_QUERIES_SKIP_ACCESS_VALIDATOR_DOC = "If true, KSQL will " | ||
+ " NOT enforce access validation checks for pull queries, which could expose Kafka topics" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validation checks
here is a bit vague. Can we be more explicit? This is really about skips authorization checks
. The docs and the name of this config should reflect this.
I think the actual functionality is that with this set to the default false
KSQL won't support pull queries when running against a secure Kafka. With it set to true
KSQL won't check the user has access to the topics underlying the the materialized state the pull query is accessing.
Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just matched it to the config above. I think this is okay, since these aspects are explained in the other config anyway.
This is accurate. The main worry is if someone runs a pull query benchmark against a production cluster, the current mechanism could actually destabilize the cluster due to its design. IMO the reputations damage due to that could be worse that having the feature be opt in with the risks understood. @derekjn is on board with this. cc @MichaelDrogalis for visibility in case he missed the other threads . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a note on the WebSocket endpoint.
This feels very wrong. Where's the test testing our normal / recommended path?
For pull queries, the normal path is to have them working no? I made the test changes so the existing functional tests can keep testing functionality when pull queries are enabled. and added tests to ensure the error is thrown when validating and we get past it when not validating. I feel this is adequate.
It looks like this PR disables pull queries for any KSQL server running against a secured Kafka cluster,
+1 to apurva's comment. Unfortunately, this is the suggested way forward and we can undo this quickly in the next release.
"ksql.query.pull.skip.access.validator"; | ||
public static final boolean KSQL_PULL_QUERIES_SKIP_ACCESS_VALIDATOR_DEFAULT = false; | ||
public static final String KSQL_PULL_QUERIES_SKIP_ACCESS_VALIDATOR_DOC = "If true, KSQL will " | ||
+ " NOT enforce access validation checks for pull queries, which could expose Kafka topics" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just matched it to the config above. I think this is okay, since these aspects are explained in the other config anyway.
ksql-common/src/main/java/io/confluent/ksql/util/KsqlConfig.java
Outdated
Show resolved
Hide resolved
ksql-common/src/main/java/io/confluent/ksql/util/KsqlConfig.java
Outdated
Show resolved
Hide resolved
ksql-functional-tests/src/test/java/io/confluent/ksql/test/rest/RestTestExecutor.java
Show resolved
Hide resolved
...p/src/main/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResource.java
Show resolved
Hide resolved
...est-app/src/main/java/io/confluent/ksql/rest/server/resources/streaming/WSQueryEndpoint.java
Outdated
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Outdated
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Outdated
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Show resolved
Hide resolved
fixes confluentinc#3863 - Added `ksql.query.pull.skip.access.validator` to control if pull queries work without validation - By default, Pull queries error out, if auth validation is needed - Replaced DUMMY_VALIDATOR with Optional<> interface for KsqlAuthorizationValidatorFactory - Fixed some tests, added test cases
3739c25
to
9741725
Compare
LGTM 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - summarizing my thoughts on the main points:
- I think our test coverage is OK. Our "supported" way to run KSQL queries on secure kafka clusters is to accept the security risk in the meantime - this is what we test. We also test that the default behavior on secure clusters is to fail pull queries. Together I feel our coverage is sufficient, especially considering a long-term fix is already in the works
- I feel that we should secure the WebSocket API in the same way. Better safe than have the bad rep of the WebSocket API taking down Kafka clusters.
Not sure I like changing it to optional instead of a dummy class and just having the config logic in there, but I'm not opinionated enough to block you 😂
...p/src/main/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResource.java
Show resolved
Hide resolved
...est-app/src/main/java/io/confluent/ksql/rest/server/resources/streaming/WSQueryEndpoint.java
Outdated
Show resolved
Hide resolved
…c#3879) fixes confluentinc#3863 - Added `ksql.query.pull.skip.access.validator` to control if pull queries work without validation - By default, Pull queries error out, if auth validation is needed - Replaced DUMMY_VALIDATOR with Optional<> interface for KsqlAuthorizationValidatorFactory - Fixed some tests, added test cases - Applied on both `query` and websocket endpoints
…sters (#3980) * refactor: lazy initialization of clients (admin,sr,ksql,connect) (#3696) - Made client creation lazy by memoizing them. * feat: add config to disable pull queries when validating (#3879) fixes #3863 - Added `ksql.query.pull.skip.access.validator` to control if pull queries work without validation - By default, Pull queries error out, if auth validation is needed - Replaced DUMMY_VALIDATOR with Optional<> interface for KsqlAuthorizationValidatorFactory - Fixed some tests, added test cases - Applied on both `query` and websocket endpoints
fixes #3863
Description
ksql.query.pull.skip.access.validator
to control if pull queries work without validationTesting done
Reviewer checklist