-
Notifications
You must be signed in to change notification settings - Fork 1.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
Add support for deriving json schema for encrypted properties. #3801
Conversation
ee323a5
to
c297688
Compare
@@ -0,0 +1,112 @@ | |||
/* | |||
* Copyright 2021. the original author or authors. |
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.
Nit:
Copyright 2021 the original author or authors.
(there's a dot after 2021)
@@ -145,4 +150,10 @@ public void setAutoIndexCreation(boolean autoCreateIndexes) { | |||
|
|||
return new UnwrappedMongoPersistentEntity<>(entity, new UnwrapEntityContext(persistentProperty)); | |||
} | |||
|
|||
@Nullable | |||
public ApplicationContext getApplicationContext() { |
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.
This doesn't seem seem to be necessary as we do not have any callers to getApplicationContext()
@Encrypted(keyId = "xKVup8B1Q+CkHaVRx+qa+g==", algorithm = "AEAD_AES_256_CBC_HMAC_SHA_512-Random") <1> | ||
static class Patient { | ||
|
||
@Id String id; |
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.
Nit: Indent
|
||
[TIP] | ||
==== | ||
The `@Encrypted` Annoation supports resolving keyIds via SpEL Expressions. |
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.
s/Annoation/annotation
@Encrypted(keyId = "#{mongocrypt.keyId(#target)}") | ||
static class Patient { | ||
|
||
@Id String id; |
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.
Nit: Indent
|
||
// ... keyVaultCollection, kmsProvider, ... | ||
|
||
MongoJsonSchemaCreator schemaCreator = MongoJsonSchemaCreator.create(mappingContext); |
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.
Nit: Indent
This commit introduces support for creating a MongoJsonSchema containing encrypted fields for a given type based on mapping metadata. Using the Encrypted annotation allows to derive required encryptMetadata and encrypt properties within a given (mapping)context. @document @Encrypted(keyId = "...") static class Patient { // ... @Encrypted(algorithm = "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic") private Integer ssn; } MongoJsonSchemaCreator schemaCreator = MongoJsonSchemaCreator.create(mappingContext); MongoJsonSchema patientSchema = schemaCreator .filter(MongoJsonSchemaCreator.encryptedOnly()) .createSchemaFor(Patient.class);
c297688
to
95d9e67
Compare
This commit introduces support for creating a MongoJsonSchema containing encrypted fields for a given type based on mapping metadata. Using the Encrypted annotation allows to derive required encryptMetadata and encrypt properties within a given (mapping)context. @document @Encrypted(keyId = "...") static class Patient { // ... @Encrypted(algorithm = "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic") private Integer ssn; } MongoJsonSchemaCreator schemaCreator = MongoJsonSchemaCreator.create(mappingContext); MongoJsonSchema patientSchema = schemaCreator .filter(MongoJsonSchemaCreator.encryptedOnly()) .createSchemaFor(Patient.class); Closes: #3800 Original pull request: #3801.
That's merged now |
Closes: #3800