Skip to content
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

Adding config for keystore types, switching tls to native implementation, and adding authorization for server-broker tls channel #7653

Merged

Conversation

jasperjiaguo
Copy link
Contributor

@jasperjiaguo jasperjiaguo commented Oct 27, 2021

Description

  1. Add missing functionality for netty tls truststore/keystore type, so that JKS/PKCS12 keystore can load properly.
  2. Switch TLS to native implementation (https://netty.io/wiki/forked-tomcat-native.html). Native method brings less overhead for encryption/decryption.
  3. Add authorization endpoint for broker-server netty tls channel. The authorization is performed on server side after handshake completion of the broker-server channel, which can be used for server to check broker's certificate.

We have validated the functionalities of above changes internally using production data and queries.

Upgrade Notes

Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
No

Does this PR fix a zero-downtime upgrade introduced earlier?
No

Does this PR otherwise need attention when creating release notes? Things to consider:
Yes

Release Notes

  1. Moved org.apache.pinot.server.api.access.AllowAllAccessFactory to org.apache.pinot.server.access.AllowAllAccessFactory
    important Note that if your current installation explicitly configured access control factory to use org.apache.pinot.server.api.access.AllowAllAccessFactory, please change it to org.apache.pinot.server.access.AllowAllAccessFactory.

  2. Adding the following configs so that keystore/truststore of different types(JKS/PKCS12/...) can load properly

    pinot-controller
    controller.tls.keystore.type
    controller.tls.truststore.type
    pinot-broker
    pinot.broker.tls.keystore.type
    pinot.broker.tls.truststore.type
    pinot-server
    pinot.server.tls.keystore.type
    pinot.server.tls.truststore.type

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2021

Codecov Report

Merging #7653 (1a603e4) into master (c594796) will decrease coverage by 6.41%.
The diff coverage is 13.04%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #7653      +/-   ##
============================================
- Coverage     71.47%   65.06%   -6.42%     
+ Complexity     4033     4029       -4     
============================================
  Files          1581     1536      -45     
  Lines         80419    78634    -1785     
  Branches      11950    11752     -198     
============================================
- Hits          57483    51160    -6323     
- Misses        19049    23815    +4766     
+ Partials       3887     3659     -228     
Flag Coverage Δ
integration1 ?
integration2 ?
unittests1 68.52% <13.04%> (-0.11%) ⬇️
unittests2 14.57% <0.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rg/apache/pinot/core/transport/ServerChannels.java 75.47% <0.00%> (-16.84%) ⬇️
...ava/org/apache/pinot/core/transport/TlsConfig.java 3.84% <0.00%> (-78.51%) ⬇️
...main/java/org/apache/pinot/core/util/TlsUtils.java 0.00% <0.00%> (-72.47%) ⬇️
...che/pinot/server/access/AllowAllAccessFactory.java 80.00% <0.00%> (ø)
...apache/pinot/spi/ingestion/batch/spec/TlsSpec.java 0.00% <0.00%> (ø)
...va/org/apache/pinot/spi/utils/CommonConstants.java 26.31% <ø> (ø)
...e/pinot/core/transport/InstanceRequestHandler.java 56.96% <37.50%> (-4.15%) ⬇️
...a/org/apache/pinot/core/transport/QueryServer.java 53.19% <50.00%> (-17.27%) ⬇️
...a/org/apache/pinot/common/metrics/MinionMeter.java 0.00% <0.00%> (-100.00%) ⬇️
...g/apache/pinot/common/metrics/ControllerMeter.java 0.00% <0.00%> (-100.00%) ⬇️
... and 372 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c594796...1a603e4. Read the comment docs.

Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apucher Can you please take a look at this PR?

@@ -73,8 +73,7 @@ public boolean isRetriable() {
}
}

