linkorb/flex-auth-provider

Silex service provider for including FlexAuth library.

Installs: 1 060

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 2

Open Issues: 0

Type:silex-provider

v1.3.2 2023-02-07 10:57 UTC

This package is auto-updated.

Last update: 2024-12-07 14:50:58 UTC


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();
};

Links

Silex demo

The Security Component(Symfony Docs)