1 | <?php |
||
21 | final class ClientSecretBasic implements AuthenticationMethod |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $realm; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | private $secretLifetime; |
||
32 | |||
33 | /** |
||
34 | * ClientSecretBasic constructor. |
||
35 | * |
||
36 | * @param string $realm |
||
37 | * @param int $secretLifetime |
||
38 | */ |
||
39 | public function __construct(string $realm, int $secretLifetime = 0) |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | public function getSchemesParameters(): array |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function findClientIdAndCredentials(ServerRequestInterface $request, &$client_credentials = null): ? ClientId |
||
63 | { |
||
64 | $authorization_headers = $request->getHeader('Authorization'); |
||
65 | if (0 < count($authorization_headers)) { |
||
66 | foreach ($authorization_headers as $authorization_header) { |
||
67 | $clientId = $this->findClientIdAndCredentialsInAuthorizationHeader($authorization_header, $client_credentials); |
||
68 | if (null !== $clientId) { |
||
69 | return $clientId; |
||
70 | } |
||
71 | } |
||
72 | } |
||
73 | |||
74 | return null; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @param $authorization_header |
||
79 | * @param null $client_credentials |
||
80 | * |
||
81 | * @return ClientId|null |
||
82 | */ |
||
83 | private function findClientIdAndCredentialsInAuthorizationHeader($authorization_header, &$client_credentials = null) |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function checkClientConfiguration(DataBag $command_parameters, DataBag $validated_parameters): DataBag |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | public function isClientAuthenticated(Client $client, $client_credentials, ServerRequestInterface $request): bool |
||
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | public function getSupportedMethods(): array |
||
120 | { |
||
121 | return ['client_secret_basic']; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * @return string |
||
126 | */ |
||
127 | private function createClientSecret(): string |
||
131 | } |
||
132 |