Skip to content

Implement plain text decryption. (spring-cloud#865)#1417

Closed
sstiglitz wants to merge 1 commit intospring-cloud:masterfrom
sstiglitz:rebase-for-publish
Closed

Implement plain text decryption. (spring-cloud#865)#1417
sstiglitz wants to merge 1 commit intospring-cloud:masterfrom
sstiglitz:rebase-for-publish

Conversation

@sstiglitz
Copy link
Copy Markdown
Contributor

What does this PR do?

This implements the feature request made in GH-865. It adds support to decrypt properties being served as plain text through the ResourcesController. Only JSON, YAML, and Properties file extensions are
supported.

Design considerations.

  • On/off of this feature is through setting both spring.cloud.config.server.encrypt.enabled (existing setting) and spring.cloud.config.server.encrypt.plainTextEncrypt (entirely new setting) to true. By default, plainTextEncrypt is false. This is to ensure backwards compatibility and not break existing users which may be expecting encrypted values. The dual enable is a little clunky to me, but couldn't think of a better way given existing features. spring.cloud.config.server.encrypt.enabled set to false is supposed to turn of decryption entirely so a dependency on this setting seemed right to not break the contract. Please let me know your thoughts.

  • Notice I say file extensions above. Not file types. For example, a file with a ".json" extension is assumed to be JSON. If it's just text, the system will end up throwing an error due to not being able to parse JSON. I figured a proper file type check was unnecessary given the precedent already being set within EnvironmentController and this being a system-to-system application targeted at developers/operations who can be trusted to maintain consistency between file extensions and file types.

  • If a file extension is unsupported, but this new feature is enabled, the unencrypted file will be served and WARN log event will trigger. I see-saw'ed over throwing an exception, but that didn't seem right as a person may want decrypted values when supported, but the untouched file when unsupported. I wasn't sure about the log event either as it might fill up log files on a busy server. Doing nothing at all seems like an equally okay option, but please let me know your thoughts.

  • There is a new dependency to handle YAML parsing. It's using a Jackson YAML module. SnakeYml has similar parsing capabilities, but using Jackson offered good code reuse in an environment already using Jackson, so this seemed like a better choice.

This implements the feature request made in GH-865. It adds support to
decrypt properties being served as plain text through the
ResourcesController. Only JSON, YAML, and Properties file extensions are
supported.

Add unit tests around the new feature.

Add documentation for the new feature.
@pivotal-issuemaster
Copy link
Copy Markdown

@sstiglitz Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link
Copy Markdown

@sstiglitz Thank you for signing the Contributor License Agreement!

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 3, 2019

Codecov Report

Merging #1417 into master will increase coverage by 0.31%.
The diff coverage is 83.14%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #1417      +/-   ##
===========================================
+ Coverage     78.19%   78.5%   +0.31%     
- Complexity     1028    1055      +27     
===========================================
  Files           126     131       +5     
  Lines          3697    3783      +86     
  Branches        522     531       +9     
===========================================
+ Hits           2891    2970      +79     
- Misses          625     630       +5     
- Partials        181     183       +2
Impacted Files Coverage Δ Complexity Δ
...g/server/config/ConfigServerAutoConfiguration.java 100% <ø> (ø) 1 <0> (ø) ⬇️
.../server/config/ResourceEncryptorConfiguration.java 0% <0%> (ø) 0 <0> (?)
...ig/server/config/ConfigServerMvcConfiguration.java 100% <100%> (ø) 5 <0> (ø) ⬇️
...oud/config/server/resource/ResourceController.java 85.5% <100%> (+0.6%) 26 <4> (+6) ⬆️
...er/encryption/AbstractCipherResourceEncryptor.java 100% <100%> (ø) 7 <7> (?)
...d/config/server/config/ConfigServerProperties.java 60.97% <50%> (+4.21%) 11 <0> (+1) ⬆️
...server/encryption/CipherResourceYamlEncryptor.java 85.71% <85.71%> (ø) 3 <3> (?)
...server/encryption/CipherResourceJsonEncryptor.java 85.71% <85.71%> (ø) 3 <3> (?)
.../encryption/CipherResourcePropertiesEncryptor.java 94.73% <94.73%> (ø) 6 <6> (?)
... and 9 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 f24f023...c7df36e. Read the comment docs.

3 similar comments
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 3, 2019

Codecov Report

Merging #1417 into master will increase coverage by 0.31%.
The diff coverage is 83.14%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #1417      +/-   ##
===========================================
+ Coverage     78.19%   78.5%   +0.31%     
- Complexity     1028    1055      +27     
===========================================
  Files           126     131       +5     
  Lines          3697    3783      +86     
  Branches        522     531       +9     
===========================================
+ Hits           2891    2970      +79     
- Misses          625     630       +5     
- Partials        181     183       +2
Impacted Files Coverage Δ Complexity Δ
...g/server/config/ConfigServerAutoConfiguration.java 100% <ø> (ø) 1 <0> (ø) ⬇️
.../server/config/ResourceEncryptorConfiguration.java 0% <0%> (ø) 0 <0> (?)
...ig/server/config/ConfigServerMvcConfiguration.java 100% <100%> (ø) 5 <0> (ø) ⬇️
...oud/config/server/resource/ResourceController.java 85.5% <100%> (+0.6%) 26 <4> (+6) ⬆️
...er/encryption/AbstractCipherResourceEncryptor.java 100% <100%> (ø) 7 <7> (?)
...d/config/server/config/ConfigServerProperties.java 60.97% <50%> (+4.21%) 11 <0> (+1) ⬆️
...server/encryption/CipherResourceYamlEncryptor.java 85.71% <85.71%> (ø) 3 <3> (?)
...server/encryption/CipherResourceJsonEncryptor.java 85.71% <85.71%> (ø) 3 <3> (?)
.../encryption/CipherResourcePropertiesEncryptor.java 94.73% <94.73%> (ø) 6 <6> (?)
... and 9 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 f24f023...c7df36e. Read the comment docs.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 3, 2019

Codecov Report

Merging #1417 into master will increase coverage by 0.31%.
The diff coverage is 83.14%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #1417      +/-   ##
===========================================
+ Coverage     78.19%   78.5%   +0.31%     
- Complexity     1028    1055      +27     
===========================================
  Files           126     131       +5     
  Lines          3697    3783      +86     
  Branches        522     531       +9     
===========================================
+ Hits           2891    2970      +79     
- Misses          625     630       +5     
- Partials        181     183       +2
Impacted Files Coverage Δ Complexity Δ
...g/server/config/ConfigServerAutoConfiguration.java 100% <ø> (ø) 1 <0> (ø) ⬇️
.../server/config/ResourceEncryptorConfiguration.java 0% <0%> (ø) 0 <0> (?)
...ig/server/config/ConfigServerMvcConfiguration.java 100% <100%> (ø) 5 <0> (ø) ⬇️
...oud/config/server/resource/ResourceController.java 85.5% <100%> (+0.6%) 26 <4> (+6) ⬆️
...er/encryption/AbstractCipherResourceEncryptor.java 100% <100%> (ø) 7 <7> (?)
...d/config/server/config/ConfigServerProperties.java 60.97% <50%> (+4.21%) 11 <0> (+1) ⬆️
...server/encryption/CipherResourceYamlEncryptor.java 85.71% <85.71%> (ø) 3 <3> (?)
...server/encryption/CipherResourceJsonEncryptor.java 85.71% <85.71%> (ø) 3 <3> (?)
.../encryption/CipherResourcePropertiesEncryptor.java 94.73% <94.73%> (ø) 6 <6> (?)
... and 9 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 f24f023...c7df36e. Read the comment docs.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 3, 2019

Codecov Report

Merging #1417 into master will increase coverage by 0.31%.
The diff coverage is 83.14%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #1417      +/-   ##
===========================================
+ Coverage     78.19%   78.5%   +0.31%     
- Complexity     1028    1055      +27     
===========================================
  Files           126     131       +5     
  Lines          3697    3783      +86     
  Branches        522     531       +9     
===========================================
+ Hits           2891    2970      +79     
- Misses          625     630       +5     
- Partials        181     183       +2
Impacted Files Coverage Δ Complexity Δ
...g/server/config/ConfigServerAutoConfiguration.java 100% <ø> (ø) 1 <0> (ø) ⬇️
.../server/config/ResourceEncryptorConfiguration.java 0% <0%> (ø) 0 <0> (?)
...ig/server/config/ConfigServerMvcConfiguration.java 100% <100%> (ø) 5 <0> (ø) ⬇️
...oud/config/server/resource/ResourceController.java 85.5% <100%> (+0.6%) 26 <4> (+6) ⬆️
...er/encryption/AbstractCipherResourceEncryptor.java 100% <100%> (ø) 7 <7> (?)
...d/config/server/config/ConfigServerProperties.java 60.97% <50%> (+4.21%) 11 <0> (+1) ⬆️
...server/encryption/CipherResourceYamlEncryptor.java 85.71% <85.71%> (ø) 3 <3> (?)
...server/encryption/CipherResourceJsonEncryptor.java 85.71% <85.71%> (ø) 3 <3> (?)
.../encryption/CipherResourcePropertiesEncryptor.java 94.73% <94.73%> (ø) 6 <6> (?)
... and 9 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 f24f023...c7df36e. Read the comment docs.

Copy link
Copy Markdown
Contributor

@ryanjbaxter ryanjbaxter left a comment

Choose a reason for hiding this comment

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

Thanks! This looks pretty good to me!

@ryanjbaxter
Copy link
Copy Markdown
Contributor

@sstiglitz could you update the PR to resolve the merge conflicts?

@ryanjbaxter
Copy link
Copy Markdown
Contributor

ping @sstiglitz

@ryanjbaxter ryanjbaxter modified the milestones: 2.2.0.M2, 2.2.0.RC2 Oct 28, 2019
@ryanjbaxter
Copy link
Copy Markdown
Contributor

Closed via 8025d7d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants