diff --git a/dojo/okta.py b/dojo/okta.py index e64bf343b1..7c564d005a 100644 --- a/dojo/okta.py +++ b/dojo/okta.py @@ -9,13 +9,23 @@ from urllib.parse import urljoin -from ..utils import append_slash from .oauth import BaseOAuth2 class OktaMixin: + + def append_slash(self, url): + """Make sure we append a slash at the end of the URL otherwise we + have issues with urljoin Example: + >>> urlparse.urljoin('http://www.example.com/api/v3', 'user/1/') + 'http://www.example.com/api/user/1/' + """ + if url and not url.endswith("/"): + url = f"{url}/" + return url + def api_url(self): - return append_slash(self.setting("API_URL")) + return self.append_slash(self.setting("API_URL")) def authorization_url(self): return self._url("v1/authorize") @@ -24,7 +34,7 @@ def access_token_url(self): return self._url("v1/token") def _url(self, path): - return urljoin(append_slash(self.setting("API_URL")), path) + return urljoin(self.append_slash(self.setting("API_URL")), path) def oidc_config(self): return self.get_json(