Skip to content

Commit

Permalink
Add SecretManager in anticipation of other secret managers (fix)
Browse files Browse the repository at this point in the history
Add SecretManager in anticipation of other secret managers
  • Loading branch information
chris9692 authored Jan 26, 2022
2 parents 7925f1a + 44d1950 commit dd11b69
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.linkedin.cdi.keys.ExtractorKeys;
import com.linkedin.cdi.keys.JobKeys;
import com.linkedin.cdi.keys.JsonExtractorKeys;
import com.linkedin.cdi.util.EncryptionUtils;
import com.linkedin.cdi.util.JsonUtils;
import com.linkedin.cdi.util.ParameterTypes;
import com.linkedin.cdi.util.SchemaBuilder;
Expand Down Expand Up @@ -552,7 +553,7 @@ private JsonObject encryptJsonFields(String parentKey, JsonElement input) {
// this function assumes that the final value to be encrypted will always be a JsonPrimitive object and in case of
// of JsonObject it will iterate recursively.
if (value.isJsonPrimitive() && encryptionFields.contains(new JsonPrimitive(absoluteKey))) {
String valStr = SecretManager.getInstance(state).encrypt(value.isJsonNull() ? "" : value.getAsString());
String valStr = EncryptionUtils.encryptGobblin(value.isJsonNull() ? "" : value.getAsString(), state);
output.add(key, new JsonPrimitive(valStr));
} else if (value.isJsonObject()) {
output.add(key, encryptJsonFields(absoluteKey, value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private JsonObject selectFieldsFromGenericRecord(GenericRecord record, List<Stri
if (valueObject == null || fieldType == Schema.Type.NULL) {
jsonObject.add(field, JsonNull.INSTANCE);
} else if (fieldType == Schema.Type.STRING) {
jsonObject.addProperty(field, SecretManager.getInstance(state).decrypt(valueObject.toString()));
jsonObject.addProperty(field, EncryptionUtils.decryptGobblin(valueObject.toString(), state));
} else if (fieldType == Schema.Type.ARRAY) {
jsonObject.add(field, gson.fromJson(valueObject.toString(), JsonArray.class));
} else if (fieldType == Schema.Type.RECORD) {
Expand Down
5 changes: 1 addition & 4 deletions docs/parameters/ms.secret.manager.class.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@

## Description

`ms.secret.manager.class` specifies the SecretManager class to use for secrets
and confidential data encryption and decryption.
`ms.secret.manager.class` specifies the SecretManager class to use for secrets encryption and decryption.

Secrets include usernames, passwords, API keys, tokens, etc, that are essential for connections to other
data systems.

Confidential data include dataset columns that require encryption on storage.

Currently, we have the following SecretManager:

- `com.linkedin.cdi.util.GobblinSecretManager`
Expand Down
2 changes: 1 addition & 1 deletion docs/parameters/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ the primary inputs of job execution, which is its metadata, i.e, job configurati
## [ms.secret.manager.class](ms.secret.manager.class.md)

`ms.secret.manager.class` specifies the SecretManager class to use for secrets
and confidential data encryption and decryption.
encryption and decryption.

## [ms.session.key.field](ms.session.key.field.md)

Expand Down

0 comments on commit dd11b69

Please sign in to comment.