Skip to content

Instantly share code, notes, and snippets.

@juliettegodyere
Created April 13, 2024 18:43
Show Gist options
  • Save juliettegodyere/3b263d16942bb3cfe3fb66307a02715f to your computer and use it in GitHub Desktop.
Save juliettegodyere/3b263d16942bb3cfe3fb66307a02715f to your computer and use it in GitHub Desktop.
Secure Configuration Management with Spring Cloud Config Server
## I've implemented a Microservice architecture where I've leveraged Spring Cloud Config Server for managing externalized configurations. To ensure the security of sensitive data, I needed a solution for encrypting and decrypting configurations before storing them on GitHub. Fortunately, Spring Cloud Config Server offers robust encryption and decryption capabilities out of the box.
Here's how I implemented encryption using the Symmetric key method:
Generated a 32-character alphanumeric encryption key.
Added the encryption key to my configServer-service application.properties file:
`encrypt.key = ${ENCRYPT_KEY}`
Note: ${ENCRYPT_KEY} references the value stored in the 'ENCRYPT_KEY' environmental variable.
Encrypted sensitive data using the command:
`curl localhost:8888/encrypt -d 'my-sensitive-password`
Updated my Microservices configurations stored on GitHub using the Config Server to include:
`spring.datasource.password={cipher}encrypted-value`
For detailed guidance, I found the following resources invaluable:
https://medium.com/@karthi32.mail/spring-cloud-config-server-encryption-and-decryption-using-git-repository-d8d1a7a1e6eb
https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_encryption_and_decryption
https://www.youtube.com/watch?v=FRrcewwT6bY
These references provided comprehensive insights into effectively managing secure configurations with Spring Cloud Config Server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment