Skip to content

Commit 74dc24d

Browse files
nsmoooosec00kiemon5ter
authored andcommitted
Add support for errorURL to be exposed in metadata for IdP
errorURL can be used to redirect a user's browser in the event of a failure. Most part of this exist already in this project. But was not exposed in the metadata generated from the configuration.
1 parent 023fc4a commit 74dc24d

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

docs/howto/config.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,19 @@ Example::
13201320
},
13211321
},
13221322

1323+
error_url
1324+
"""""""""
1325+
1326+
The URL to which the user's browser may be redirected in the event of a failure.
1327+
1328+
Example::
1329+
1330+
"service":
1331+
"idp": {
1332+
"error_url": "http://localhost:8088/error_page",
1333+
},
1334+
}
1335+
13231336
only_use_keys_in_metadata
13241337
"""""""""""""""""""""""""
13251338

src/saml2/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"domain",
121121
"name_qualifier",
122122
"edu_person_targeted_id",
123+
"error_url",
123124
]
124125

125126
PDP_ARGS = ["endpoints", "name_form", "name_id_format"]

src/saml2/metadata.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,10 @@ def do_idpsso_descriptor(conf, cert=None, enc_cert=None):
583583
except KeyError:
584584
setattr(idpsso, key, DEFAULTS[key])
585585

586+
error_url = conf.getattr("error_url", "idp")
587+
if error_url:
588+
idpsso.error_url = error_url
589+
586590
return idpsso
587591

588592

tests/test_31_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
},
104104
"urn:mace:umu.se:saml:roland:sp": None,
105105
},
106+
"error_url": "http://localhost:8080/error",
106107
}
107108
},
108109
# "xmlsec_binary" : "/usr/local/bin/xmlsec1",
@@ -287,6 +288,9 @@ def test_idp_1():
287288
attribute_restrictions = c.getattr("policy", "idp").get_attribute_restrictions("")
288289
assert attribute_restrictions["edupersonaffiliation"][0].match("staff")
289290

291+
error_url = c.getattr("error_url", "idp")
292+
assert error_url == "http://localhost:8080/error"
293+
290294

291295
def test_idp_2():
292296
c = IdPConfig().load(IDP2)

tests/test_60_sp.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)