uxf / security
3.40.4
2024-04-09 16:28 UTC
Requires
- php: ^8.3
- ext-json: *
- firebase/php-jwt: ^6.0
- uxf/core: 3.40.4
- dev-main
- 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
This package is auto-updated.
Last update: 2024-04-09 14:32:48 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',
],
],
]);
};
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
# callback
https://domain.com/api/auth/oidc/<provider>/callback