Support for basic column Data Encryption with Object

One more news and reason to use Objects :) 

From Liferay 7.4 U80 it was implemented the option for encryption on the Object field.

A functionality to be able to encrypt specific object fields, it will prevent someone with the direct access to the database from viewing the sensitive information.

To be able to use the Object’s Encrypted field, firstly you'll need to add the encryption key in portal-ext.properties  or as a Environment Variable (please see the important properties highlighted below with the example values):

 

##
## Object
##

    #
    # Env: LIFERAY_OBJECT_PERIOD_ENCRYPTION_PERIOD_ALGORITHM
    #
    object.encryption.algorithm=AES

    #
    # Env: LIFERAY_OBJECT_PERIOD_ENCRYPTION_PERIOD_ENABLED
    #
    object.encryption.enabled=true

    #
    # Env: LIFERAY_OBJECT_PERIOD_ENCRYPTION_PERIOD_KEY
    # generated key as bytes -> enconded as base64
    #
    object.encryption.key=Um9zZWxhaW5lTWFycXVlcw==

 

Note I:  about the above configuration, the algorithm used is the AES as the liferay default, but you could configure another one.
Note II: For the encryption key, make sure you are encoded as base64 with the key size configured on company.encryption.key.size property (by default is 128, that means your key to be encoded should have 16 characters). You can use this site https://www.base64encode.org/ or execute in a Mac or Linux the following command to encode $ echo -n 'RoselaineMarques' | base64 (for sure replacing my name to your key lol ).

 

After applied the configuration above, just restart your portal and you will be able to create a encrypted field in your Object:


 

Creating a new record entry you can see the field encrypted in the Database:

 

In the Headless API or UI the data is decrypted as you can see below:



          .... And that's it! Hope this new feature helps you to store your sensitive data \o/  .....