-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Issue 8382][Pulsar Function] Enable e2e encryption for Pulsar Function #8432
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
[Issue 8382][Pulsar Function] Enable e2e encryption for Pulsar Function #8432
Conversation
pulsar-common/src/main/java/org/apache/pulsar/common/functions/CryptoConfig.java
Outdated
Show resolved
Hide resolved
...s/java-examples/src/main/java/org/apache/pulsar/functions/api/examples/RawFileKeyReader.java
Show resolved
Hide resolved
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/CryptoUtils.java
Show resolved
Hide resolved
| DISCARD = 1; | ||
| CONSUME = 2; | ||
|
|
||
| SEND = 10; |
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.
Why the SEND command value is 10, Is there any special meaning here? We still reserve the middle value?
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.
Reserve some single digit values just in case there're new actions added for the consumer failure.
Logically it's more clear. FAIL or 0 is the default behavior; 1~9 is for consumer; 10 and above is for producer.
...s/java-examples/src/main/java/org/apache/pulsar/functions/api/examples/RawFileKeyReader.java
Show resolved
Hide resolved
|
ping @sijie @srkukarni Could you please help review this PR? |
|
@nlu90 great contribution! |
…on (apache#8432) Fixes apache#8382 ### Motivation Add the e2e encryption support for Pulsar Functions ### Modifications - Add `CryptoConfig` the encapsulate all the crypto related configs set by user - Add `CryptoSpec` to `Function` protobuf to container crypto information internally - Add `CryptoUtils` to help create instance, convert between `CryptoConfig` and `CryptoSpec` - Add crypto validation method in `ValidatorUtils` to ensure the provided `CryptoKeyReader` Class has a ctor with `Map` arg - Updated the cli to allow user set crypto for consumer/producer when submitting the function - Update `PulsarSource`, `PulsarSink` to use the crypto config if provided ### Verifying this change - [x] Make sure that the change passes the CI checks.
|
Doc has been added in https://github.com/apache/pulsar/pull/8648/files |
(If this PR fixes a github issue, please add
Fixes #<xyz>.)Fixes #8382
Motivation
Add the e2e encryption support for Pulsar Functions
Modifications
CryptoConfigthe encapsulate all the crypto related configs set by userCryptoSpectoFunctionprotobuf to container crypto information internallyCryptoUtilsto help create instance, convert betweenCryptoConfigandCryptoSpecValidatorUtilsto ensure the providedCryptoKeyReaderClass has a ctor withMapargPulsarSource,PulsarSinkto use the crypto config if providedVerifying this change
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changespulsar-client-messagecrypto-bcintopuslar-function instance--producer-configto allow setting crypto related configs.Documentation
Now user can enable e2e encryption as follows:
./bin/pulsar-admin functions create --jar pulsar-functions/java-examples/target/pulsar-functions-api-examples.jar \ --classname org.apache.pulsar.functions.api.examples.ExclamationFunction \ --input-specs '{"persistent://public/default/output": {"cryptoConfig": {"cryptoKeyReaderClassName": "org.apache.pulsar.functions.api.examples.RawFileKeyReader", "cryptoKeyReaderConfig": {"PUBLIC": "/Users/nlu/workspace/stream-native/pulsar/keys/test_ecdsa_pubkey.pem", "PRIVATE":"/Users/nlu/workspace/stream-native/pulsar/keys/test_ecdsa_privkey_2.pem"}, "consumerCryptoFailureAction": "FAIL"}}}' \ --output persistent://public/default/output-2One requirement is the provided
cryptoKeyReaderClassmust has a constructor withMap<String, Object>parameter for initialization. And the argument is provided viacryptoKeyReaderConfigin the cli