mogilvie / EncryptBundle

Encryption bundle
89 stars 29 forks source link

Identifier "default" as connection name is mandatory? #38

Closed Felsfungus closed 1 year ago

Felsfungus commented 1 year ago

Hey,

i installed version v2.0.1 of EncryptBundle and i'm getting the following error message:

!!    The Doctrine connection "default" referenced in service "SpecShaper\Encrypt  
!!    Bundle\Subscribers\DoctrineEncryptSubscriberInterface" does not exist. Avai  
!!    lable connections names: ..., ..., ...

I do not have a connection named "default" for reasons. Can i configure the bundle in any way not to use the connection named "default"? In my doctrine.yaml i configured the default connection this way:

doctrine:
    dbal:
        default_connection: myconnection

When configuring a connection named "default" the error is gone, but i would like not to have a connection named "default".

Thank you for your work :-)

Felsfungus commented 1 year ago

After some debugging i found out, that the default connection is needed for installation, but we can override the connection by service configuration:

    \SpecShaper\EncryptBundle\Subscribers\DoctrineEncryptSubscriber:
        class: '%spec_shaper_encrypt.subscriber_class%'
        arguments:
            $annotationArray: '%spec_shaper_encrypt.annotation_classes%'
            $isDisabled: '%spec_shaper_encrypt.is_disabled%'
        tags:
            - { name: doctrine.event_subscriber, connection: api }

Is that the way i should go or is there a better way?

mogilvie commented 1 year ago

Rather than overriding the service definition in your own bundle, I would suggest we instead set a config parameter in the spec_shaper_encrypt.yaml, and set the definition during dependency injection. I also want to look at how i can enable the subscriber for multiple entity connections. I'm currently working on a multitenant application and need to apply this bundle to potentially hundreds of database connections. I'll keep your use case in mind.

Felsfungus commented 1 year ago

That sounds good to me and would make configuration better. Thank you :-)

If you think about configuration: I would like to ask how you would solve the problem, that there might be more than one entity manager with different connections that have different entities with some encrypted columns. Is there a way to solve that case?

mogilvie commented 1 year ago

Leave with me for the moment, I'm also rewriting for flex install at the same time.

Felsfungus commented 1 year ago

Sorry, don't want to annoy you :-). My case is solved for now, thank you for your response. I will keep on track for changes!

mogilvie commented 1 year ago

Dev-master now has config settings in config/spec_shaper_encrypt.yaml allowing you to define the connection name, and/or multiple connection names.