1. Go to this page and download the library: Download survos/auth-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
survos / auth-bundle example snippets
use Survos\AuthBundle\Traits\OAuthIdentifiersInterface;
use Survos\AuthBundle\Traits\OAuthIdentifiersTrait;
class User implements OAuthIdentifiersInterface
{
use OAuthIdentifiersTrait;
}
final class UserProvider implements AttributesBasedUserProviderInterface
{
public function __construct(private EntityManagerInterface $em, private OidcUserResolver $oidcUserResolver) {}
public function loadUserByIdentifier(string $identifier, array $attributes = []): UserInterface
{
return OidcUserResolver::isOidcLogin($attributes)
? $this->oidcUserResolver->resolve('authentik', $attributes)
: $this->em->getRepository(User::class)->findOneBy(['email' => $identifier]) ?? throw new UserNotFoundException();
}
}