-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoneAuth.php
More file actions
34 lines (28 loc) · 787 Bytes
/
NoneAuth.php
File metadata and controls
34 lines (28 loc) · 787 Bytes
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
<?php
declare(strict_types=1);
namespace Arcp\Auth;
use Arcp\Messages\Session\Auth;
use Arcp\Messages\Session\PeerInfo;
/**
* `none` scheme (RFC §8.2). Only valid if the client requested
* `capabilities.anonymous: true` AND the runtime advertises it.
*/
final class NoneAuth implements AuthScheme
{
public function __construct(private readonly string $defaultPrincipal = 'anonymous')
{
}
#[\Override]
public function name(): string
{
return 'none';
}
#[\Override]
public function verify(Auth $auth, PeerInfo $client): AuthResult
{
if ($auth->scheme !== 'none') {
return AuthResult::reject('scheme mismatch');
}
return AuthResult::accept($client->principal ?? $this->defaultPrincipal);
}
}