mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-03 05:29:53 +09:00
Update to laravel 7
This commit is contained in:
36
vendor/php-http/message/src/Authentication/Header.php
vendored
Normal file
36
vendor/php-http/message/src/Authentication/Header.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Message\Authentication;
|
||||
|
||||
use Http\Message\Authentication;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
class Header implements Authentication
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|string[]
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param string|string[] $value
|
||||
*/
|
||||
public function __construct(string $name, $value)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function authenticate(RequestInterface $request)
|
||||
{
|
||||
return $request->withHeader($this->name, $this->value);
|
||||
}
|
||||
}
|
||||
@@ -27,10 +27,6 @@ final class Matching implements Authentication
|
||||
*/
|
||||
private $matcher;
|
||||
|
||||
/**
|
||||
* @param Authentication $authentication
|
||||
* @param callable|null $matcher
|
||||
*/
|
||||
public function __construct(Authentication $authentication, callable $matcher = null)
|
||||
{
|
||||
if (is_null($matcher)) {
|
||||
@@ -58,8 +54,7 @@ final class Matching implements Authentication
|
||||
/**
|
||||
* Creates a matching authentication for an URL.
|
||||
*
|
||||
* @param Authentication $authentication
|
||||
* @param string $url
|
||||
* @param string $url
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
|
||||
@@ -20,9 +20,6 @@ final class QueryParam implements Authentication
|
||||
*/
|
||||
private $params = [];
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(array $params)
|
||||
{
|
||||
$this->params = $params;
|
||||
@@ -41,7 +38,7 @@ final class QueryParam implements Authentication
|
||||
|
||||
$params = array_merge($params, $this->params);
|
||||
|
||||
$query = http_build_query($params, null, '&');
|
||||
$query = http_build_query($params, '', '&');
|
||||
|
||||
$uri = $uri->withQuery($query);
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@ final class RequestConditional implements Authentication
|
||||
*/
|
||||
private $authentication;
|
||||
|
||||
/**
|
||||
* @param RequestMatcher $requestMatcher
|
||||
* @param Authentication $authentication
|
||||
*/
|
||||
public function __construct(RequestMatcher $requestMatcher, Authentication $authentication)
|
||||
{
|
||||
$this->requestMatcher = $requestMatcher;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Http\Message\Authentication;
|
||||
|
||||
use Http\Message\Authentication;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
@@ -22,14 +23,24 @@ final class Wsse implements Authentication
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $hashAlgorithm;
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $hashAlgorithm To use a better hashing algorithm than the weak sha1, pass the algorithm to use, e.g. "sha512"
|
||||
*/
|
||||
public function __construct($username, $password)
|
||||
public function __construct($username, $password, $hashAlgorithm = 'sha1')
|
||||
{
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
if (false === in_array($hashAlgorithm, hash_algos())) {
|
||||
throw new InvalidArgumentException(sprintf('Unaccepted hashing algorithm: %s', $hashAlgorithm));
|
||||
}
|
||||
$this->hashAlgorithm = $hashAlgorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,10 +48,9 @@ final class Wsse implements Authentication
|
||||
*/
|
||||
public function authenticate(RequestInterface $request)
|
||||
{
|
||||
// TODO: generate better nonce?
|
||||
$nonce = substr(md5(uniqid(uniqid().'_', true)), 0, 16);
|
||||
$created = date('c');
|
||||
$digest = base64_encode(sha1(base64_decode($nonce).$created.$this->password, true));
|
||||
$digest = base64_encode(hash($this->hashAlgorithm, base64_decode($nonce).$created.$this->password, true));
|
||||
|
||||
$wsse = sprintf(
|
||||
'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
|
||||
|
||||
Reference in New Issue
Block a user