PHP code example of survos / auth-bundle

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();
    }
}
bash
vendor/bin/phpunit --no-configuration --bootstrap bu/auth-bundle/tests/bootstrap.php bu/auth-bundle/tests