Skip to content

Commit 51676dd

Browse files
Enforce encrypt_mandatory flag (#1)
1 parent 2d7d058 commit 51676dd

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/esaml_sp.erl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@ validate_assertion(Xml, DuplicateFun, SP = #esaml_sp{}) ->
259259
_ -> {error, bad_saml}
260260
end
261261
end,
262+
fun(X) ->
263+
if SP#esaml_sp.encrypt_mandatory ->
264+
case xmerl_xpath:string("/samlp:Response/saml:EncryptedAssertion", X, [{namespace, Ns}]) of
265+
[_] -> X; % Encrypted assertion found, continue
266+
_ -> {error, encryption_required}
267+
end;
268+
true -> X % Not mandatory, continue
269+
end
270+
end,
262271
fun(X) ->
263272
case xmerl_xpath:string("/samlp:Response/saml:EncryptedAssertion", X, [{namespace, Ns}]) of
264273
[A1] ->

0 commit comments

Comments
 (0)