diff options
author | peppelinux <giuseppe.demarco@unical.it> | 2020-12-26 15:50:35 +0100 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-12-29 18:33:24 +0200 |
commit | d2e775aa1af2a2a350a6eb0cfe2adb3c34693b57 (patch) | |
tree | 9085f1fa42342288ce65e96d8b227df252a6eba9 /src | |
parent | ca0696cec41cdf968f5f9417ba8d6ee5406fa114 (diff) | |
download | pysaml2-d2e775aa1af2a2a350a6eb0cfe2adb3c34693b57.tar.gz |
Fix StatusResponse when return_addrs is not set
`return_addrs` is set to `None` by default in `StatusResponse.__init__()`.
If it is not filled with a proper value then `self._verify()` will fail because it tries
to iterate over a `None` object.
This PR avoids this error, by setting the `return_addrs` to `[]`.
```
if self.asynchop:
if (
self.response.destination
and self.response.destination not in self.return_addrs
):
logger.error("%s not in %s", self.response.destination, self.return_addrs)
return None
```
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/saml2/response.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/saml2/response.py b/src/saml2/response.py index 5fd8043a..50e4f6b0 100644 --- a/src/saml2/response.py +++ b/src/saml2/response.py @@ -255,7 +255,7 @@ class StatusResponse(object): def __init__(self, sec_context, return_addrs=None, timeslack=0, request_id=0, asynchop=True, conv_info=None): self.sec = sec_context - self.return_addrs = return_addrs + self.return_addrs = return_addrs or [] self.timeslack = timeslack self.request_id = request_id @@ -402,10 +402,11 @@ class StatusResponse(object): raise RequestVersionTooHigh() if self.asynchop: - if self.response.destination and \ - self.response.destination not in self.return_addrs: - logger.error("%s not in %s", self.response.destination, - self.return_addrs) + if ( + self.response.destination + and self.response.destination not in self.return_addrs + ): + logger.error("%s not in %s", self.response.destination, self.return_addrs) return None valid = self.issue_instant_ok() and self.status_ok() |