Commit 93f018e7 authored by Vincent Pelletier's avatar Vincent Pelletier

erp5_oauth2_authorisation: Factorise MultiFernet instanciation

parent c5410570
...@@ -1022,10 +1022,10 @@ class OAuth2AuthorisationServerConnector(XMLObject): ...@@ -1022,10 +1022,10 @@ class OAuth2AuthorisationServerConnector(XMLObject):
Only Zope-based request authentication is supported Only Zope-based request authentication is supported
(ex: "Authorization: Basic ..." request header). (ex: "Authorization: Basic ..." request header).
""" """
multi_fernet = self.__getLoginRetryURLMultiFernet()
# Retrieve posted field, validate signature and extract the url.
try: try:
login_retry_url = self.__getLoginRetryURLMultiFernet().decrypt( login_retry_url = multi_fernet.decrypt(REQUEST.form['login_retry_url'])
REQUEST.form['login_retry_url'],
)
except (fernet.InvalidToken, TypeError, KeyError): except (fernet.InvalidToken, TypeError, KeyError):
# No login_retry_url provided or its value is unusable: if this is a GET # No login_retry_url provided or its value is unusable: if this is a GET
# request (trying to display a login form), use the current URL. # request (trying to display a login form), use the current URL.
...@@ -1039,7 +1039,7 @@ class OAuth2AuthorisationServerConnector(XMLObject): ...@@ -1039,7 +1039,7 @@ class OAuth2AuthorisationServerConnector(XMLObject):
def getSignedLoginRetryUrl(): def getSignedLoginRetryUrl():
if login_retry_url is None: if login_retry_url is None:
return None return None
return self.__getLoginRetryURLMultiFernet().encrypt(login_retry_url) return multi_fernet.encrypt(login_retry_url)
return _ERP5AuthorisationEndpoint( return _ERP5AuthorisationEndpoint(
server_connector_path=self.getPath(), server_connector_path=self.getPath(),
zope_request=REQUEST, zope_request=REQUEST,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment