From 39a4adab92704d62230e2b90d31b5642c8b9d6cd Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Tue, 8 Nov 2022 16:37:18 +0100 Subject: [PATCH 1/7] foo --- backend/app.py | 2 +- backend/areas/auth/auth.py | 2 -- backend/areas/auth/lit_auth.py | 11 ++++++++++- backend/helpers/authentik_api.py | 18 ++++++++++++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/backend/app.py b/backend/app.py index 97f6ffb..892b041 100644 --- a/backend/app.py +++ b/backend/app.py @@ -46,7 +46,7 @@ Migrate(app, db) db.init_app(app) -app.logger.setLevel(logging.INFO) +app.logger.setLevel(logging.DEBUG) app.register_blueprint(api_v1) app.register_blueprint(web) diff --git a/backend/areas/auth/auth.py b/backend/areas/auth/auth.py index c972752..11438d7 100644 --- a/backend/areas/auth/auth.py +++ b/backend/areas/auth/auth.py @@ -8,14 +8,12 @@ from areas.apps import App, AppRole from config import * from helpers import HydraOauth, BadRequest, KratosApi - @api_v1.route("/login", methods=["POST"]) @cross_origin() def login(): authorization_url = HydraOauth.authorize() return jsonify({"authorizationUrl": authorization_url}) - @api_v1.route("/hydra/callback") @cross_origin() def hydra_callback(): diff --git a/backend/areas/auth/lit_auth.py b/backend/areas/auth/lit_auth.py index f99432c..d0d4e96 100644 --- a/backend/areas/auth/lit_auth.py +++ b/backend/areas/auth/lit_auth.py @@ -1,14 +1,23 @@ from multiprocessing import current_process from flask import jsonify, request -from flask_jwt_extended import create_access_token +from flask_jwt_extended import create_access_token, jwt_required from flask_cors import cross_origin from datetime import timedelta +from helpers.authentik_api import AuthentikApi from areas import api_v1 from config import * from helpers import LITOauth, BadRequest +@api_v1.route("/logout", methods=["POST"]) +@cross_origin() +@jwt_required() +def logout(): + res = AuthentikApi.post("/flows/executor/default-invalidation-flow/") + print(res) + return jsonify({}) + @api_v1.route("/login", methods=["POST"]) @cross_origin() def login(): diff --git a/backend/helpers/authentik_api.py b/backend/helpers/authentik_api.py index e8e9a4d..7dacdea 100644 --- a/backend/helpers/authentik_api.py +++ b/backend/helpers/authentik_api.py @@ -32,11 +32,25 @@ class AuthentikApi: # TODO: check if can be replaced with apispec generated api raise AuthentikError() @staticmethod - def __paginate(res: requests.Response): # TODO: test this + def post(url, data=[]): + try: + res = requests.post(f"{AUTHENTIK_BASEURL}{url}", headers={ + "Authorization": f"Bearer {AuthentikApi.__token()}"}, data=data) + AuthentikApi.__handleError(res) + if ("pagination" in res.json()): + return AuthentikApi.__paginate(res) + return res.json() + except AuthentikError as err: + raise err + except: + raise AuthentikError() + + @staticmethod + def __paginate(res: requests.Response): # TODO: test this results = res.json()["results"] for page in range(1, res.json()["pagination"]["total_pages"]): res = requests.get( f"{res.request.url}", headers=res.request.headers, params={'page': page}) AuthentikApi.__handleError(res) results.append(res.json()["results"]) - return results \ No newline at end of file + return results From b55eb16384bc166e9cb8cd8b3d133e19c1f58b1a Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Wed, 9 Nov 2022 11:40:09 +0100 Subject: [PATCH 2/7] fix config --- backend/config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/config.py b/backend/config.py index 4daddfa..e0bcc24 100644 --- a/backend/config.py +++ b/backend/config.py @@ -30,7 +30,6 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False # Set this to "true" to load the config from a Kubernetes serviceaccount # running in a Kubernetes pod. Set it to "false" to load the config from the # `KUBECONFIG` environment variable. -LOAD_INCLUSTER_CONFIG = os.environ.get( - "LOAD_INCLUSTER_CONFIG").lower() == "true" +LOAD_INCLUSTER_CONFIG = os.environ.get("LOAD_INCLUSTER_CONFIG") == "true" AUTHENTIK_BASEURL = os.environ.get("AUTHENTIK_BASEURL") From 7032b49554ace5600b3902ba6328ef252404eed5 Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Tue, 15 Nov 2022 12:09:10 +0100 Subject: [PATCH 3/7] add utility apps filter for header --- src/components/Header/HeaderLIT.tsx | 33 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/components/Header/HeaderLIT.tsx b/src/components/Header/HeaderLIT.tsx index 7a4cc75..a6c4964 100644 --- a/src/components/Header/HeaderLIT.tsx +++ b/src/components/Header/HeaderLIT.tsx @@ -6,6 +6,7 @@ import Gravatar from 'react-gravatar'; import { Link, useLocation } from 'react-router-dom'; import clsx from 'clsx'; import { useApps } from 'src/services/apps'; +import { UTILITY_APPS } from 'src/modules/dashboard/consts'; const navigation = [ { name: '', to: '/users', requiresAdmin: true }, @@ -64,21 +65,23 @@ const HeaderLIT: React.FC = () => {
{/* Current: "border-primary-500 text-gray-900", Default: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700" */} - {apps.map((app) => ( - - {app.name} - - ))} + {apps + .filter((app) => UTILITY_APPS.indexOf(app.slug) === -1) + .map((app) => ( + + {app.name} + + ))} {/* {navigationItems.map((item) => ( Date: Tue, 22 Nov 2022 13:21:21 +0100 Subject: [PATCH 4/7] fix redirect-uri in get_token --- backend/helpers/lit_oauth.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/helpers/lit_oauth.py b/backend/helpers/lit_oauth.py index 3df84d2..bfd8075 100644 --- a/backend/helpers/lit_oauth.py +++ b/backend/helpers/lit_oauth.py @@ -23,6 +23,7 @@ class LITOauth: try: oauth = OAuth2Session( client_id=HYDRA_CLIENT_ID, + redirect_uri=REDIRECT_URL, state=state, ) token = oauth.fetch_token( From fa37029e96a7c5e0a7d99337f63a2dac0a294c1b Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Tue, 22 Nov 2022 13:22:09 +0100 Subject: [PATCH 5/7] fix db stuff --- backend/.dockerignore | 4 ++++ backend/.env.sample | 4 ++-- backend/.gitignore | 1 + backend/entrypoint.sh | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 backend/.dockerignore diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..20ea10c --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,4 @@ +.env +.vscode +.venv +__pycache__ \ No newline at end of file diff --git a/backend/.env.sample b/backend/.env.sample index 7b053cb..94b806d 100644 --- a/backend/.env.sample +++ b/backend/.env.sample @@ -6,5 +6,5 @@ TOKEN_URL="https://sso.example.org/application/o/token/" REDIRECT_URL="https://example.org/login-callback" SECRET_KEY= LOAD_INCLUSTER_CONFIG=false -DATABASE_URL=sqlite:///database.db -AUTHENTIK_BASEURL="https://sso.example.org/api/v3" \ No newline at end of file +DATABASE_URL=sqlite:///db/database.db +AUTHENTIK_BASEURL="https://sso.example.org/api/v3" diff --git a/backend/.gitignore b/backend/.gitignore index 0acc03e..35adce7 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -8,4 +8,5 @@ __pycache__ .envrc .direnv run_app.local.sh +db/ *.db diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index f5a05a4..591defd 100755 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -2,5 +2,6 @@ set -eu env +mkdir -p db flask db upgrade -gunicorn app:app -b 0.0.0.0:5000 --workers "$(nproc)" --reload --capture-output --enable-stdio-inheritance --log-level DEBUG \ No newline at end of file +gunicorn app:app -b 0.0.0.0:5000 --workers "$(nproc)" --reload --capture-output --enable-stdio-inheritance --log-level DEBUG From 4896a3a2d137d926e35676f4990dbd0837f21ead Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Tue, 22 Nov 2022 17:31:07 +0100 Subject: [PATCH 6/7] add more icons --- public/assets/bbb.svg | 23 +++++++ public/assets/element.svg | 7 ++ public/assets/gitea.svg | 12 ++++ public/assets/hedgedoc.svg | 129 +++++++++++++++++++++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 public/assets/bbb.svg create mode 100644 public/assets/element.svg create mode 100644 public/assets/gitea.svg create mode 100644 public/assets/hedgedoc.svg diff --git a/public/assets/bbb.svg b/public/assets/bbb.svg new file mode 100644 index 0000000..ee4680c --- /dev/null +++ b/public/assets/bbb.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/assets/element.svg b/public/assets/element.svg new file mode 100644 index 0000000..54a91b7 --- /dev/null +++ b/public/assets/element.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/public/assets/gitea.svg b/public/assets/gitea.svg new file mode 100644 index 0000000..797d894 --- /dev/null +++ b/public/assets/gitea.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/hedgedoc.svg b/public/assets/hedgedoc.svg new file mode 100644 index 0000000..6ababf2 --- /dev/null +++ b/public/assets/hedgedoc.svg @@ -0,0 +1,129 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5532d022ac96bd82ca2211aecacf6b4706c94afb Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Tue, 3 Jan 2023 11:06:17 +0100 Subject: [PATCH 7/7] fix: enable scrolling --- src/modules/dashboard/AppIframe.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/dashboard/AppIframe.tsx b/src/modules/dashboard/AppIframe.tsx index dc19b9d..e96bf6f 100644 --- a/src/modules/dashboard/AppIframe.tsx +++ b/src/modules/dashboard/AppIframe.tsx @@ -11,7 +11,6 @@ export const AppIframe: React.FC = ({ app }: { app: any }) => { position="absolute" frameBorder={0} overflow="hidden" - scrolling="no" title={app.name} url={app.url} />