linkorb / flex-auth-provider
Silex service provider for including FlexAuth library.
Installs: 1 038
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 2
Open Issues: 0
Type:silex-provider
Requires
- php: >=7.0
- linkorb/flex-auth: ^1.0
- silex/silex: ~2.0
README
FlexAuth: Silex provider
FlexAuthProvider provider integration FlexAuth library to Silex framework.
Using
use Silex\Application; $app = new Application(); //.... $app->register(new \Silex\Provider\SessionServiceProvider()); $app->register(new \FlexAuthProvider\FlexAuthProvider()); // define login page for redirect if jwt authentication is failed via browser $app['flex_auth.jwt.redirect_login_page'] = "/login"; $app['security.user_provider.main'] = function ($app) { return $app['flex_auth.security.user_provider']; }; $app->register(new Silex\Provider\SecurityServiceProvider(), [ 'security.firewalls' => [ 'main' => [ # https://silex.symfony.com/doc/2.0/cookbook/guard_authentication.html 'guard' => [ 'authenticators' => [ 'flex_auth.type.jwt.security.authenticator' ], ], 'form' => [ 'login_path' => '/login', 'default_target_path' => '/', 'check_path' => '/login_check' ], 'logout' => [ 'logout_path' => '/logout', 'target_url' => 'homepage', 'invalidate_session' => true ], 'anonymous' => true, ], ], ]); $app['security.default_encoder'] = function ($app) { return $pimple['flex_auth.security.password_encoder']; // return new \Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder(); };