Skip to content

Commit 6ec4b67

Browse files
committed
SAML bug fixes
* Fix error casting request_xml to bytes when request_xml is an object
1 parent 6525c99 commit 6ec4b67

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

djangosaml2/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
UnsolicitedResponse)
3838
from saml2.s_utils import UnsupportedBinding
3939
from saml2.sigver import MissingKey
40+
from saml2.samlp import AuthnRequest
4041
from saml2.validate import ResponseLifetimeExceed, ToEarly
4142
from saml2.xmldsig import ( # support for SHA1 is required by spec
4243
SIG_RSA_SHA1, SIG_RSA_SHA256)
@@ -205,6 +206,9 @@ def login(request,
205206
binding=binding,
206207
**kwargs)
207208
try:
209+
if isinstance(request_xml, AuthnRequest):
210+
# request_xml will be an instance of AuthnRequest if the message is not signed
211+
request_xml = str(request_xml)
208212
saml_request = base64.b64encode(bytes(request_xml, 'UTF-8')).decode('utf-8')
209213

210214
http_response = render(request, post_binding_form_template, {

0 commit comments

Comments
 (0)