Open Journal Systems  3.3.0
BasicAuth.php
1 <?php
2 
4 
7 
13 final class BasicAuth implements Authentication
14 {
18  private $username;
19 
23  private $password;
24 
29  public function __construct($username, $password)
30  {
31  $this->username = $username;
32  $this->password = $password;
33  }
34 
38  public function authenticate(RequestInterface $request)
39  {
40  $header = sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->username, $this->password)));
41 
42  return $request->withHeader('Authorization', $header);
43  }
44 }
Http\Message\Authentication\BasicAuth
Definition: BasicAuth.php:13
Http\Message\Authentication
Definition: AutoBasicAuth.php:3
Psr\Http\Message\RequestInterface
Definition: vendor/psr/http-message/src/RequestInterface.php:24
Http\Message\Authentication
Definition: Authentication.php:12
Psr\Http\Message\MessageInterface\withHeader
withHeader($name, $value)
Http\Message\Authentication\BasicAuth\__construct
__construct($username, $password)
Definition: BasicAuth.php:35
Http\Message\Authentication\BasicAuth\authenticate
authenticate(RequestInterface $request)
Definition: BasicAuth.php:44