roadiz/rozier-bundle

安装数量: 3,700

依赖: 4

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 0

类型:symfony-bundle

v2.3.28 2024-09-24 13:19 UTC

README

将旧版管理界面迁移到 Roadiz v2

Run test status

安装

确保全局已安装 Composer,如 Composer 文档的安装章节所述。

使用 Symfony Flex 的应用程序

打开命令行,进入您的项目目录,并执行以下命令

$ composer require roadiz/rozier-bundle

不使用 Symfony Flex 的应用程序

步骤 1: 下载 Bundle

打开命令行,进入您的项目目录,并执行以下命令以下载此 Bundle 的最新稳定版本

$ composer require roadiz/rozier-bundle

步骤 2: 启用 Bundle

然后,通过将其添加到项目 config/bundles.php 文件中注册的 Bundle 列表中来启用该 Bundle

// config/bundles.php

return [
    // ...
    \RZ\Roadiz\RozierBundle\RoadizRozierBundle::class => ['all' => true],
];

配置

  • config/packages/roadiz_rozier.yaml 复制到您的 Symfony 应用 config/packages 文件夹中。
  • 禁用 Twig strict_variables
  • 添加自定义 security 配置
# config/packages/security.yaml
security:
    enable_authenticator_manager: true
    password_hashers:
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
            algorithm: auto
    providers:
        openid_user_provider:
            id: RZ\Roadiz\OpenId\Authentication\Provider\OpenIdAccountProvider
        roadiz_user_provider:
            entity:
                class: RZ\Roadiz\CoreBundle\Entity\User
                property: username
        all_users:
            chain:
                providers: [ 'openid_user_provider', 'roadiz_user_provider' ]

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            lazy: true
            provider: all_users
            switch_user: { role: ROLE_SUPERADMIN, parameter: _su }
            logout:
                path: logoutPage
            custom_authenticator:
                - RZ\Roadiz\RozierBundle\Security\RozierAuthenticator
    access_control:
        - { path: ^/rz-admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/rz-admin, roles: ROLE_BACKEND_USER }
  • 添加自定义路由
# config/routes.yaml
roadiz_rozier:
    resource: "@RoadizRozierBundle/config/routing.yaml"

rz_intervention_request:
    resource: "@RZInterventionRequestBundle/Resources/config/routing.yml"
    prefix:   /

OpenID

此 Bundle 允许用户使用 OpenID 登录到后台办公室

#config/packages/roadiz_rozier.yaml
roadiz_rozier:
    #...
    open_id:
        # Verify User info in JWT at each login
        verify_user_info: false
        # Standard OpenID autodiscovery URL, required to enable OpenId login in Roadiz CMS.
        discovery_url: '%env(string:OPEN_ID_DISCOVERY_URL)%'
        # For public identity providers (such as Google), restrict users emails by their domain.
        hosted_domain: '%env(string:OPEN_ID_HOSTED_DOMAIN)%'
        # OpenID identity provider OAuth2 client ID
        oauth_client_id: '%env(string:OPEN_ID_CLIENT_ID)%'
        # OpenID identity provider OAuth2 client secret
        oauth_client_secret: '%env(string:OPEN_ID_CLIENT_SECRET)%'
        granted_roles:
            - ROLE_USER
            - ROLE_BACKEND_USER

然后,将自定义认证器 roadiz_rozier.open_id.authenticator 添加到您的安全配置中

#config/packages/security.yaml
security:
    firewalls:
        main:
            # ...
            custom_authenticator:
                - RZ\Roadiz\RozierBundle\Security\RozierAuthenticator
                - roadiz_rozier.open_id.authenticator

贡献

问题Pull Requests 中报告问题,并发送至 主 Roadiz 仓库