xiaowang/kirby/src/Http/Request/Auth.php

56 lines
978 B
PHP
Raw Normal View History

2022-08-31 16:08:03 +02:00
<?php
namespace Kirby\Http\Request;
2023-04-14 16:30:28 +02:00
use SensitiveParameter;
2022-08-31 16:08:03 +02:00
/**
* 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
*/
2022-12-19 16:26:24 +01:00
protected string $data;
2022-08-31 16:08:03 +02:00
/**
* Constructor
*/
2023-04-14 16:30:28 +02:00
public function __construct(
#[SensitiveParameter]
string $data
) {
2022-08-31 16:08:03 +02:00
$this->data = $data;
}
/**
* Converts the object to a string
*/
public function __toString(): string
{
return ucfirst($this->type()) . ' ' . $this->data();
}
/**
* Returns the raw authentication data after the
* first space in the `Authorization` header
*/
public function data(): string
{
return $this->data;
}
/**
* Returns the name of the auth type (lowercase)
*/
abstract public function type(): string;
}