diff --git a/backend/.dockerignore b/backend/.dockerignore deleted file mode 100644 index 20ea10c..0000000 --- a/backend/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -.env -.vscode -.venv -__pycache__ \ No newline at end of file diff --git a/backend/.env.sample b/backend/.env.sample index 94b806d..7b053cb 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:///db/database.db -AUTHENTIK_BASEURL="https://sso.example.org/api/v3" +DATABASE_URL=sqlite:///database.db +AUTHENTIK_BASEURL="https://sso.example.org/api/v3" \ No newline at end of file diff --git a/backend/.gitignore b/backend/.gitignore index 35adce7..0acc03e 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -8,5 +8,4 @@ __pycache__ .envrc .direnv run_app.local.sh -db/ *.db 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/config.py b/backend/config.py index e0bcc24..4daddfa 100644 --- a/backend/config.py +++ b/backend/config.py @@ -30,6 +30,7 @@ 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") == "true" +LOAD_INCLUSTER_CONFIG = os.environ.get( + "LOAD_INCLUSTER_CONFIG").lower() == "true" AUTHENTIK_BASEURL = os.environ.get("AUTHENTIK_BASEURL") diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index 591defd..f5a05a4 100755 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -2,6 +2,5 @@ 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 +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 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 diff --git a/backend/helpers/lit_oauth.py b/backend/helpers/lit_oauth.py index bfd8075..3df84d2 100644 --- a/backend/helpers/lit_oauth.py +++ b/backend/helpers/lit_oauth.py @@ -23,7 +23,6 @@ class LITOauth: try: oauth = OAuth2Session( client_id=HYDRA_CLIENT_ID, - redirect_uri=REDIRECT_URL, state=state, ) token = oauth.fetch_token( diff --git a/public/assets/bbb.svg b/public/assets/bbb.svg deleted file mode 100644 index ee4680c..0000000 --- a/public/assets/bbb.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/public/assets/element.svg b/public/assets/element.svg deleted file mode 100644 index 54a91b7..0000000 --- a/public/assets/element.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/public/assets/gitea.svg b/public/assets/gitea.svg deleted file mode 100644 index 797d894..0000000 --- a/public/assets/gitea.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/public/assets/hedgedoc.svg b/public/assets/hedgedoc.svg deleted file mode 100644 index 6ababf2..0000000 --- a/public/assets/hedgedoc.svg +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/Header/HeaderLIT.tsx b/src/components/Header/HeaderLIT.tsx index a6c4964..7a4cc75 100644 --- a/src/components/Header/HeaderLIT.tsx +++ b/src/components/Header/HeaderLIT.tsx @@ -6,7 +6,6 @@ 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 }, @@ -65,23 +64,21 @@ 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 - .filter((app) => UTILITY_APPS.indexOf(app.slug) === -1) - .map((app) => ( - - {app.name} - - ))} + {apps.map((app) => ( + + {app.name} + + ))} {/* {navigationItems.map((item) => ( = ({ app }: { app: any }) => { position="absolute" frameBorder={0} overflow="hidden" + scrolling="no" title={app.name} url={app.url} />