From bf29c7756f11b28a24fed5a3d6e934454fefe459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 3 Jul 2024 11:14:05 +0200 Subject: [PATCH] [wip] upgrade configuration to chill v3 (symfony 5) --- config/packages/cache_chill.yaml | 14 +++ config/packages/chill.yaml | 6 ++ config/packages/cruds.yaml | 88 ------------------- config/packages/dev/twig.yaml | 3 - config/packages/doctrine_migrations.yaml | 16 ---- .../packages/doctrine_migrations_chill.yaml | 20 +++++ config/packages/framework.yaml | 6 -- config/packages/framework_chill.yaml | 3 + config/packages/mailer_chill.yaml | 4 + config/packages/messenger.yaml | 8 -- config/packages/messenger_chill.yaml | 13 +++ config/packages/security.yaml | 67 +++----------- config/packages/security_chill.yaml | 50 +++++++++++ config/packages/test/.gitkeep | 0 config/packages/test/chill.yaml | 5 -- config/packages/test/security.yaml | 3 - config/packages/twig.yaml | 13 --- config/packages/twig_chill.yaml | 16 ++++ .../{workflow.yaml => workflow_chill.yaml} | 0 entrypoint.sh | 1 + 20 files changed, 137 insertions(+), 199 deletions(-) create mode 100644 config/packages/cache_chill.yaml delete mode 100644 config/packages/cruds.yaml delete mode 100644 config/packages/dev/twig.yaml create mode 100644 config/packages/doctrine_migrations_chill.yaml create mode 100644 config/packages/framework_chill.yaml create mode 100644 config/packages/mailer_chill.yaml create mode 100644 config/packages/messenger_chill.yaml create mode 100644 config/packages/security_chill.yaml create mode 100644 config/packages/test/.gitkeep delete mode 100644 config/packages/test/chill.yaml create mode 100644 config/packages/twig_chill.yaml rename config/packages/{workflow.yaml => workflow_chill.yaml} (100%) diff --git a/config/packages/cache_chill.yaml b/config/packages/cache_chill.yaml new file mode 100644 index 0000000..71877b6 --- /dev/null +++ b/config/packages/cache_chill.yaml @@ -0,0 +1,14 @@ +framework: + cache: + default_redis_provider: '%env(resolve:REDIS_URL)%' + pools: + cache.user_data: + adapter: cache.adapter.redis + public: true + default_lifetime: 300 # 5 minutes + + # will be used in chill_main.tag_aware_cache service + cache.tags: + adapter: cache.adapter.redis + public: false + default_lifetime: 300 diff --git a/config/packages/chill.yaml b/config/packages/chill.yaml index 6e41ee6..1cffa8d 100644 --- a/config/packages/chill.yaml +++ b/config/packages/chill.yaml @@ -27,6 +27,12 @@ chill_main: y: '%env(float:ADD_ADDRESS_MAP_CENTER_Y)%' z: '%env(float:ADD_ADDRESS_MAP_CENTER_Z)%' +when@test: + chill_main: + available_languages: + - 'fr' + - 'en' + chill_custom_fields: show_empty_values_in_views: false diff --git a/config/packages/cruds.yaml b/config/packages/cruds.yaml deleted file mode 100644 index e798dbd..0000000 --- a/config/packages/cruds.yaml +++ /dev/null @@ -1,88 +0,0 @@ -chill_main: - cruds: - - - class: 'App\Entity\VendeePerson' - controller: 'App\Controller\VendeePersonController' - name: vendeeperson - base_path: /vendee/vendeeperson - actions: - infosociopro_edit: - controller_action: 'infosocioproEdit' - path: '/{id}/infosociopro/edit' - role: CHILL_PERSON_EDIT - infosociopro_view: - controller_action: 'infosocioproView' - path: '/{id}/infosociopro/view' - role: CHILL_PERSON_VIEW - entourage_edit: - controller_action: 'entourageEdit' - path: '/{id}/entourage/edit' - role: CHILL_PERSON_EDIT - entourage_view: - controller_action: 'entourageView' - path: '/{id}/entourage/view' - role: CHILL_PERSON_VIEW - infomedicale_edit: - controller_action: 'infomedicaleEdit' - path: '/{id}/infomedicale/edit' - role: CHILL_PERSON_EDIT - infomedicale_view: - controller_action: 'infomedicaleView' - path: '/{id}/infomedicale/view' - role: CHILL_PERSON_VIEW - infologement_edit: - controller_action: 'infologementEdit' - path: '/{id}/infologement/edit' - role: CHILL_PERSON_EDIT - infologement_view: - controller_action: 'infologementView' - path: '/{id}/infologement/view' - role: CHILL_PERSON_VIEW - - - class: 'App\Entity\VendeePersonMineur' - controller: 'App\Controller\VendeePersonMineurController' - name: vendeepersonmineur - base_path: /vendee/vendeepersonmineur - actions: - infofamille_edit: - controller_action: 'infofamilleEdit' - path: '/{id}/infofamille/edit' - role: CHILL_PERSON_EDIT - infofamille_view: - controller_action: 'infofamilleView' - path: '/{id}/infofamille/view' - role: CHILL_PERSON_VIEW - scolarite_edit: - controller_action: 'scolariteEdit' - path: '/{id}/scolarite/edit' - role: CHILL_PERSON_EDIT - scolarite_view: - controller_action: 'scolariteView' - path: '/{id}/scolarite/view' - role: CHILL_PERSON_VIEW - infomedicale_edit: - controller_action: 'infomedicaleEdit' - path: '/{id}/infomedicale/edit' - role: CHILL_PERSON_EDIT - infomedicale_view: - controller_action: 'infomedicaleView' - path: '/{id}/infomedicale/view' - role: CHILL_PERSON_VIEW - - - class: 'App\Entity\Security\Profile' - name: vendee_security_profile - base_path: '/admin/vendee/security/profile' - base_role: ROLE_ADMIN - form_class: 'App\Form\Security\ProfileType' - controller: 'App\Controller\SecurityProfileController' - actions: - index: - template: '/Security/Profile/index.html.twig' - role: ROLE_ADMIN - new: - role: ROLE_ADMIN - template: '/Security/Profile/new.html.twig' - edit: - role: ROLE_ADMIN - template: '/Security/Profile/edit.html.twig' - diff --git a/config/packages/dev/twig.yaml b/config/packages/dev/twig.yaml deleted file mode 100644 index 97871a9..0000000 --- a/config/packages/dev/twig.yaml +++ /dev/null @@ -1,3 +0,0 @@ -twig: - globals: - responsive_debug: false diff --git a/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml index cfc56ba..6aa2000 100644 --- a/config/packages/doctrine_migrations.yaml +++ b/config/packages/doctrine_migrations.yaml @@ -2,25 +2,9 @@ doctrine_migrations: migrations_paths: # migrations for custom modules 'Application\Migrations': '%kernel.project_dir%/migrations' - # migrations for default chill modules - 'Chill\Migrations\Main': '@ChillMainBundle/migrations' - 'Chill\Migrations\Activity': '@ChillActivityBundle/migrations' - 'Chill\Migrations\DocStore': '@ChillDocStoreBundle/migrations' - 'Chill\Migrations\CustomFields': '@ChillCustomFieldsBundle/migrations' - 'Chill\Migrations\Event': '@ChillEventBundle/migrations' - 'Chill\Migrations\Person': '@ChillPersonBundle/migrations' - 'Chill\Migrations\Task': '@ChillTaskBundle/migrations' - 'Chill\Migrations\ThirdParty': '@ChillThirdPartyBundle/migrations' - 'Chill\Migrations\DocGenerator': '@ChillDocGeneratorBundle/migrations' - 'Chill\Migrations\AsideActivity': '@ChillAsideActivityBundle/migrations' - 'Chill\Migrations\Calendar': '@ChillCalendarBundle/migrations' - 'Chill\Migrations\Budget': '@ChillBudgetBundle/migrations' all_or_nothing: true - services: - 'Doctrine\Migrations\Version\Comparator': 'Chill\MainBundle\Doctrine\Migrations\VersionComparator' - storage: table_storage: table_name: 'migration_versions' diff --git a/config/packages/doctrine_migrations_chill.yaml b/config/packages/doctrine_migrations_chill.yaml new file mode 100644 index 0000000..81c1074 --- /dev/null +++ b/config/packages/doctrine_migrations_chill.yaml @@ -0,0 +1,20 @@ +doctrine_migrations: + migrations_paths: + # migrations for default chill modules + 'Chill\Migrations\Main': '@ChillMainBundle/migrations' + 'Chill\Migrations\Activity': '@ChillActivityBundle/migrations' + 'Chill\Migrations\DocStore': '@ChillDocStoreBundle/migrations' + 'Chill\Migrations\CustomFields': '@ChillCustomFieldsBundle/migrations' + 'Chill\Migrations\Event': '@ChillEventBundle/migrations' + 'Chill\Migrations\Person': '@ChillPersonBundle/migrations' + 'Chill\Migrations\Task': '@ChillTaskBundle/migrations' + 'Chill\Migrations\ThirdParty': '@ChillThirdPartyBundle/migrations' + 'Chill\Migrations\DocGenerator': '@ChillDocGeneratorBundle/migrations' + 'Chill\Migrations\AsideActivity': '@ChillAsideActivityBundle/migrations' + 'Chill\Migrations\Calendar': '@ChillCalendarBundle/migrations' + 'Chill\Migrations\Budget': '@ChillBudgetBundle/migrations' + all_or_nothing: + true + + services: + 'Doctrine\Migrations\Version\Comparator': 'Chill\MainBundle\Doctrine\Migrations\VersionComparator' diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index b996de4..19073bb 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -7,8 +7,6 @@ framework: verify_peer: false verify_host: false - # DIRTY FIX un bug dans symfony4 empêche de récupérer un tableau de variables depuis .env - # cfr. https://github.com/symfony/symfony/issues/28599 trusted_hosts: - '^(localhost|127.0.0.1|web)$' - '%env(resolve:TRUSTED_HOSTS)%' @@ -31,10 +29,6 @@ framework: #error_controller: App\Controller\ErrorController::show - ## sf4 check: ou à déplacer dans un chill.yaml - assets: - json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' - when@test: framework: test: true diff --git a/config/packages/framework_chill.yaml b/config/packages/framework_chill.yaml new file mode 100644 index 0000000..051d36d --- /dev/null +++ b/config/packages/framework_chill.yaml @@ -0,0 +1,3 @@ +framework: + assets: + json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' diff --git a/config/packages/mailer_chill.yaml b/config/packages/mailer_chill.yaml new file mode 100644 index 0000000..041ea79 --- /dev/null +++ b/config/packages/mailer_chill.yaml @@ -0,0 +1,4 @@ +framework: + mailer: + envelope: + sender: '%env(NOTIFICATION_FROM_EMAIL)%' diff --git a/config/packages/messenger.yaml b/config/packages/messenger.yaml index 574d024..6aa8d3e 100644 --- a/config/packages/messenger.yaml +++ b/config/packages/messenger.yaml @@ -17,11 +17,3 @@ framework: routing: # Route your messages to the transports # 'App\Message\YourMessage': async - 'Chill\CalendarBundle\Messenger\Message\CalendarRangeMessage': async - 'Chill\CalendarBundle\Messenger\Message\CalendarRangeRemovedMessage': async - 'Chill\CalendarBundle\Messenger\Message\CalendarRemovedMessage': async - 'Chill\CalendarBundle\Messenger\Message\CalendarMessage': async - 'Chill\CalendarBundle\Messenger\Message\InviteUpdateMessage': async - 'Chill\CalendarBundle\Messenger\Message\MSGraphChangeNotificationMessage': async - 'Chill\MainBundle\Service\ShortMessage\ShortMessage': async - 'Chill\DocGeneratorBundle\Service\Messenger\RequestGenerationMessage': priority diff --git a/config/packages/messenger_chill.yaml b/config/packages/messenger_chill.yaml new file mode 100644 index 0000000..6ced6e9 --- /dev/null +++ b/config/packages/messenger_chill.yaml @@ -0,0 +1,13 @@ +framework: + messenger: + routing: + # Route your messages to the transports + # 'App\Message\YourMessage': async + 'Chill\CalendarBundle\Messenger\Message\CalendarRangeMessage': async + 'Chill\CalendarBundle\Messenger\Message\CalendarRangeRemovedMessage': async + 'Chill\CalendarBundle\Messenger\Message\CalendarRemovedMessage': async + 'Chill\CalendarBundle\Messenger\Message\CalendarMessage': async + 'Chill\CalendarBundle\Messenger\Message\InviteUpdateMessage': async + 'Chill\CalendarBundle\Messenger\Message\MSGraphChangeNotificationMessage': async + 'Chill\MainBundle\Service\ShortMessage\ShortMessage': async + 'Chill\DocGeneratorBundle\Service\Messenger\RequestGenerationMessage': priority diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 2c3590e..c5554b7 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -1,9 +1,4 @@ security: - - access_decision_manager: - strategy: unanimous - allow_if_all_abstain: false - enable_authenticator_manager: true # https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords password_hashers: @@ -12,66 +7,24 @@ security: Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto' # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider providers: - chain_provider: - chain : - providers: [in_memory, users] - in_memory: + # providers added by chill-bundles recipes + # those providers are required to make chill working + chill_chain_provider: + chain: + providers: [chill_in_memory, chill_users] + chill_in_memory: memory: users: admin: { password: '%env(resolve:ADMIN_PASSWORD)%', roles: ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH', 'ROLE_USER'] } - users: + chill_users: id: chill.main.user_provider - encoders: - Chill\MainBundle\Entity\User: auto - Symfony\Component\Security\Core\User\User: plaintext - firewalls: - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - wopi: - pattern: ^/wopi - provider: chain_provider - stateless: true - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - main: - # remove during upgrade from symfony 4 to symfony 5 TODO check this - #anonymous: ~ - provider: chain_provider - form_login: - csrf_parameter: _csrf_token - csrf_token_id: authenticate - #csrf_provider: security.csrf.token_manager - # remove during upgrade from symfony 4 to symfony 5 TODO check this - # logout_on_user_change: true - logout: - path: /logout + # end of providers added by chill-bundles recipes + # all other providers might be removed, unless you have specific needs + # TODO AFTER CHILL-BUNDLES RECIPES INSTALL: remove the user providers which are not used - # uncomment to enable impersonate mode in Chill - # https://symfony.com/doc/current/security/impersonating_user.html - switch_user: true - - # activate different ways to authenticate - # https://symfony.com/doc/current/security.html#firewalls-authentication # Easy way to control access for large sections of your site # Note: Only the *first* access control that matches will be used - access_control: - - { path: ^/saml/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/saml/metadata, roles: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/(login|logout), roles: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/public, roles: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/wopi, roles: IS_AUTHENTICATED_FULLY } - # access for homepage, the homepage redirect admin to admin section - - { path: ^/$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } - - { path: ^/homepage$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } - # idem - - { path: ^/([a-z]+/)?homepage, roles: [ IS_AUTHENTICATED_REMEMBERED ] } - # admin section, only for admin - - { path: ^/([a-z]+/)?admin, roles: ROLE_ADMIN } - # other pages, only for regular user (no admin) - - { path: ^/, roles: ROLE_USER } when@test: security: diff --git a/config/packages/security_chill.yaml b/config/packages/security_chill.yaml new file mode 100644 index 0000000..7cc6aee --- /dev/null +++ b/config/packages/security_chill.yaml @@ -0,0 +1,50 @@ +security: + access_decision_manager: + strategy: unanimous + allow_if_all_abstain: false + firewalls: + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + wopi: + pattern: ^/wopi + provider: chill_chain_provider + stateless: true + guard: + authenticators: + - lexik_jwt_authentication.jwt_token_authenticator + chill_main: + # remove during upgrade from symfony 4 to symfony 5 TODO check this + #anonymous: ~ + provider: chill_chain_provider + form_login: + csrf_parameter: _csrf_token + csrf_token_id: authenticate + #csrf_provider: security.csrf.token_manager + # remove during upgrade from symfony 4 to symfony 5 TODO check this + # logout_on_user_change: true + logout: + path: /logout + + # uncomment to enable impersonate mode in Chill + # https://symfony.com/doc/current/security/impersonating_user.html + switch_user: true + + # activate different ways to authenticate + # https://symfony.com/doc/current/security.html#firewalls-authentication + + # Easy way to control access for large sections of your site + # Note: Only the *first* access control that matches will be used + access_control: + - { path: ^/(login|logout), roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/public, roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/wopi, roles: IS_AUTHENTICATED_FULLY } + # access for homepage, the homepage redirect admin to admin section + - { path: ^/$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + - { path: ^/homepage$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + # idem + - { path: ^/([a-z]+/)?homepage, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + # admin section, only for admin + - { path: ^/([a-z]+/)?admin, roles: ROLE_ADMIN } + # other pages, only for regular user (no admin) + - { path: ^/, roles: ROLE_USER } diff --git a/config/packages/test/.gitkeep b/config/packages/test/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config/packages/test/chill.yaml b/config/packages/test/chill.yaml deleted file mode 100644 index a6a68de..0000000 --- a/config/packages/test/chill.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -chill_main: - available_languages: - - 'fr' - - 'en' diff --git a/config/packages/test/security.yaml b/config/packages/test/security.yaml index 4ff9144..5403233 100644 --- a/config/packages/test/security.yaml +++ b/config/packages/test/security.yaml @@ -1,8 +1,5 @@ --- # config/packages/test/security.yaml security: - firewalls: - default: - http_basic: ~ role_hierarchy: CHILL_MASTER_ROLE: [CHILL_INHERITED_ROLE_1] diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 5cfd09e..282e33c 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -1,18 +1,5 @@ twig: default_path: '%kernel.project_dir%/templates' - - ## In Symfony 5, bootstrap_5 theme is supported. But not yet in sf4 !! - # see sf5 https://symfony.com/doc/current/form/form_themes.html - # see sf4 https://symfony.com/doc/4.4/form/form_themes.html - # - # While waiting for the upgrade, we get the form theme file - # (https://github.com/symfony/symfony/tree/5.4/src/Symfony/Bridge/Twig/Resources/views/Form), - # put it in ChillMainBundle/Resources/views/Form/bootstrap5/ - # and adapt it lightly. - # - form_themes: ['@ChillMain/Form/bootstrap5/bootstrap_5_horizontal_layout.html.twig'] - #form_themes: ['bootstrap_5_horizontal_layout.html.twig'] - when@test: twig: strict_variables: true diff --git a/config/packages/twig_chill.yaml b/config/packages/twig_chill.yaml new file mode 100644 index 0000000..15a3066 --- /dev/null +++ b/config/packages/twig_chill.yaml @@ -0,0 +1,16 @@ +twig: + ## In Symfony 5, bootstrap_5 theme is supported. But not yet in sf4 !! + # see sf5 https://symfony.com/doc/current/form/form_themes.html + # see sf4 https://symfony.com/doc/4.4/form/form_themes.html + # + # While waiting for the upgrade, we get the form theme file + # (https://github.com/symfony/symfony/tree/5.4/src/Symfony/Bridge/Twig/Resources/views/Form), + # put it in ChillMainBundle/Resources/views/Form/bootstrap5/ + # and adapt it lightly. + # + form_themes: ['@ChillMain/Form/bootstrap5/bootstrap_5_horizontal_layout.html.twig'] + +when@dev: + twig: + globals: + responsive_debug: false diff --git a/config/packages/workflow.yaml b/config/packages/workflow_chill.yaml similarity index 100% rename from config/packages/workflow.yaml rename to config/packages/workflow_chill.yaml diff --git a/entrypoint.sh b/entrypoint.sh index cf5fd1e..0bebfb8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -41,6 +41,7 @@ if [ "${APP_ENV}" = "prod" ]; then php /var/www/app/bin/console doctrine:migrations:status php /var/www/app/bin/console doctrine:migrations:migrate -n php /var/www/app/bin/console messenger:setup-transports + php /var/www/app/bin/console chill:db:sync-views fi fi