37
vendor/php-http/message/src/Authentication/Bearer.php
vendored
Normal file
37
vendor/php-http/message/src/Authentication/Bearer.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Message\Authentication;
|
||||
|
||||
use Http\Message\Authentication;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Authenticate a PSR-7 Request using a token.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*/
|
||||
final class Bearer implements Authentication
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $token;
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
*/
|
||||
public function __construct($token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function authenticate(RequestInterface $request)
|
||||
{
|
||||
$header = sprintf('Bearer %s', $this->token);
|
||||
|
||||
return $request->withHeader('Authorization', $header);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user