Skip to content

Commit cbaaa8f

Browse files
committed
Add SP config validation for https entityid
- Adds check that entityid is an https url based on eIDAS SAML Message Format v.1.2. There's no way of really validating that the url is correct (there are many scenarios for false positives and negatives) so we only check that the url scheme is https as the specs define - Adds test for the above rule
1 parent c8c7864 commit cbaaa8f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/saml2/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import sys
1010
from functools import partial
1111
import re
12+
from urllib import parse
1213
from iso3166 import countries
1314

1415
import six
@@ -676,7 +677,10 @@ def validate(self):
676677
"application_identifier MUST be in the form <vendor name>:<software "
677678
"identifier>:<major-version>.<minor-version>[.<patch-version>]":
678679
self.validate_application_identifier_format(
679-
self.get_application_identifier())
680+
self.get_application_identifier()),
681+
"entityid MUST be an HTTPS URL pointing to the location of its published "
682+
"metadata":
683+
parse.urlparse(self.entityid).scheme == "https"
680684
}
681685

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

tests/eidas/sp_conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathutils import xmlsec_path
33

44
CONFIG = {
5-
"entityid": "urn:mace:example.com:saml:roland:sp",
5+
"entityid": "https://example.org",
66
"name": "urn:mace:example.com:saml:roland:sp",
77
"description": "My own SP",
88
"service": {

tests/eidas/test_sp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,12 @@ def test_support_contact_person_empty_email(self,
336336

337337
with pytest.raises(ConfigValidationError):
338338
conf.validate()
339+
340+
def test_entityid_no_https(self, config):
341+
config["entityid"] = "urn:mace:example.com:saml:roland:idp"
342+
343+
conf = eIDASSPConfig()
344+
conf.load(config)
345+
346+
with pytest.raises(ConfigValidationError):
347+
conf.validate()

0 commit comments

Comments
 (0)