stauth/symfony-stauth

暂存服务器授权包,.htaccess替代方案

0.0.2 2017-07-08 17:08 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:13:32 UTC


README

Latest Stable Version License composer.lock available

暂存服务器授权包,.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非常重要。