Skip to content

Commit

Permalink
add appendslash
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-sommer committed May 14, 2024
1 parent 8de18b7 commit 99d717f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dojo/okta.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@

from urllib.parse import urljoin

Check failure on line 10 in dojo/okta.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (E402)

dojo/okta.py:10:1: E402 Module level import not at top of file

Check notice on line 10 in dojo/okta.py

View workflow job for this annotation

GitHub Actions / flake8-your-pr

dojo/okta.py#L10

module level import not at top of file (E402)

from ..utils import append_slash
from .oauth import BaseOAuth2

Check failure on line 12 in dojo/okta.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (E402)

dojo/okta.py:12:1: E402 Module level import not at top of file

Check notice on line 12 in dojo/okta.py

View workflow job for this annotation

GitHub Actions / flake8-your-pr

dojo/okta.py#L12

module level import not at top of file (E402)


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")
Expand All @@ -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(
Expand Down

0 comments on commit 99d717f

Please sign in to comment.