-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Client side S3EncryptionClient (#1033)
Introduce KMS with S3EncryptionClient
- Loading branch information
1 parent
29edb24
commit dc67ca3
Showing
18 changed files
with
545 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...oud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/s3/S3AesProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2013-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.awspring.cloud.autoconfigure.s3; | ||
|
||
import javax.crypto.SecretKey; | ||
|
||
/** | ||
* Interface for providing {@link SecretKey} when configuring {@link software.amazon.encryption.s3.S3EncryptionClient}. | ||
* Required when encrypting files server side with AES. Secret Key should be stored in secure storage, for example AWS | ||
* Secrets Manager. | ||
* @author Matej Nedic | ||
* @since 3.3.0 | ||
*/ | ||
public interface S3AesProvider { | ||
|
||
/** | ||
* Provides SecretKey that will be used to configure {@link software.amazon.encryption.s3.S3EncryptionClient}. | ||
* Advised to fetch and return SecretKey in this method from Secured Storage. | ||
* @return KeyPair that will be used for encryption/decryption. | ||
*/ | ||
SecretKey generateSecretKey(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...figure/src/main/java/io/awspring/cloud/autoconfigure/s3/S3EncryptionClientCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2013-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.awspring.cloud.autoconfigure.s3; | ||
|
||
import io.awspring.cloud.autoconfigure.AwsClientCustomizer; | ||
import software.amazon.encryption.s3.S3EncryptionClient; | ||
|
||
/** | ||
* Callback interface that can be used to customize a {@link S3EncryptionClient.Builder}. | ||
* | ||
* @author Matej Nedic | ||
* @since 3.3.0 | ||
*/ | ||
@FunctionalInterface | ||
public interface S3EncryptionClientCustomizer extends AwsClientCustomizer<S3EncryptionClient.Builder> { | ||
} |
44 changes: 44 additions & 0 deletions
44
...toconfigure/src/main/java/io/awspring/cloud/autoconfigure/s3/S3EncryptionConditional.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2013-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.awspring.cloud.autoconfigure.s3; | ||
|
||
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
|
||
/** | ||
* Conditional for creating {@link software.amazon.encryption.s3.S3EncryptionClient}. Will only create | ||
* S3EncryptionClient if one of following is true. | ||
* @author Matej Nedic | ||
* @since 3.3.0 | ||
*/ | ||
public class S3EncryptionConditional extends AnyNestedCondition { | ||
public S3EncryptionConditional() { | ||
super(ConfigurationPhase.REGISTER_BEAN); | ||
} | ||
|
||
@ConditionalOnBean(S3RsaProvider.class) | ||
static class RSAProviderCondition { | ||
} | ||
|
||
@ConditionalOnBean(S3AesProvider.class) | ||
static class AESProviderCondition { | ||
} | ||
|
||
@ConditionalOnProperty(name = "spring.cloud.aws.s3.encryption.keyId") | ||
static class KmsKeyProperty { | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...oud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/s3/S3RsaProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2013-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.awspring.cloud.autoconfigure.s3; | ||
|
||
import java.security.KeyPair; | ||
|
||
/** | ||
* Interface for providing {@link KeyPair} when configuring {@link software.amazon.encryption.s3.S3EncryptionClient}. | ||
* Required for encrypting/decrypting files server side with RSA. Key pair should be stored in secure storage, for | ||
* example AWS Secrets Manager. | ||
* @author Matej Nedic | ||
* @since 3.3.0 | ||
*/ | ||
public interface S3RsaProvider { | ||
|
||
/** | ||
* Provides KeyPair that will be used to configure {@link software.amazon.encryption.s3.S3EncryptionClient}. Advised | ||
* to fetch and return KeyPair in this method from Secured Storage. | ||
* @return KeyPair that will be used for encryption/decryption. | ||
*/ | ||
KeyPair generateKeyPair(); | ||
} |
Oops, something went wrong.