stauth / symfony-stauth
暂存服务器授权包,.htaccess替代方案
0.0.2
2017-07-08 17:08 UTC
Requires
- guzzlehttp/guzzle: 6.*
- symfony/psr-http-message-bridge: 0.2
- twig/twig: ~1.0
This package is not auto-updated.
Last update: 2024-09-29 02:13:32 UTC
README
暂存服务器授权包,.htaccess替代方案,在stauth.io注册
安装
composer require stauth/symfony-stauth
本地和暂存
如果你不希望Stauth服务提供商在生产环境中执行,请在app/routing_dev.yml
中导入路由
# stauth protection stauth_protection: resource: "@StauthProtectionBundle/Resources/config/routing.yml"
在AppKernel.php
中初始化Bundle
if ($this->getEnvironment() !== 'prod') { // ... $bundles[] = new Stauth\StauthProtectionBundle(); }
生产
如果你不介意Stauth服务提供商在生产环境中执行,或者你想要保护你的生产应用程序,请在app/routing.yml
中导入路由
# stauth protection stauth_protection: resource: "@StauthProtectionBundle/Resources/config/routing.yml"
在AppKernel.php
中初始化Bundle
public function registerBundles() { $bundles = array( // ... new Stauth\StauthProtectionBundle(), );
在stauth.io生成访问令牌,并将其添加到parameters.yml
stauth.access_token: 'eyJkkk40eXAiOiJsdvk3k43krKV1QiLCJ...'
默认受保护环境为staging
,要更改此设置,请将stauth.protected_env
添加到parameters.yml
stauth.protected_env: 'local'
缓存
请注意,此包利用csrf_token
,因此从任何响应缓存引擎中排除路由/stauth/protected
和/stauth/authorize
非常重要。