<pre style='margin:0'>
Dan Villiom Podlaski Christiansen (danchr) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/cc0a3fffd8b5856ac67e7c69f75b4abff21aa6e7">https://github.com/macports/macports-ports/commit/cc0a3fffd8b5856ac67e7c69f75b4abff21aa6e7</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit cc0a3fffd8b5856ac67e7c69f75b4abff21aa6e7
</span>Author: Dan Villiom Podlaski Christiansen <danchr@gmail.com>
AuthorDate: Wed Mar 8 12:52:11 2023 +0100
<span style='display:block; white-space:pre;color:#404040;'> openconnect-sso: add legacy variant
</span>---
net/openconnect-sso/Portfile | 5 ++
net/openconnect-sso/files/legacy+redirect.diff | 104 +++++++++++++++++++++++++
2 files changed, 109 insertions(+)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/net/openconnect-sso/Portfile b/net/openconnect-sso/Portfile
</span><span style='display:block; white-space:pre;color:#808080;'>index 503b25ac18b..37ea55051bf 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/net/openconnect-sso/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/net/openconnect-sso/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -45,3 +45,8 @@ depends_lib-append port:openconnect \
</span>
patch.pre_args -p1
patchfiles poetry-core.diff
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+variant legacy description {Add patch that enables legacy redirection with OpenSSL 3} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ patchfiles-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ legacy+redirect.diff
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/net/openconnect-sso/files/legacy+redirect.diff b/net/openconnect-sso/files/legacy+redirect.diff
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000000..08820ac3002
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/net/openconnect-sso/files/legacy+redirect.diff
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,104 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From b53695bbe1c2f5f87ea43455f826d82e14e9b6b1 Mon Sep 17 00:00:00 2001
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From: Dan Villiom Podlaski Christiansen <danchr@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Date: Tue, 28 Feb 2023 16:22:00 +0100
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Subject: [PATCH 1/2] Use an insecure request when detecting redirects, and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ allow legacy connect
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+---
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ openconnect_sso/authenticator.py | 30 +++++++++++++++++++++++++++++-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 1 file changed, 29 insertions(+), 1 deletion(-)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git a/openconnect_sso/authenticator.py b/openconnect_sso/authenticator.py
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 2cd0456..54ee683 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- a/openconnect_sso/authenticator.py
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ b/openconnect_sso/authenticator.py
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -2,6 +2,9 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ import requests
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ import structlog
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ from lxml import etree, objectify
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++import ssl
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++from requests import adapters
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++import urllib3
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ from openconnect_sso.saml_authenticator import authenticate_in_browser
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -54,7 +57,7 @@ async def authenticate(self, display_mode):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def _detect_authentication_target_url(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Follow possible redirects in a GET request
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Authentication will occcur using a POST request on the final URL
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- response = requests.get(self.host.vpn_url)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ response = self.session.get(self.host.vpn_url, verify=False)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ response.raise_for_status()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.host.address = response.url
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ logger.debug("Auth target url", url=self.host.vpn_url)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -89,8 +92,33 @@ class AuthResponseError(AuthenticationError):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ pass
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class LegacyHTTPAdapter(adapters.HTTPAdapter):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ """“Transport adapter” that allows us to use legacy renogation.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Such renegotiation is disabled by default in OpenSSL 3.0. This
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ suppresses errors such as:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ legacy renegotiation disabled (_ssl.c:992)')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ """
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ def init_poolmanager(self, connections, maxsize, block=False):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ctx = urllib3.util.ssl_.create_urllib3_context()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ctx.load_default_certs()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ctx.options |= 0x4 # ssl.OP_LEGACY_SERVER_CONNECT
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.poolmanager = urllib3.PoolManager(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ssl_context=ctx,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ num_pools=connections,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ maxsize=maxsize,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ block=block,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def create_http_session(proxy):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ session = requests.Session()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ session.mount("https://", LegacyHTTPAdapter())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ session.proxies = {"http": proxy, "https": proxy}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ session.headers.update(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From e5d7e7db696fff90ceb81750e08726304b7fff0a Mon Sep 17 00:00:00 2001
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From: Dan Villiom Podlaski Christiansen <danchr@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Date: Tue, 28 Feb 2023 16:22:46 +0100
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Subject: [PATCH 2/2] Don't fail, but issue a warning when detecting redirect
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ fails
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+---
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ openconnect_sso/authenticator.py | 14 +++++++++++---
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 1 file changed, 11 insertions(+), 3 deletions(-)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git a/openconnect_sso/authenticator.py b/openconnect_sso/authenticator.py
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index 54ee683..ac3c14a 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- a/openconnect_sso/authenticator.py
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ b/openconnect_sso/authenticator.py
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -57,10 +57,18 @@ async def authenticate(self, display_mode):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def _detect_authentication_target_url(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Follow possible redirects in a GET request
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Authentication will occcur using a POST request on the final URL
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- response = self.session.get(self.host.vpn_url, verify=False)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- response.raise_for_status()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- self.host.address = response.url
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ logger.debug("Auth target url", url=self.host.vpn_url)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ response = self.session.get(self.host.vpn_url, verify=False)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if response.ok:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.host.address = response.url
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ logger.warn(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "Failed to check for redirect",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ reason=response.reason,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ error=response.status_code,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ response=response,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.host.address = self.host.vpn_url
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def _start_authentication(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ request = _create_auth_init_request(self.host, self.host.vpn_url)
</span></pre><pre style='margin:0'>
</pre>