You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often you need to have passwords (for databases, third-party services, etc.) as part of your configuration. These are typically environment specific (see above). However, with DevOps and continuous-deployment you might be tempted to commit such configurations into your version-control (e.g. `git`). Doing that with plain text passwords is a severe problem especially for production systems. Never do that! Instead we offer some suggestions how to deal with sensible configurations:
157
158
158
159
=== Password Encryption
159
160
A simple but reasonable approach is to configure the passwords encrypted with a master-password. The master-password should be a strong secret that is specific for each environment. It must never be committed to version-control.
160
-
In order to support encrypted passwords in spring-boot `application.properties` all you need to do is to add https://github.com/ulisesbocchio/jasypt-spring-boot#jasypt-spring-boot[jasypt-spring-boot] as dependency in your `pom.xml`(please check for recent version link:https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter[here]):
161
+
In order to support encrypted passwords in spring-boot `application.properties` all you need to do is to add https://github.com/ulisesbocchio/jasypt-spring-boot#jasypt-spring-boot[jasypt-spring-boot] as dependency in your `pom.xml`(please check for recent version link:https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter[here]):
161
162
[source, xml]
162
163
----
163
164
<dependency>
@@ -166,83 +167,56 @@ In order to support encrypted passwords in spring-boot `application.properties`
166
167
<version>3.0.3</version>
167
168
</dependency>
168
169
----
169
-
This will smoothly integrate http://jasypt.org/[jasypt] into your https://projects.spring.io/spring-boot/[spring-boot] application. Read this https://apereo.atlassian.net/wiki/spaces/CASUM/pages/103261428/HOWTO+Use+Jasypt+to+encrypt+passwords+in+configuration+files[HOWTO] to learn how to encrypt and decrypt passwords using jasypt. Here is a simple example output of an encrypted password (of course you have to use strong passwords instead of `secret` and `postgres` - this is only an example):
170
+
This will smoothly integrate http://jasypt.org/[jasypt] into your https://projects.spring.io/spring-boot/[spring-boot] application. Read this https://apereo.atlassian.net/wiki/spaces/CASUM/pages/103261428/HOWTO+Use+Jasypt+to+encrypt+passwords+in+configuration+files[HOWTO] to learn how to encrypt and decrypt passwords using jasypt.
170
171
172
+
Here we give a simple example how to encypt and configure a secret value. Different algorithms can be used if perferred (e.g. `PBEWITHMD5ANDTRIPLEDES`). However, the default in jasypt is `PBEWITHHMACSHA512ANDAES_256` that provides strong encryption.
Of course the master-password (`masterpassword`) and the actual password to encrypt (`secret`) are just examples.
197
+
Please replace them with reasonable strong passwords for your environment.
198
+
There entire line after the `OUTPUT` block is your encrypted secret.
199
+
It even contains some random salt so that multiple encryption invocations with the same parameters (`ARGUMENTS`) will produce a different `OUTPUT`.
190
200
191
201
The master-password can be configured on your target environment via the property `jasypt.encryptor.password`. As system properties given on the command-line are visible in the process list, we recommend to use an `config/application.yml` file only for this purpose (as we recommended to use `application.properties` for regular configs):
192
202
```
193
203
jasypt:
194
204
encryptor:
195
-
password: «secret»
205
+
password: masterpassword
196
206
```
197
-
(of course you will replace `«secret»` with a strong password). In case you happen to have multiple apps on the same machine, you can symlink the `application.yml` from a central place.
198
-
Now you are able to put encrypted passwords into your `application.properties`
207
+
Again `masterpassword` is just an example that your replace with your actual master password.
208
+
Now you are able to put encrypted passwords into your `application.properties` and specify the algorithm.
This `application.properties` file can be version controlled (git-opts) and without knowing the masterpassword nobody is able to decrypt this to get the actual secret back.
202
214
203
-
To prevent jasypt to throw an exception in dev or test scenarios simply put this in your local config (`src/main/config/application.properties` and same for `test`, see above for details):
215
+
To prevent jasypt to throw an exception in dev or test scenarios you can simply put this in your local config (`src/main/config/application.properties` and same for `test`, see above for details):
204
216
```
205
217
jasypt.encryptor.password=none
206
218
```
207
219
208
-
==== Configure Algorithm
209
-
Algorithm can be configured for stronger encryption. Jasypt uses PBEWITHHMACSHA512ANDAES_256 as the Default encryption algorithm.
210
-
Algorithm can be configured through System, properties file, command line argumments, environment variable etc.
211
-
212
-
Here is an example on how to use different algorithm for encryption and decryption.
213
-
214
-
Use the below command to encrypt, specify the algorithm PBEWITHMD5ANDTRIPLEDES with master password "secret" and the string to be encrypted as "postgres"
For decryption, specify the algorithm in the "applicaiton.properties" file as shown here. Keep the master password in config/application.yaml as described above.
Other configurable properties can be found https://github.com/ulisesbocchio/jasypt-spring-boot#password-based-encryption-configuration[here]
243
-
244
-
AES is considered secure in available encryption algorithms, PBEWITHHMACSHA512ANDAES_256 as highest level, which is the default algorithm as on Jasypt version 1.9.3. Our recommendation is to use the default (PBEWITHHMACSHA512ANDAES_256), which means algorithm need not be specified.
245
-
246
220
==== Is this Security by Obscurity?
247
221
248
222
* Yes, from the point of view to protect the passwords on the target environment this is nothing but security by obscurity. If an attacker somehow got full access to the machine this will only cause him to spend some more time.
0 commit comments