Skip to content

Commit 15fbb73

Browse files
committed
Ensure assertions containing an AuthzDecisionStatement also contain a subject
1 parent 5005c40 commit 15fbb73

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/XML/saml/Assertion.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ public function __construct(
9595
return $statement instanceof AuthnStatement;
9696
}));
9797

98+
if (count($authnStatements) > 0) {
99+
Assert::notNull(
100+
$subject,
101+
"Assertions containing an <AuthnStatement> element MUST contain a <Subject> element.",
102+
ProtocolViolationException::class,
103+
);
104+
}
105+
106+
$authzDecisionStatements = array_values(array_filter($statements, function ($statement) {
107+
return $statement instanceof AuthzDecisionStatement;
108+
}));
109+
110+
if (count($authzDecisionStatements) > 0) {
111+
Assert::notNull(
112+
$subject,
113+
"Assertions containing an <AuthzDecisionStatement> element MUST contain a <Subject> element.",
114+
ProtocolViolationException::class,
115+
);
116+
}
117+
98118
$attributeStatements = array_values(array_filter($statements, function ($statement) {
99119
return $statement instanceof AttributeStatement;
100120
}));

0 commit comments

Comments
 (0)