for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the "Kata 1" package.
*
* Copyright (c) Daniel González
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* @author Daniel González <[email protected]>
*/
namespace App\Security\Http;
use Component\Http\Request;
use App\Repository\UserRepository;
/**
* HttpBasicUserProvider.
class HttpBasicUserProvider
{
* @var UserRepository
protected $repository;
* HttpBasicUserProvider constructor.
* @param UserRepository $repository
public function __construct(UserRepository $repository)
$this->repository = $repository;
}
* @param Request|null $request
* @return \App\Model\User|false
public function getUser(Request $request = null)
if (!$request) {
return;
$token = base64_decode($request->getHeader('Authorization'));
if (!$token) {
if (!strpos($token, ':')) {
list($name, $password) = explode(':', $token);
return $this->repository->findByNameAndPassword($name, $password);