1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2017 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OAuth2Framework\Bundle\Server\Controller; |
15
|
|
|
|
16
|
|
|
use Interop\Http\Factory\ResponseFactoryInterface; |
17
|
|
|
use Interop\Http\ServerMiddleware\DelegateInterface; |
18
|
|
|
use Interop\Http\ServerMiddleware\MiddlewareInterface; |
19
|
|
|
use Jose\Object\JWKSetInterface; |
20
|
|
|
use Jose\SignerInterface; |
21
|
|
|
use OAuth2Framework\Bundle\Server\Service\MetadataBuilder; |
22
|
|
|
use OAuth2Framework\Component\Server\Endpoint\Metadata\MetadataEndpoint; |
23
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
24
|
|
|
|
25
|
|
|
class MetadataController implements MiddlewareInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var MetadataEndpoint |
29
|
|
|
*/ |
30
|
|
|
private $metadataEndpoint; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* MetadataController constructor. |
34
|
|
|
* |
35
|
|
|
* @param ResponseFactoryInterface $responseFactory |
36
|
|
|
* @param MetadataBuilder $metadataBuilder |
37
|
|
|
*/ |
38
|
|
|
public function __construct(ResponseFactoryInterface $responseFactory, MetadataBuilder $metadataBuilder) |
39
|
|
|
{ |
40
|
|
|
$metadata = $metadataBuilder->getMetadata(); |
41
|
|
|
$this->metadataEndpoint = new MetadataEndpoint($responseFactory, $metadata); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param SignerInterface $signer |
46
|
|
|
* @param JWKSetInterface $signatureKeySet |
47
|
|
|
* @param string $signatureAlgorithm |
48
|
|
|
*/ |
49
|
|
|
public function enableSignedMetadata(SignerInterface $signer, string $signatureAlgorithm, JWKSetInterface $signatureKeySet) |
50
|
|
|
{ |
51
|
|
|
$this->metadataEndpoint->enableSignedMetadata($signer, $signatureAlgorithm, $signatureKeySet); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
public function process(ServerRequestInterface $request, DelegateInterface $delegate) |
58
|
|
|
{ |
59
|
|
|
return $this->metadataEndpoint->process($request, $delegate); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|