From cf595d9f568c4cdc9387452978d59d217f7db687 Mon Sep 17 00:00:00 2001 From: Dan Villiom Podlaski Christiansen Date: Tue, 28 Feb 2023 16:22:46 +0100 Subject: [PATCH] Don't fail, but issue a warning when detecting redirect fails --- openconnect_sso/authenticator.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/openconnect_sso/authenticator.py b/openconnect_sso/authenticator.py index b9b333b..804b243 100644 --- a/openconnect_sso/authenticator.py +++ b/openconnect_sso/authenticator.py @@ -58,10 +58,18 @@ async def authenticate(self, display_mode): def _detect_authentication_target_url(self): # Follow possible redirects in a GET request # Authentication will occcur using a POST request on the final URL - response = self.session.get(self.host.vpn_url, verify=False) - response.raise_for_status() - self.host.address = response.url logger.debug("Auth target url", url=self.host.vpn_url) + response = self.session.get(self.host.vpn_url, verify=False) + if response.ok: + self.host.address = response.url + else: + logger.warn( + "Failed to check for redirect", + reason=response.reason, + error=response.status_code, + response=response, + ) + self.host.address = self.host.vpn_url def _start_authentication(self): request = _create_auth_init_request(self.host, self.host.vpn_url, self.version)