Debian Codegraph @

lib/3rdParty/composer/facile-it/php-openid-client/src/AuthMethod/ClientSecretPost.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Facile\OpenIDClient\AuthMethod;
6
7 use Facile\OpenIDClient\Client\ClientInterface as OpenIDClient;
8 use Facile\OpenIDClient\Exception\InvalidArgumentException;
9 use Psr\Http\Message\RequestInterface;
10 use Override;
11
12 use function array_merge;
13 use function http_build_query;
14
15 final class ClientSecretPost implements AuthMethodInterface
16 {
17 #[Override]
18 public function getSupportedMethod(): string
19 {
20 return 'client_secret_post';
21 }
22
23 #[Override]
24 public function createRequest(
25 RequestInterface $request,
26 OpenIDClient $client,
27 array $claims
28 ): RequestInterface {
29 $clientSecret = $client->getMetadata()->getClientSecret();
30
31 if (null === $clientSecret) {
32 throw new InvalidArgumentException($this->getSupportedMethod() . ' cannot be used without client_secret metadata');
33 }
34
35 $clientId = $client->getMetadata()->getClientId();
36
37 $claims = array_merge($claims, [
38 'client_id' => $clientId,
39 'client_secret' => $clientSecret,
40 ]);
41
42 $request->getBody()->write(http_build_query($claims));
43
44 return $request;
45 }
46 }