From cba78b4de786dd20d52ed2564d769d7e0347c77a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 17 Sep 2020 21:53:57 +0200 Subject: [PATCH] providers/*: fix launch_url not working --- passbook/core/models.py | 2 +- passbook/providers/oauth2/models.py | 7 +++---- passbook/providers/saml/models.py | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/passbook/core/models.py b/passbook/core/models.py index 1b4945c2e..9b1827454 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -160,7 +160,7 @@ class Application(PolicyBindingModel): if self.meta_launch_url: return self.meta_launch_url if self.provider: - return self.provider.launch_url + return self.get_provider().launch_url return None def get_provider(self) -> Optional[Provider]: diff --git a/passbook/providers/oauth2/models.py b/passbook/providers/oauth2/models.py index 8d904c83b..a12a25397 100644 --- a/passbook/providers/oauth2/models.py +++ b/passbook/providers/oauth2/models.py @@ -269,12 +269,11 @@ class OAuth2Provider(Provider): @property def launch_url(self) -> Optional[str]: """Guess launch_url based on first redirect_uri""" - if not self.redirect_uris: + if self.redirect_uris == "": return None - main_url = self.redirect_uris[0] + main_url = self.redirect_uris.split("\n")[0] launch_url = urlparse(main_url) - launch_url.path = "" - return launch_url.geturl() + return main_url.replace(launch_url.path, "") def form(self) -> Type[ModelForm]: from passbook.providers.oauth2.forms import OAuth2ProviderForm diff --git a/passbook/providers/saml/models.py b/passbook/providers/saml/models.py index 0a370bd75..5ec666d08 100644 --- a/passbook/providers/saml/models.py +++ b/passbook/providers/saml/models.py @@ -107,8 +107,7 @@ class SAMLProvider(Provider): def launch_url(self) -> Optional[str]: """Guess launch_url based on acs URL""" launch_url = urlparse(self.acs_url) - launch_url.path = "" - return launch_url.geturl() + return self.acs_url.replace(launch_url.path, "") def form(self) -> Type[ModelForm]: from passbook.providers.saml.forms import SAMLProviderForm