Skip to content

Commit 94f56c9

Browse files
committed
Add an alert about the monkey-patch of pysaml2
- Include fix IdentityPython/pysaml2#812
1 parent 8ae1687 commit 94f56c9

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ source env/bin/activate
5858
pip install djangosaml2-spid
5959
````
6060

61+
⚠️ djangosaml2-spid uses a *monkey-patch* version of the pysaml2 library that fixes
62+
some limitations or small bugs that can affect SPID data. Patches are applied only
63+
once after the app is ready to run. Take a look at module `djangosaml2_spid._saml2`
64+
for patches code and references.
65+
66+
6167
Your example saml2 configuration is in `spid_config/spid_settings.py`.
6268
See djangosaml2 and pysaml2 official docs for clarifications.
6369

src/djangosaml2_spid/_saml2.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
DISABLE_WEAK_XMLSEC_ALGORITHMS = True # https://github.com/IdentityPython/pysaml2/pull/628
55
ADD_XSD_DATE_TYPE = True # https://github.com/IdentityPython/pysaml2/pull/602
6-
PATCH_RESPONSE_VERIFY = True # https://github.com/peppelinux/pysaml2/commit/8bdbbdf41ce63a37d3ba02c8f48a3dba0217d463
6+
PATCH_RESPONSE_VERIFY = True # https://github.com/IdentityPython/pysaml2/pull/812
77

88

99
def pysaml2_patch():
@@ -167,27 +167,28 @@ def _wrong_type_value(xsd, value):
167167
AttributeValueBase.set_text = set_text
168168

169169
if PATCH_RESPONSE_VERIFY:
170-
logger = logging.getLogger(__name__)
170+
logger = logging.getLogger(StatusResponse.__module__)
171171

172172
def _verify(self):
173173
if self.request_id and self.in_response_to and \
174174
self.in_response_to != self.request_id:
175175
logger.error("Not the id I expected: %s != %s",
176176
self.in_response_to, self.request_id)
177177
return None
178+
178179
if self.response.version != "2.0":
179-
_ver = float(self.response.version)
180-
if _ver < 2.0:
180+
if float(self.response.version) < 2.0:
181181
raise RequestVersionTooLow()
182182
else:
183183
raise RequestVersionTooHigh()
184184

185-
destination = self.response.destination
186-
if self.asynchop and destination:
187-
# Destination must be present
188-
if destination not in self.return_addrs:
185+
if self.asynchop:
186+
if not getattr(self.response, 'destination'):
187+
logger.error("Invalid response destination in asynchop")
188+
return None
189+
elif self.response.destination not in self.return_addrs:
189190
logger.error(
190-
f"{destination} not in {self.return_addrs}"
191+
f"{self.response.destination} not in {self.return_addrs}"
191192
)
192193
return None
193194

0 commit comments

Comments
 (0)