farvest/security-bundle
Composer 安装命令:
composer require farvest/security-bundle
包简介
Security bundle test to provide login page to accesss administration pages.
README 文档
README
Security Bundle by Flagstone. Create login and logout root for admin access
Installation
Use composer manager to install it
composer install flagstone/security-bundle
To add the user entity to your database, you just have to make a standard migration.
php bin/console make:migration
php bin/console doctrine:migrations:migrate
Import Routes
In the routing file of your application, add the following
flagstone_security:
resource: '@FlagstoneSecurityBundle/Resources/config/routes_security.yaml'
prefix:
en: ''
fr: '/fr'
de: '/de'
flagstone_security_user:
resource: '@FlagstoneSecurityBundle/Resources/config/routes_user.yaml'
prefix:
en: '/admin'
fr: '/fr/admin'
de: '/de/admin'
The bundle define 2 distinct routes. The first one is to access to the user management, the second give a routing for /login and /logout routes. So you can define distinct prefix for these 2 routes.
Configuration
This bundle uses the Symfony security bundle. So you just have to configure the security with the security.yaml file, like this example:
security:
enable_authenticator_manager: true
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
providers:
user:
entity:
class: Flagstone\SecurityBundle\Entity\User
property: username
firewalls:
dev:
pattern: (_(profiler|wdt)|css|images|js)/
security: false
admin:
lazy: true
logout:
path: logout
target: login
provider: user
custom_authenticator:
- Flagstone\SecurityBundle\Security\UserFormAuthenticator
main:
lazy: true
security: false
role_hierarchy:
ROLE_COMMENT: ROLE_GUEST
ROLE_BLOG: ROLE_COMMENT
ROLE_ADMIN: ROLE_BLOG
ROLE_DEV: [ROLE_GUEST, ROLE_COMMENT, ROLE_BLOG, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
access_control:
- { path: ^/admin/login, roles: PUBLIC_ACCESS}
- { path: ^/admin/user, roles: ROLE_DEV}
- { path: ^/admin, roles: ROLE_ADMIN}
The bundle uses 3 parameters to define the route for login_form and success login and the list of roles you want.
availableRoles:
- 'ROLE_DEV'
- 'ROLE_ADMIN'
- 'ROLE_USER'
- 'ROLE_GUEST'
fs_adminIndex: 'fs_admin_index'
fs_loginRoute: 'fs_admin_login'
Default values are set, but you can overwrite these parameters in your services.yaml.
Usage
Create an user
You can use the embed user creation command console. You can create the first admin user :
php bin/console flagstone-security:create-admin
Answer all questions and then, a new user is created, with admin privileges.
TODO
- Add a logging system to know who make what.
- Add configuration to know what can be do by a role user (who can delete, who can edit...). Define actions by role.
License
farvest/security-bundle 适用场景与选型建议
farvest/security-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 farvest/security-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 farvest/security-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-07