imatic / user-bundle
Imatic 用户包
v5.0.0
2021-11-26 12:23 UTC
Requires
- php: >=7.4
- doctrine/doctrine-bundle: ^2.1.2
- doctrine/orm: ^2.7.4
- imatic/controller-bundle: ^5.0.0
- imatic/view-bundle: ^5.0.4
- sensio/framework-extra-bundle: ^5.6.1
- symfony/framework-bundle: ^4.4.16
- symfony/swiftmailer-bundle: ^3.5.1
Requires (Dev)
- doctrine/doctrine-fixtures-bundle: ^3.3
- friendsofphp/php-cs-fixer: ^2.8
- imatic/form-bundle: ^4.0.1
- imatic/testing: ^6.0.2
- phpmd/phpmd: ^2.6
- symfony/asset: ^4.4
- symfony/expression-language: ^4.4
- symfony/web-profiler-bundle: ^4.4
- symfony/yaml: ^4.4
Suggests
- phpoffice/phpexcel: To create and import role documents.
- dev-master
- v5.0.0
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- v4.0.0-alpha.4
- v4.0.0-alpha.3
- v4.0.0-alpha.2
- v4.0.0-alpha
- 3.0.17
- v3.0.16
- v3.0.15
- v3.0.14
- v3.0.13
- v3.0.12
- v3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0
- 2.6.4
- 2.6.3
- 2.6.1
- 2.6.0
- dev-dependabot/composer/twig/twig-3.11.1
- dev-php8test
- dev-null-email
- dev-registration-group
- dev-null-username
- dev-php8
This package is auto-updated.
Last update: 2024-09-12 07:21:18 UTC
README
ImaticUserBundle
角色
全局角色
配置
# app/config/security.yml security: # ... role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
翻译
全局角色使用 "roles" 域进行翻译。
模型角色
配置
# app/config/config.yml # Imatic user imatic_user: # ... security: role: model: namespaces: includes: - App excludes: - AppExampleBundle\Entity\Example # exclude single entity - AppFooBundle\Entity # exclude all entities
安装
1. 生成 AppUserBundle
生成并启用一个名为 AppUserBundle 的本地包。
此包将包含与用户相关的实体和固定数据。
2. 使用 composer 下载 ImaticUserBundle
"require": { # ... "imatic/user-bundle": "^3.0" }
3. 启用包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new FOS\UserBundle\FOSUserBundle(), new Imatic\Bundle\UserBundle\ImaticUserBundle(), ); }
4. 配置包
# app/config/config.yml imports: # ... - { resource: "@ImaticUserBundle/Resources/config/config.yml" } - { resource: "@AppUserBundle/Resources/config/config.yml" } doctrine: # ... orm: #... resolve_target_entities: # UserBundle Imatic\Bundle\UserBundle\Model\UserInterface: ApUserBundle\Entity\User Imatic\Bundle\UserBundle\Model\GroupInterface: AppUserBundle\Entity\Group # Imatic user imatic_user: entities: user: AppUserBundle\Entity\User group: AppUserBundle\Entity\Group security: role: model: namespaces: includes: ~ excludes: ~ hierarchy: ~
5. 配置安全设置
# app/config/security.yml security: encoders: Symfony\Component\Security\Core\User\UserInterface: bcrypt role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: imatic_user_provider: id: imatic_user.user_provider.username firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: pattern: ^/ form_login: provider: imatic_user_provider csrf_token_generator: security.csrf.token_manager logout: true anonymous: true switch_user: true access_control: - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/, role: IS_AUTHENTICATED_FULLY }
6. 配置路由
# app/config/routing.yml imatic_user: resource: "@ImaticUserBundle/Resources/config/routing.yml"