Skip to content

Commit 2bb7c59

Browse files
committed
Ensure that trust_marks are not possible in subordinate statements
1 parent a7ea7b3 commit 2bb7c59

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/Federation/EntityStatement.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ public function getTrustMarks(): ?TrustMarksClaimBag
237237
throw new EntityStatementException('Invalid Trust Marks claim.');
238238
}
239239

240+
// It MUST NOT be present in Subordinate Statements.
241+
if (!$this->isConfiguration()) {
242+
throw new EntityStatementException('Trust Marks claim encountered in configuration statement.');
243+
}
244+
240245
$trustMarkClaimBag = $this->claimFactory->forFederation()->buildTrustMarksClaimBag();
241246

242247
while (is_array($trustMarkClaimData = array_pop($trustMarksClaims))) {

tests/src/Federation/EntityStatementTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ public function testIsNotConfiguration(): void
216216
$this->signatureMock->method('getProtectedHeader')->willReturn($this->sampleHeader);
217217
$payload = $this->validPayload;
218218
$payload['iss'] = 'something-else';
219-
// Authority hints should not be present if not configuration.
219+
// Authority hints, trust marks should not be present if not configuration.
220220
unset($payload['authority_hints']);
221+
unset($payload['trust_marks']);
221222
$this->jsonHelperMock->method('decode')->willReturn($payload);
222223

223224
$this->assertFalse($this->sut()->isConfiguration());
@@ -525,6 +526,7 @@ public function testCanGetMetadataPolicyClaim(): void
525526
$payload = $this->validPayload;
526527
$payload['sub'] = 'something-else';
527528
unset($payload['authority_hints']);
529+
unset($payload['trust_marks']);
528530
$payload['metadata_policy'] = [
529531
'openid_relying_party' => [
530532
'contacts' => [

0 commit comments

Comments
 (0)