dcs / 安全核心包
DCSSecurityCoreBundle 提供了安全管理的基礎服務
Requires
- php: >=5.3.9
Requires (Dev)
- dcs/user-core-bundle: ~1.0@dev
- phpunit/phpcov: 3.*
- phpunit/phpunit: ^5
- satooshi/php-coveralls: ~1.0
- symfony/security: ~2.8|~3.0
Suggests
- dcs/security-auth-form-bundle: Provides an authentication system using the login form
This package is not auto-updated.
Last update: 2024-09-26 01:02:33 UTC
README
DCSSecurityCoreBundle
DCSSecurityCoreBundle 提供了將 DCSUser 集成到 Symfony 安全系統 的功能。
此包提供自定義的 UserProvider 和自定義的 AuthenticationProvider。
UserProvider
使用 DCS\User\CoreBundle\Repository\UserRepositoryInterface
的 UserProvider 處理用戶恢復。在 loadUserByUsername 行動中,會觸發兩個事件(用戶搜索前後),允許您插入額外邏輯。
AuthenticationProvider
此提供者擴展了 Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider
,並在執行 authenticate 方法後添加一個事件。AuthenticationProvider 不直接由此包使用,但在實現最終的 SecurityFactoryInterface 時提供作為服務。
參見:DCSSecurityAuthFormBundle 登錄系統,它使用登錄表單。
事件
事件完整列表在 DCS\Security\CoreBundle\DCSSecurityCoreEvents
類中。
安裝
先決條件
此包需要 DCSUserCoreBundle。
需要此包
運行以下命令
$ composer require dcs/security-core-bundle "~1.0@dev"
Composer 將將包安裝到您的項目的 vendor/dcs/security-core-bundle
文件夾。
啟用包
在 kernel 中啟用包
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new DCS\Security\CoreBundle\DCSSecurityCoreBundle(),
// ...
);
}
配置
現在您已經正確啟用此包,下一步是配置它以適應您應用的特定需求。
將以下配置添加到您的 config.yml
。
dcs_security_core:
provider_key: #SECURITY_PROVIDER_NAME
並將提供者設置為您的 security.yml
。
security:
providers:
dcs_user:
id: dcs_security.core.provider.user
# !!Now use the provider in your authentication provider within the firewall!!
報告問題或功能請求
問題和功能請求在 Github issue tracker 中追蹤。