PHP 8.2.30
Preview: BasicAuth.php Size: 869 B
/home/byroehnu/easetack.com/vendor/php-http/message/src/Authentication/BasicAuth.php

<?php

namespace Http\Message\Authentication;

use Http\Message\Authentication;
use Psr\Http\Message\RequestInterface;

/**
 * Authenticate a PSR-7 Request using Basic Auth.
 *
 * @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
 */
final class BasicAuth implements Authentication
{
    /**
     * @var string
     */
    private $username;

    /**
     * @var string
     */
    private $password;

    /**
     * @param string $username
     * @param string $password
     */
    public function __construct($username, $password)
    {
        $this->username = $username;
        $this->password = $password;
    }

    public function authenticate(RequestInterface $request)
    {
        $header = sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->username, $this->password)));

        return $request->withHeader('Authorization', $header);
    }
}

Directory Contents

Dirs: 0 × Files: 9

Name Size Perms Modified Actions
1.10 KB lrw-rw-rw- 2024-10-02 11:34:13
Edit Download
869 B lrw-rw-rw- 2024-10-02 11:34:13
Edit Download
658 B lrw-rw-rw- 2024-10-02 11:34:13
Edit Download
1.13 KB lrw-rw-rw- 2024-10-02 11:34:13
Edit Download
599 B lrw-rw-rw- 2024-10-02 11:34:13
Edit Download
1.76 KB lrw-rw-rw- 2024-10-02 11:34:13
Edit Download
1.04 KB lrw-rw-rw- 2024-10-02 11:34:13
Edit Download
951 B lrw-rw-rw- 2024-10-02 11:34:13
Edit Download
1.68 KB lrw-rw-rw- 2024-10-02 11:34:13
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).