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;
/**
* HttpBearer supports the authentication method based on HTTP Bearer token.
*/
final class HttpBearer extends HttpHeader
{
protected string $headerName = 'Authorization';
protected string $pattern = '/^Bearer\s+(.*?)$/';
* @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 withRealm(string $realm): self
$new = clone $this;
$new->realm = $realm;
return $new;