stauth / symfony-stauth
Staging server athorization package, .htaccess alternative
Requires
- guzzlehttp/guzzle: 6.*
- symfony/psr-http-message-bridge: 0.2
- twig/twig: ~1.0
This package is not auto-updated.
Last update: 2025-01-05 03:26:41 UTC
README
Staging server athorization package, alternative for .htaccess, register at stauth.io
Installation
composer require stauth/symfony-stauth
Local and staging
If you don't want Stauth service provider to be exeuted at production environment, import routes in app/routing_dev.yml
# stauth protection stauth_protection: resource: "@StauthProtectionBundle/Resources/config/routing.yml"
Initialize Bundle in AppKernel.php
:
if ($this->getEnvironment() !== 'prod') { // ... $bundles[] = new Stauth\StauthProtectionBundle(); }
Production
If you don't mind Stauth service provider being executed at production environment, or you want to protect your production app, import routes in app/routing.yml
# stauth protection stauth_protection: resource: "@StauthProtectionBundle/Resources/config/routing.yml"
Initialize Bundle in AppKernel.php
:
public function registerBundles() { $bundles = array( // ... new Stauth\StauthProtectionBundle(), );
Generate access token at stauth.io and add it to parameteres.yml
:
stauth.access_token: 'eyJkkk40eXAiOiJsdvk3k43krKV1QiLCJ...'
By default protected environment is staging
, in order to change this, add stauth.protected_env
to parameters.yml
:
stauth.protected_env: 'local'
Cache
Please keep in mind that this package takes adventage of csrf_token
, therefore it is important to exclude both routes /stauth/protected
and /stauth/authorize
from any response caching engines.