From a7fb3ab28dd47eee9976606cdfef3d9160c331a3 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Mon, 4 Apr 2022 14:24:30 +0200 Subject: [PATCH] Change KRATOS_URL to KRATOS_ADMIN_URL and HYDRA_URL to HYDRA_PUBLIC_URL for clarity --- config.py | 4 ++-- helpers/hydra_oauth.py | 2 +- helpers/kratos_api.py | 8 ++++---- run_app.sh | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config.py b/config.py index 918aeb9..cfcf05b 100644 --- a/config.py +++ b/config.py @@ -1,14 +1,14 @@ import os SECRET_KEY = os.environ.get("SECRET_KEY") -KRATOS_URL = os.environ.get("KRATOS_URL") HYDRA_CLIENT_ID = os.environ.get("HYDRA_CLIENT_ID") HYDRA_CLIENT_SECRET = os.environ.get("HYDRA_CLIENT_SECRET") HYDRA_AUTHORIZATION_BASE_URL = os.environ.get("HYDRA_AUTHORIZATION_BASE_URL") -HYDRA_URL = os.environ.get("HYDRA_URL") TOKEN_URL = os.environ.get("TOKEN_URL") PUBLIC_URL = os.environ.get('PUBLIC_URL') + +HYDRA_PUBLIC_URL = os.environ.get("HYDRA_PUBLIC_URL") HYDRA_ADMIN_URL = os.environ.get('HYDRA_ADMIN_URL') KRATOS_ADMIN_URL = os.environ.get('KRATOS_ADMIN_URL') KRATOS_PUBLIC_URL = str(os.environ.get('KRATOS_PUBLIC_URL')) + "/" diff --git a/helpers/hydra_oauth.py b/helpers/hydra_oauth.py index f90b891..b75d615 100644 --- a/helpers/hydra_oauth.py +++ b/helpers/hydra_oauth.py @@ -43,7 +43,7 @@ class HydraOauth: hydra = OAuth2Session( client_id=HYDRA_CLIENT_ID, token=session["hydra_token"] ) - user_info = hydra.get("{}/userinfo".format(HYDRA_URL)) + user_info = hydra.get("{}/userinfo".format(HYDRA_PUBLIC_URL)) return user_info.json() except Exception as err: diff --git a/helpers/kratos_api.py b/helpers/kratos_api.py index 87b1e9d..eb83c82 100644 --- a/helpers/kratos_api.py +++ b/helpers/kratos_api.py @@ -15,7 +15,7 @@ class KratosApi: @staticmethod def get(url): try: - res = requests.get("{}{}".format(KRATOS_URL, url)) + res = requests.get("{}{}".format(KRATOS_ADMIN_URL, url)) KratosApi.__handleError(res) return res except KratosError as err: @@ -26,7 +26,7 @@ class KratosApi: @staticmethod def post(url, data): try: - res = requests.post("{}{}".format(KRATOS_URL, url), json=data) + res = requests.post("{}{}".format(KRATOS_ADMIN_URL, url), json=data) KratosApi.__handleError(res) return res except KratosError as err: @@ -37,7 +37,7 @@ class KratosApi: @staticmethod def put(url, data): try: - res = requests.put("{}{}".format(KRATOS_URL, url), json=data) + res = requests.put("{}{}".format(KRATOS_ADMIN_URL, url), json=data) KratosApi.__handleError(res) return res except KratosError as err: @@ -48,7 +48,7 @@ class KratosApi: @staticmethod def delete(url): try: - res = requests.delete("{}{}".format(KRATOS_URL, url)) + res = requests.delete("{}{}".format(KRATOS_ADMIN_URL, url)) KratosApi.__handleError(res) return res except KratosError as err: diff --git a/run_app.sh b/run_app.sh index 47aa65a..218949a 100755 --- a/run_app.sh +++ b/run_app.sh @@ -21,16 +21,15 @@ fi export FLASK_APP=app.py export FLASK_ENV=development export SECRET_KEY="e38hq!@0n64g@qe6)5csk41t=ljo2vllog(%k7njnm4b@kh42c" -export KRATOS_URL="http://127.0.0.1:8000" export HYDRA_CLIENT_ID="dashboard-local" export HYDRA_CLIENT_SECRET="gDSEuakxzybHBHJocnmtDOLMwlWWEvPh" -export HYDRA_URL="https://sso.init.stackspin.net" export HYDRA_AUTHORIZATION_BASE_URL="https://sso.init.stackspin.net/oauth2/auth" export TOKEN_URL="https://sso.init.stackspin.net/oauth2/token" # Login facilitator paths export KRATOS_PUBLIC_URL=http://localhost/kratos export KRATOS_ADMIN_URL=http://localhost:8000 +export HYDRA_PUBLIC_URL="https://sso.init.stackspin.net" export HYDRA_ADMIN_URL=http://localhost:4445 export PUBLIC_URL=http://localhost/web/ #export DATABASE_URL="mysql+pymysql://stackspin:stackspin@localhost/stackspin?charset=utf8mb4"