for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Auth\Method;
use Psr\Http\Message\ResponseInterface;
/**
* HttpBearerAuth supports the authentication method based on HTTP Bearer token.
*/
final class HttpBearer extends HttpHeader
{
private const HEADER_NAME = 'Authorization';
private const PATTERN = '/^Bearer\s+(.*?)$/';
protected string $headerName = self::HEADER_NAME;
protected string $pattern = self::PATTERN;
* @var string the HTTP authentication realm
private string $realm = 'api';
public function challenge(ResponseInterface $response): ResponseInterface
return $response->withHeader('WWW-Authenticate', "{$this->headerName} realm=\"{$this->realm}\"");
}
public function setRealm(string $realm): void
$this->realm = $realm;