greenhollowtech/ght-api-authenticator-bundle
Composer 安装命令:
composer require greenhollowtech/ght-api-authenticator-bundle
包简介
GHT API Authenticator Bundle
README 文档
README
This bundle provides the GHT API Authenticator as a service in Symfony.
Installation
Get the Composer package
To install with Composer, run composer require greenhollowtech/ght-api-authenticator-bundle. For Symfony 2, make sure to stipulate the version ~1.0.
Add the GHTApiAuthenticatorBundle to your Symfony application
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new GHT\ApiAuthenticatorBundle\GHTApiAuthenticatorBundle(),
// ...
);
}
Usage
Set up your firewall to use the API Authenticator.
# app/config/security.yml
security:
...
firewalls:
api:
stateless: true
simple_preauth:
authenticator: ght_api_authenticator
Add the apiKey and apiSecret properties to your user entity, along with the related getters and setters.
If you already have properties established, and wish to use the existing data, simply configure the API Authenticator to use those properties instead of the default:
# app/config/config.yml
ght_api_authenticator:
user_entity:
api_key_property: myKeyPropertyName
api_secret_property: mySecretPropertyName
Custom User Provider
If your application has alternative means of loading the current user, you can provide that to the API Authenticator as well by defining your own service. Your custom user provider is passed as the third argument in the construct.
# src/AcmeBundle/Resources/config/services.yml
services:
...
acme_api_user_authenticator:
class: GHT\ApiAuthenticatorBundle\Security\ApiUserAuthenticator
arguments:
- %ght_api_authenticator.user_entity.api_key_property%
- %ght_api_authenticator.user_entity.api_secret_property%
- "@acme_custom_user_provider"
Then set the authenticator in your firewall to use this new service instead.
统计信息
- 总下载量: 30
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-01