From abe1476d2021099650d6c34c95ca9314cde907ba Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Wed, 6 May 2020 10:43:38 -0400 Subject: [PATCH 1/2] b64encode needs bytes here --- lib/galaxy/authnz/custos_authnz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/authnz/custos_authnz.py b/lib/galaxy/authnz/custos_authnz.py index 1056de21330..3a1f8b67be3 100644 --- a/lib/galaxy/authnz/custos_authnz.py +++ b/lib/galaxy/authnz/custos_authnz.py @@ -230,7 +230,7 @@ class CustosAuthnz(IdentityProvider): # Set custos endpoints clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret'] eps = requests.get(self.config['url'], - headers={"Authorization": "Basic %s" % base64.b64encode(clientIdAndSec)}, + headers={"Authorization": "Basic %s" % base64.b64encode(util.smart_str(clientIdAndSec))}, verify=False, params={'client_id': self.config['client_id']}) endpoints = eps.json() self.config['authorization_endpoint'] = endpoints['authorization_endpoint'] From 6cd54b2c7c8c646699ca878286ff28f7bd23d750 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Wed, 6 May 2020 13:13:16 -0400 Subject: [PATCH 2/2] Fix b64encoded bytestrings being added to request payload in python3 --- lib/galaxy/authnz/custos_authnz.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/authnz/custos_authnz.py b/lib/galaxy/authnz/custos_authnz.py index 3a1f8b67be3..9a54bba385c 100644 --- a/lib/galaxy/authnz/custos_authnz.py +++ b/lib/galaxy/authnz/custos_authnz.py @@ -197,7 +197,7 @@ class CustosAuthnz(IdentityProvider): token_endpoint, client_secret=client_secret, authorization_response=trans.request.url, - headers={"Authorization": "Basic %s" % base64.b64encode(clientIdAndSec)}, # for custos + headers={"Authorization": "Basic %s" % util.unicodify(base64.b64encode(util.smart_str(clientIdAndSec)))}, # for custos verify=self._get_verify_param()) def _get_userinfo(self, oauth2_session): @@ -230,7 +230,7 @@ class CustosAuthnz(IdentityProvider): # Set custos endpoints clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret'] eps = requests.get(self.config['url'], - headers={"Authorization": "Basic %s" % base64.b64encode(util.smart_str(clientIdAndSec))}, + headers={"Authorization": "Basic %s" % util.unicodify(base64.b64encode(util.smart_str(clientIdAndSec)))}, verify=False, params={'client_id': self.config['client_id']}) endpoints = eps.json() self.config['authorization_endpoint'] = endpoints['authorization_endpoint'] @@ -241,7 +241,7 @@ class CustosAuthnz(IdentityProvider): def _get_custos_credentials(self): clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret'] creds = requests.get(self.config['credential_url'], - headers={"Authorization": "Basic %s" % base64.b64encode(util.smart_str(clientIdAndSec))}, + headers={"Authorization": "Basic %s" % util.unicodify(base64.b64encode(util.smart_str(clientIdAndSec)))}, verify=False, params={'client_id': self.config['client_id']}) credentials = creds.json() self.config['iam_client_secret'] = credentials['iam_client_secret']