Skip to content

Commit 7d43518

Browse files
author
Alexander Schrijver
committed
Move storing the response data into its own method in the Auth class
This makes it easier to incorporate other response methods into the code.
1 parent 615bb73 commit 7d43518

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/onelogin/saml2/auth.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ def set_strict(self, value):
9494
assert isinstance(value, bool)
9595
self.__settings.set_strict(value)
9696

97+
def store_valid_response(self, response):
98+
self.__attributes = response.get_attributes()
99+
self.__friendlyname_attributes = response.get_friendlyname_attributes()
100+
self.__nameid = response.get_nameid()
101+
self.__nameid_format = response.get_nameid_format()
102+
self.__nameid_nq = response.get_nameid_nq()
103+
self.__nameid_spnq = response.get_nameid_spnq()
104+
self.__session_index = response.get_session_index()
105+
self.__session_expiration = response.get_session_not_on_or_after()
106+
self.__last_message_id = response.get_id()
107+
self.__last_assertion_id = response.get_assertion_id()
108+
self.__last_authn_contexts = response.get_authn_contexts()
109+
self.__authenticated = True
110+
self.__last_assertion_not_on_or_after = response.get_assertion_not_on_or_after()
111+
97112
def process_response(self, request_id=None):
98113
"""
99114
Process the SAML Response sent by the IdP.
@@ -112,20 +127,7 @@ def process_response(self, request_id=None):
112127
self.__last_response = response.get_xml_document()
113128

114129
if response.is_valid(self.__request_data, request_id):
115-
self.__attributes = response.get_attributes()
116-
self.__friendlyname_attributes = response.get_friendlyname_attributes()
117-
self.__nameid = response.get_nameid()
118-
self.__nameid_format = response.get_nameid_format()
119-
self.__nameid_nq = response.get_nameid_nq()
120-
self.__nameid_spnq = response.get_nameid_spnq()
121-
self.__session_index = response.get_session_index()
122-
self.__session_expiration = response.get_session_not_on_or_after()
123-
self.__last_message_id = response.get_id()
124-
self.__last_assertion_id = response.get_assertion_id()
125-
self.__last_authn_contexts = response.get_authn_contexts()
126-
self.__authenticated = True
127-
self.__last_assertion_not_on_or_after = response.get_assertion_not_on_or_after()
128-
130+
self.store_valid_response(response)
129131
else:
130132
self.__errors.append('invalid_response')
131133
self.__error_reason = response.get_error()

0 commit comments

Comments
 (0)