picodexter / PcdxParameterEncryptionBundle

A Symfony bundle that allows you to encrypt and decrypt parameters
MIT License
1 stars 0 forks source link

Symfony3 - Parameters not being decrypted #2

Closed sverraest closed 6 years ago

sverraest commented 6 years ago

I've successfully installed the bundle, added the configuration, added the bundle to AppKernel and added the encrypted values, using the cli, to the parameters.yml file.

During database connections to Doctrine at no point are the parameters.yml parameters decrypted. A failing attempt to connect with the encrypted parameters is happening.

If I just use the normal plain text parameters it works which makes me believe the decryption is not actually called.

Do you need to enabled this bundle in any other way?

picodexter commented 6 years ago

Did you try decrypting the value by executing the reverse command?

php bin/console pcdx-parameter-encryption:decrypt <algorithm_id>

That way you can make sure that the application is properly loading all the algorithms including the key settings.

If that works, then I would check if you used the correct pattern to make the bundle recognize an encrypted value. An example in the documentation was the following algorithm:

pcdx_parameter_encryption:
    algorithms:
        -   id: 'caesar_rot13'
            pattern:
                type: 'value_prefix'
                arguments:
                    -   '=#!PPE!c:r13!#='
            encryption:
                service: 'pcdx_parameter_encryption.encryption.encrypter.caesar.rot13'
                key: '%parameter_encryption.caesar.rot13.key%'
            decryption:
                service: 'pcdx_parameter_encryption.encryption.decrypter.caesar.rot13'
                key: '%parameter_encryption.caesar.rot13.key%'

so in that case the encrypted parameter would have to look as follows:

parameters:
    [...]
    my_encrypted_parameter: '=#!PPE!c:r13!#=ciphertext'

with ciphertext being the encrypted value.

If this doesn't work, are you using environment variables in combination with the encrypted parameter by any chance?

sverraest commented 6 years ago

It was indeed the missing prefix before the cipher text. Thanks!