public static class PinotException
extends RuntimeException {
public static class PinotException extends RuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Copy link
Contributor

@apucher apucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jasperjiaguo, very much appreciate contributions on pinot security.

I have some initial questions, and I'd appreciate if you could provide some additional context.

Also, would you mind adding a unit test for different keystore formats, or blank values for your new tls property?

@@ -16,13 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.pinot.server.api.access;
package org.apache.pinot.server.access;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like it could cause serious breakage to existing pinot installations, since access control is a string-configured property with fully-qualified class name

Copy link
Contributor Author

@jasperjiaguo jasperjiaguo Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apucher In BaseServerStarter we have
String accessControlFactoryClass = _serverConf.getProperty(Server.ACCESS_CONTROL_FACTORY_CLASS, Server.DEFAULT_ACCESS_CONTROL_FACTORY_CLASS);
where I have changed DEFAULT_ACCESS_CONTROL_FACTORY_CLASS to org.apache.pinot.server.access.AllowAllAccessFactory, and left ACCESS_CONTROL_FACTORY_CLASS unchanged (pinot.server.admin.access.control.factory.class).
So if the current installation is using default (not configuring pinot.server.admin.access.control.factory.class) or configuring it to customized class there should be no problem.

IIUC, the only case that will cause problem is someone explicitly configured pinot.server.admin.access.control.factory.class to org.apache.pinot.server.api.access.AllowAllAccessFactory. Do you know any use case configured in this way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least, I would specifically call this out in the PR's release notes.

I'm aware of at least one installation that explicitly sets AllowAll... as part of startup scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, added in the release notes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we changing the package names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We moved the access control classes from pinot-server to pinot-core since they are used in QueryServer of pinot-core to enable broker-server channel authorization. There will be circular dependency if we don't change the package name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

@jasperjiaguo jasperjiaguo force-pushed the tls_config_read_netty_native_auth branch from 32d1130 to 4c27b9c Compare November 3, 2021 00:43
@jasperjiaguo jasperjiaguo requested a review from apucher November 3, 2021 01:02
@siddharthteotia
Copy link
Contributor

@apucher , can you please take a look again. Would like to get this merged if no more comments

@jasperjiaguo jasperjiaguo force-pushed the tls_config_read_netty_native_auth branch from cb1ad17 to 96dc8ab Compare November 5, 2021 20:20
Copy link
Contributor

@apucher apucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates.

Would you mind still adding the unit test for a different keystore type?
It doesn't just serve robustness but similarly as documentation for future developers.

Additionally, I'm not completely clear on how the application layer auth for broker and server would look like. Is this cert- or token-based? Here, too, a minimal unit test could help guide future generations

@apucher
Copy link
Contributor

apucher commented Nov 5, 2021

you could probably add to BasicAuthTlsRealtimeIntegrationTest to cover this

@jasperjiaguo jasperjiaguo force-pushed the tls_config_read_netty_native_auth branch 2 times, most recently from 0c5fd26 to 7230b67 Compare November 8, 2021 07:57
@kishoreg
Copy link
Member

kishoreg commented Nov 8, 2021

Its not clear why we are changing the package name for AllowAllAccessFactory

@jasperjiaguo
Copy link
Contributor Author

jasperjiaguo commented Nov 8, 2021

Its not clear why we are changing the package name for AllowAllAccessFactory

Hello @kishoreg, we moved the access control classes from pinot-server to pinot-core since they are used in QueryServer of pinot-core to enable broker-server channel authorization. There will be circular dependency if we don't change the package name.

@jasperjiaguo
Copy link
Contributor Author

jasperjiaguo commented Nov 9, 2021

Thank you for the updates.

Would you mind still adding the unit test for a different keystore type? It doesn't just serve robustness but similarly as documentation for future developers.

The test for the keystore type is done. I renamed the original tlstest.jks to tlstes.p12 as it is internally a P12 keystore. I think now JAVA uses PKCS12 instead of JKS for default keystore type. Generated a new JKS keystore for robustness test.

The authZ is cert based and it extracts X509 cert from the ChannelHandlerContext in userEventTriggered

@jasperjiaguo jasperjiaguo force-pushed the tls_config_read_netty_native_auth branch 2 times, most recently from c852378 to 33a391e Compare November 11, 2021 20:16
…tomcat-native.html)

2. Add access control for broker-server netty tls channel
3. Add missing functionality for netty tls truststore/keystore types
4. Fix a few issues, add config for ssl provider, remove the key existence check for fields having default values
5. Fix keystore naming, add keystore test for JKS
6. Adding test case for server AccessControl
@jasperjiaguo jasperjiaguo force-pushed the tls_config_read_netty_native_auth branch from b16f950 to 2d0c907 Compare November 11, 2021 20:31
@jasperjiaguo jasperjiaguo requested a review from apucher November 12, 2021 00:23
Copy link
Contributor

@apucher apucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good from my side. thank you for adding the cert auth sample. this should make extending this easier for future generations.

@kishoreg @Jackie-Jiang anything still open from your side?

@siddharthteotia siddharthteotia merged commit 4b2d31b into apache:master Nov 12, 2021
kriti-sc pushed a commit to kriti-sc/incubator-pinot that referenced this pull request Dec 12, 2021
…tomcat-native.html) (apache#7653)

2. Add access control for broker-server netty tls channel
3. Add missing functionality for netty tls truststore/keystore types
4. Fix a few issues, add config for ssl provider, remove the key existence check for fields having default values
5. Fix keystore naming, add keystore test for JKS
6. Adding test case for server AccessControl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants