|
5 | 5 | namespace SimpleSAML\Module\exampleattributeserver\Controller; |
6 | 6 |
|
7 | 7 | use DateInterval; |
| 8 | +use Nyholm\Psr7\Factory\Psr17Factory; |
8 | 9 | use SimpleSAML\{Configuration, Error, Logger}; |
9 | 10 | use SimpleSAML\HTTP\RunnableResponse; |
10 | 11 | use SimpleSAML\Metadata\MetaDataStorageHandler; |
|
29 | 30 | }; |
30 | 31 | use SimpleSAML\SAML2\XML\samlp\{AttributeQuery, Response}; |
31 | 32 | use SimpleSAML\XML\Utils\Random; |
| 33 | +use Symfony\Bridge\PsrHttpMessage\Factory\{HttpFoundationFactory, PsrHttpFactory}; |
32 | 34 | use Symfony\Component\HttpFoundation\Request; |
33 | 35 |
|
34 | 36 | /** |
@@ -77,15 +79,19 @@ public function setMetadataStorageHandler(MetaDataStorageHandler $handler): void |
77 | 79 | */ |
78 | 80 | public function main(/** @scrutinizer ignore-unused */ Request $request): RunnableResponse |
79 | 81 | { |
80 | | - $binding = Binding::getCurrentBinding(); |
81 | | - $query = $binding->receive(); |
82 | | - if (!($query instanceof AttributeQuery)) { |
| 82 | + $psr17Factory = new Psr17Factory(); |
| 83 | + $psrHttpFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory); |
| 84 | + $psrRequest = $psrHttpFactory->createRequest($request); |
| 85 | + |
| 86 | + $binding = Binding::getCurrentBinding($psrRequest); |
| 87 | + $message = $binding->receive($psrRequest); |
| 88 | + if (!($message instanceof AttributeQuery)) { |
83 | 89 | throw new Error\BadRequest('Invalid message received to AttributeQuery endpoint.'); |
84 | 90 | } |
85 | 91 |
|
86 | 92 | $idpEntityId = $this->metadataHandler->getMetaDataCurrentEntityID('saml20-idp-hosted'); |
87 | 93 |
|
88 | | - $issuer = $query->getIssuer(); |
| 94 | + $issuer = $message->getIssuer(); |
89 | 95 | if ($issuer === null) { |
90 | 96 | throw new Error\BadRequest('Missing <saml:Issuer> in <samlp:AttributeQuery>.'); |
91 | 97 | } else { |
@@ -130,7 +136,7 @@ public function main(/** @scrutinizer ignore-unused */ Request $request): Runnab |
130 | 136 | Logger::debug('No attributes requested - return all attributes.'); |
131 | 137 | $returnAttributes = $attributes; |
132 | 138 | } else { |
133 | | - foreach ($query->getAttributes() as $reqAttr) { |
| 139 | + foreach ($message->getAttributes() as $reqAttr) { |
134 | 140 | foreach ($attributes as $attr) { |
135 | 141 | if ($attr->getName() === $reqAttr->getName() && $attr->getNameFormat() === $reqAttr->getNameFormat()) { |
136 | 142 | // The requested attribute is available |
@@ -159,14 +165,14 @@ public function main(/** @scrutinizer ignore-unused */ Request $request): Runnab |
159 | 165 | issueInstant: $clock->now(), |
160 | 166 | id: (new Random())->generateID(), |
161 | 167 | subject: Subject( |
162 | | - identifier: $query->getNameID(), |
| 168 | + identifier: $message->getNameID(), |
163 | 169 | subjectConfirmation: [ |
164 | 170 | new SubjectConfirmation( |
165 | 171 | method: C::CM_BEARER, |
166 | 172 | subjectConfirmationData: new SubjectConfirmationData( |
167 | 173 | notOnOrAfter: $clock->now()->add(new DateInterval('PT300S')), |
168 | 174 | recipient: $endpoint, |
169 | | - inResponseTo: $query->getId(), |
| 175 | + inResponseTo: $message->getId(), |
170 | 176 | ), |
171 | 177 | ), |
172 | 178 | ], |
@@ -196,7 +202,7 @@ public function main(/** @scrutinizer ignore-unused */ Request $request): Runnab |
196 | 202 | issuer: new Issuer($issuer), |
197 | 203 | id: (new Random())->generateID(), |
198 | 204 | version: '2.0', |
199 | | - inResponseTo: $query->getId(), |
| 205 | + inResponseTo: $message->getId(), |
200 | 206 | destination: $endpoint, |
201 | 207 | assertions: [$assertion], |
202 | 208 | ); |
|
0 commit comments