Skip to content

Commit 1898c5d

Browse files
author
Alexander Schrijver
committed
Add logging for requests.
1 parent e3b11ee commit 1898c5d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/onelogin/saml2/auth.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
1212
"""
1313

14+
import logging
1415
import xmlsec
1516

17+
1618
from onelogin.saml2 import compat
1719
from onelogin.saml2.authn_request import OneLogin_Saml2_Authn_Request
1820
from onelogin.saml2.constants import OneLogin_Saml2_Constants
@@ -24,6 +26,9 @@
2426
from onelogin.saml2.xmlparser import tostring
2527

2628

29+
logger = logging.getLogger(__name__)
30+
31+
2732
class OneLogin_Saml2_Auth(object):
2833
"""
2934
@@ -389,22 +394,29 @@ def _create_authn_request(
389394

390395
def login_post(self, return_to=None, **authn_kwargs):
391396
authn_request = self._create_authn_request(**authn_kwargs)
397+
398+
url = self.get_sso_url()
399+
data = authn_request.get_request(deflate=False, base64_encode=False)
392400
saml_request = OneLogin_Saml2_Utils.b64encode(
393401
OneLogin_Saml2_Utils.add_sign(
394-
authn_request.get_request(deflate=False, base64_encode=False),
402+
data,
395403
self.__settings.get_sp_key(), self.__settings.get_sp_cert(),
396404
sign_algorithm=OneLogin_Saml2_Constants.RSA_SHA256,
397405
digest_algorithm=OneLogin_Saml2_Constants.SHA256,),
398406

399407
)
408+
logger.debug(
409+
"Returning form-data to the user for a AuthNRequest to %s with SAMLRequest %s",
410+
url, OneLogin_Saml2_Utils.b64decode(saml_request).decode('utf-8')
411+
)
400412
parameters = {'SAMLRequest': saml_request}
401413

402414
if return_to is not None:
403415
parameters['RelayState'] = return_to
404416
else:
405417
parameters['RelayState'] = OneLogin_Saml2_Utils.get_self_url_no_query(self.__request_data)
406418

407-
return self.get_sso_url(), parameters
419+
return url, parameters
408420

409421
def login(self, return_to=None, **authn_kwargs):
410422
"""

0 commit comments

Comments
 (0)