uxf / security
Installs: 11 067
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/uxf/security
Requires
- php: ^8.3
 - ext-json: *
 - firebase/php-jwt: ^6.0
 - twig/twig: ^3.0
 - uxf/core: 3.71.0
 
- 3.x-dev
 - 3.71.0
 - 3.70.5
 - 3.70.4
 - 3.70.3
 - 3.70.2
 - 3.70.0
 - 3.69.12
 - 3.69.7
 - 3.69.6
 - 3.69.5
 - 3.69.3
 - 3.69.1
 - 3.69.0
 - 3.68.5
 - 3.68.4
 - 3.68.3
 - 3.68.2
 - 3.68.1
 - 3.68.0
 - 3.67.3
 - 3.67.0
 - 3.66.0
 - 3.65.3
 - 3.65.2
 - 3.65.0
 - 3.64.4
 - 3.64.3
 - 3.64.2
 - 3.64.1
 - 3.64.0
 - 3.63.1
 - 3.62.4
 - 3.62.3
 - 3.62.2
 - 3.62.0
 - 3.61.7
 - 3.61.6
 - 3.61.5
 - 3.61.3
 - 3.61.2
 - 3.61.1
 - 3.61.0
 - 3.60.12
 - 3.60.11
 - 3.60.10
 - 3.60.8
 - 3.60.7
 - 3.60.5
 - 3.60.3
 - 3.60.0
 - 3.59.0
 - 3.58.8
 - 3.58.5
 - 3.58.4
 - 3.58.2
 - 3.58.1
 - 3.58.0
 - 3.57.12
 - 3.57.10
 - 3.57.7
 - 3.57.6
 - 3.57.1
 - 3.57.0
 - 3.56.3
 - 3.56.2
 - 3.56.1
 - 3.56.0
 - 3.55.9
 - 3.55.8
 - 3.55.7
 - 3.55.5
 - 3.55.0
 - 3.54.5
 - 3.54.3
 - 3.54.2
 - 3.54.0
 - 3.53.7
 - 3.53.3
 - 3.53.2
 - 3.53.1
 - 3.53.0
 - 3.51.2
 - 3.51.0
 - 3.50.6
 - 3.50.5
 - 3.50.3
 - 3.50.2
 - 3.50.1
 - 3.50.0
 - 3.49.2
 - 3.49.1
 - 3.49.0
 - 3.48.0
 - 3.47.2
 - 3.47.0
 - 3.46.11
 - 3.45.3
 - 3.45.2
 - 3.45.1
 - 3.44.6
 - 3.44.5
 - 3.44.4
 - 3.44.3
 - 3.44.2
 - 3.44.0
 - 3.43.2
 - 3.43.0
 - 3.42.0
 - 3.41.2
 - 3.41.1
 - 3.41.0
 - 3.40.4
 - 3.40.3
 - 3.40.2
 - 3.40.1
 - 3.40.0
 - 3.39.4
 - 3.39.3
 - 3.39.2
 - 3.39.1
 - 3.38.0
 - 3.37.1
 - 3.37.0
 - 3.36.3
 - 3.36.2
 - 3.36.0
 - 3.35.5
 - 3.35.4
 - 3.35.2
 - 3.34.3
 - 3.34.0
 - 3.33.0
 - 3.32.4
 - 3.32.3
 - 3.30.1
 - 3.29.1
 - 3.29.0
 - 3.27.3
 - 3.26.0
 - 3.25.5
 - 3.25.4
 - 3.24.2
 - 3.24.1
 - 3.24.0
 - 3.23.3
 - 3.23.1
 - 3.23.0
 - 3.22.0
 - 3.21.4
 - 3.21.3
 - 3.21.0
 - 3.20.0
 - 3.19.4
 - 3.19.3
 - 3.19.2
 - 3.18.0
 - 3.17.4
 - 3.17.3
 - 3.17.1
 - 3.17.0
 - 3.15.6
 - 3.15.5
 - 3.13.2
 - 3.13.0
 - 3.11.3
 - 3.11.0
 - 3.10.1
 - 3.10.0
 - 3.9.2
 - 3.8.2
 - 3.8.1
 - 3.8.0
 - 3.7.3
 - 3.7.1
 - 3.7.0
 - 3.6.0
 - 3.5.0
 - 3.4.0
 - 3.3.0
 - 3.2.4
 - 3.2.3
 - 3.2.2
 - 3.2.1
 - 3.2.0
 - 3.1.4
 - 3.1.3
 - 3.1.2
 - 3.1.1
 - 3.1.0
 - 3.0.4
 - 3.0.3
 - 3.0.2
 - 3.0.1
 - 3.0.0
 - dev-main
 
This package is auto-updated.
Last update: 2025-10-09 07:25:14 UTC
README
Install
$ composer req uxf/security
// config/packages/uxf.php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
    $containerConfigurator->extension('uxf_security', [
        'user_class' => User::class,                // required
        'base_url' => 'https://uxf.cz',             // required
        'public_key' => '%env(AUTH_PUBLIC_KEY)%',   // required
        'private_key' => '%env(AUTH_PRIVATE_KEY)%', // required
        // optional
        'access_token_lifetime' => 'P10Y',          // default 1 day
        'refresh_token_lifetime' => 'P20Y',         // default 1 month
        'refresh_token_cookie_path' => '/',         // default null (suggestion: /api/auth/refresh-token)
        'cookie_name' => 'Cookie-Name',             // default Authorization - used for header + cookie
        'cookie_secured' => false,                  // default true
        'cookie_http_only' => false,                // default true
        // OpenID Connect - optional
        'oidc' => [
            'apple' => [
                'client_id' => 'xxx',
            ],
            'facebook' => [
                'client_id' => 'xxx',
                'client_secret' => 'xxx',
            ],
            'gitlab' => [
                'client_id' => 'xxx',
                'client_secret' => 'xxx',
            ],
            'google' => [
                'client_id' => 'xxx',
            ],
            'microsoft' => [
                'client_id' => 'xxx',
            ],
            'mojeid' => [
                'client_id' => 'xxx',
            ],
            'seznam' => [
                'client_id' => 'xxx',
                'client_secret' => 'xxx',
            ],
        ],
    ]);
};
Symfony security config - recommended
// config/packages/security.php
return static function (ContainerConfigurator $config): void {
    $config->extension('security', [
        'providers' => [
            'provider' => [
                'entity' => [
                    'class' => \UXF\CMS\Entity\User::class,
                    'property' => 'email', // BC break in 3.68 (id -> email)
                ],
            ],
        ],
        ...
   ]);
}
Events
LogoutUserEvent
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use UXF\Security\Event\LogoutUserEvent;
#[AsEventListener(LogoutUserEvent::class)]
final readonly class LogoutUserListener
{
    public function __invoke(LogoutUserEvent $event): void
    {
        // edit response cookies/headers
        ...
    }
}
OpenID Connect
Create new user
use Nette\Utils\Random;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use UXF\CMS\Entity\User;
use UXF\Security\Service\OIDC\NewUserEvent;
class NewUserEventSubscriber implements EventSubscriberInterface
{
    public function process(NewUserEvent $event): void
    {
        $event->user = new User($event->oidcInfo->email, '', Random::generate());
    }
    /**
     * @inheritDoc
     */
    public static function getSubscribedEvents(): array
    {
        return [
            NewUserEvent::class => 'process',
        ];
    }
}
Providers & URLs
# login
https://domain.com/api/auth/oidc/<provider>/login
# login with redirect (default is /)
https://domain.com/api/auth/oidc/<provider>/login?redirect=/some-path
# login callback
https://domain.com/api/auth/oidc/<provider>/callback