|
48 | 48 | from saml2.ident import code, decode |
49 | 49 | from saml2.sigver import MissingKey |
50 | 50 | from saml2.s_utils import UnsupportedBinding |
| 51 | +from saml2.request import AuthnRequest |
51 | 52 | from saml2.response import ( |
52 | 53 | StatusError, StatusAuthnFailed, SignatureError, StatusRequestDenied, |
53 | 54 | UnsolicitedResponse, StatusNoAuthnContext, |
@@ -147,10 +148,10 @@ def login(request, |
147 | 148 |
|
148 | 149 | kwargs = {} |
149 | 150 | # pysaml needs a string otherwise: "cannot serialize True (type bool)" |
150 | | - if getattr(conf, '_sp_force_authn'): |
| 151 | + if getattr(conf, '_sp_force_authn', False): |
151 | 152 | kwargs['force_authn'] = "true" |
152 | | - if getattr(conf, '_sp_allow_create', "false"): |
153 | | - kwargs['allow_create'] = "true" |
| 153 | + if hasattr(conf, '_sp_allow_create'): |
| 154 | + kwargs['allow_create'] = str(conf._sp_allow_create is True).lower() |
154 | 155 |
|
155 | 156 | # is a embedded wayf needed? |
156 | 157 | idps = available_idps(conf) |
@@ -226,6 +227,9 @@ def login(request, |
226 | 227 | **kwargs) |
227 | 228 | try: |
228 | 229 | if PY3: |
| 230 | + if isinstance(request_xml, AuthnRequest): |
| 231 | + # request_xml will be an instance of AuthnRequest if the message is not signed |
| 232 | + request_xml = str(request_xml) |
229 | 233 | saml_request = base64.b64encode(binary_type(request_xml, 'UTF-8')).decode('utf-8') |
230 | 234 | else: |
231 | 235 | saml_request = base64.b64encode(binary_type(request_xml)) |
|
0 commit comments