Skip to content

Commit ff8eba7

Browse files
committed
Add eIDAS SP config sp_type validation
- Adds validation check for eIDAS SP to verify that sp_type has been set (MUST be set) and that it is set to a valid value (private/public) as stated in eIDAS SAML Message Format v.1.2 spec - Adds tests for the aforementioned checks
1 parent c84a36d commit ff8eba7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/saml2/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,9 @@ def validate(self):
682682
"metadata":
683683
parse.urlparse(self.entityid).scheme == "https",
684684
"authn_requests_signed MUST be set to True":
685-
getattr(self, "_sp_authn_requests_signed", None) is True
685+
getattr(self, "_sp_authn_requests_signed", None) is True,
686+
"sp_type MUST be set to 'public' or 'private'":
687+
getattr(self, "_sp_sp_type", None) in ("public", "private")
686688
}
687689

688690
if not all(error_validators.values()):

tests/eidas/test_sp.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,13 @@ def test_authn_requests_signed_unassigned(self, config):
283283

284284
self.assert_validation_error(config)
285285

286+
def test_sp_type_undeclared(self, config):
287+
del config["service"]["sp"]["sp_type"]
288+
289+
self.assert_validation_error(config)
290+
291+
def test_sp_type_invalid_value(self, config):
292+
config["service"]["sp"]["sp_type"] = "test value"
293+
294+
self.assert_validation_error(config)
295+

0 commit comments

Comments
 (0)