-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathEnvironment.php
More file actions
43 lines (37 loc) · 1.07 KB
/
Environment.php
File metadata and controls
43 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace Intervention\HttpAuth;
use Intervention\HttpAuth\Exceptions\AuthentificationException;
use Intervention\HttpAuth\Interfaces\EnvironmentInterface;
use Intervention\HttpAuth\Interfaces\TokenInterface;
class Environment implements EnvironmentInterface
{
/**
* Available auth tokens
*
* @var array<string>
*/
protected static array $tokenClassnames = [
Tokens\PhpAuthUser::class,
Tokens\HttpAuthentification::class,
Tokens\RedirectHttpAuthorization::class,
Tokens\PhpAuthDigest::class,
Tokens\HttpAuthorization::class,
];
/**
* {@inheritdoc}
*
* @see EnvironmentInterface::token()
*/
public static function token(): TokenInterface
{
foreach (static::$tokenClassnames as $classname) {
try {
return new $classname();
} catch (AuthentificationException) {
// try next
}
}
throw new AuthentificationException('Unable to parse authentication token.');
}
}