Upgrade to 3.7.0

This commit is contained in:
Bastian Allgeier
2022-06-27 10:02:22 +02:00
parent 0751a6510d
commit 1c22148d7b
674 changed files with 5052 additions and 3082 deletions

61
kirby/src/Http/Request/Auth.php Executable file
View File

@@ -0,0 +1,61 @@
<?php
namespace Kirby\Http\Request;
/**
* Base class for auth types
*
* @package Kirby Http
* @author Lukas Bestle <lukas@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
abstract class Auth
{
/**
* Raw authentication data after the first space
* in the `Authorization` header
*
* @var string
*/
protected $data;
/**
* Constructor
*
* @param string $data
*/
public function __construct(string $data)
{
$this->data = $data;
}
/**
* Converts the object to a string
*
* @return string
*/
public function __toString(): string
{
return ucfirst($this->type()) . ' ' . $this->data();
}
/**
* Returns the raw authentication data after the
* first space in the `Authorization` header
*
* @return string
*/
public function data(): string
{
return $this->data;
}
/**
* Returns the name of the auth type (lowercase)
*
* @return string
*/
abstract public function type(): string;
}

17
kirby/src/Http/Request/Auth/BasicAuth.php Normal file → Executable file
View File

@@ -2,12 +2,19 @@
namespace Kirby\Http\Request\Auth;
use Kirby\Http\Request\Auth;
use Kirby\Toolkit\Str;
/**
* Basic Authentication
* HTTP basic authentication data
*
* @package Kirby Http
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class BasicAuth extends BearerAuth
class BasicAuth extends Auth
{
/**
* @var string
@@ -27,11 +34,11 @@ class BasicAuth extends BearerAuth
/**
* @param string $token
*/
public function __construct(string $token)
public function __construct(string $data)
{
parent::__construct($token);
parent::__construct($data);
$this->credentials = base64_decode($token);
$this->credentials = base64_decode($data);
$this->username = Str::before($this->credentials, ':');
$this->password = Str::after($this->credentials, ':');
}

39
kirby/src/Http/Request/Auth/BearerAuth.php Normal file → Executable file
View File

@@ -2,36 +2,19 @@
namespace Kirby\Http\Request\Auth;
use Kirby\Http\Request\Auth;
/**
* Bearer Auth
* Bearer token authentication data
*
* @package Kirby Http
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class BearerAuth
class BearerAuth extends Auth
{
/**
* @var string
*/
protected $token;
/**
* Creates a new Bearer Auth object
*
* @param string $token
*/
public function __construct(string $token)
{
$this->token = $token;
}
/**
* Converts the object to a string
*
* @return string
*/
public function __toString(): string
{
return ucfirst($this->type()) . ' ' . $this->token();
}
/**
* Returns the authentication token
*
@@ -39,7 +22,7 @@ class BearerAuth
*/
public function token(): string
{
return $this->token;
return $this->data;
}
/**

View File

@@ -0,0 +1,48 @@
<?php
namespace Kirby\Http\Request\Auth;
use Kirby\Cms\App;
use Kirby\Http\Request\Auth;
/**
* Authentication data using Kirby's session
*
* @package Kirby Http
* @author Lukas Bestle <lukas@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class SessionAuth extends Auth
{
/**
* Tries to return the session object
*
* @return \Kirby\Session\Session
*/
public function session()
{
return App::instance()->sessionHandler()->getManually($this->data);
}
/**
* Returns the session token
*
* @return string
*/
public function token(): string
{
return $this->data;
}
/**
* Returns the authentication type
*
* @return string
*/
public function type(): string
{
return 'session';
}
}

0
kirby/src/Http/Request/Body.php Normal file → Executable file
View File

0
kirby/src/Http/Request/Data.php Normal file → Executable file
View File

0
kirby/src/Http/Request/Files.php Normal file → Executable file
View File

0
kirby/src/Http/Request/Query.php Normal file → Executable file
View File