Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.1-beta1
-
Component/s: Configuration
-
Labels:None
-
Environment:This is in all environments where one has a password to connect to a database.
Description
In Datasource.groovy, the password field is 'clear text'. This is not acceptible in our company, and would prevent our company (Citigroup) from using Grails. The suggestion is to do what we now do in the Jrun configuration file.
This is to supply the encrypted password, plus the name of a java class that is used to decrypt the password.
I'm including here the description of how this works. This is just a suggestion - if Graeme et al has a better way, that's all the better.
Here is the description of how this now works in Jrun which can be used as a model:
AES Encryption
Jrun comes with a Java class that provides AES encryption named JRunCrypterForTwofish. This implements the AES Encyrption technique known as TwoFish, and is a sophisticated and powerful algorthim that complies with Citigroup encryption standards. In order to encrypt the password, enter this command:
java jrun.security.JRunCrypterForTwofish thisword
Then plug in the encryption lines n the jrun-resources.xml file:
<password>8F89EBB13AC7C0840F2C623CFBB284D8</password>
<encrypted>true</encrypted>
<encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
3DES Encryption
3DES is another very advanced encryption standard. Jrun does not come with a Java class that automaically provides this type of encryption. However there are many Java classes that provide this standard, either in the public domain or available for purchase. The two steps are the same: using the class to encrypt the password, and then specifying in jrun-resources.xml the encrypted password and the name of the class to be used.
First use the java class that provides 3DES Encryption to encrypt the password. Then specify the encrypted password and the class as follows in jrun-resources.xml:
<password>ENCRYPTEDPASSWORD</password>
<encrypted>true</encrypted>
<encryption-class>java.class.that.provides.3DES.security</encryption-class>
So in DataSource.groovy you can now specify an encrypted password as follows:
dataSource { username = "foo" password = "438uodf9s872398783r" passwordEncryptionCodec="my.company.encryption.BlowfishCodec" }You need to provide an implementation by specifying the paswordEncryptionCodec property. The class specified basically needs to implement two methods, encode and decode. For example below is a sample implementation:
with this class you can also generate a key by running the main method. Note the password here is hard coded, this is only a sample impl. If you are happy with this implementation then please close the issue.
dataSource { username = "foo" password = "438uodf9s872398783r" passwordEncryptionCodec="my.company.encryption.BlowfishCodec" }