Compare commits

..

1 commit

Author SHA1 Message Date
Philipp Rothmann
39a4adab92 foo 2022-11-08 16:37:18 +01:00
16 changed files with 48 additions and 206 deletions

View file

@ -1,4 +0,0 @@
.env
.vscode
.venv
__pycache__

View file

@ -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"

1
backend/.gitignore vendored
View file

@ -8,5 +8,4 @@ __pycache__
.envrc
.direnv
run_app.local.sh
db/
*.db

View file

@ -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)

View file

@ -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():

View file

@ -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():

View file

@ -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")

View file

@ -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

View file

@ -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
return results

View file

@ -23,7 +23,6 @@ class LITOauth:
try:
oauth = OAuth2Session(
client_id=HYDRA_CLIENT_ID,
redirect_uri=REDIRECT_URL,
state=state,
)
token = oauth.fetch_token(

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 416 416" width="416" height="416" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<symbol id="a" viewBox="-207.491 -207.49 414.981 414.981">
<path d="m198.491 0c0-109.624-88.866-198.49-198.491-198.49-109.623 0-198.49 88.866-198.49 198.49 0 109.623 88.867 198.491 198.49 198.491 109.625 0 198.491-88.868 198.491-198.491z" fill="url(#b)" stroke="#5d6aa5" stroke-width="18"/>
<path d="m.543 190.26c50.3-.373 104.324-20.494 143.335-66.953-1.66-39.852-72.986-80.704-132.511-125.68-49.945-37.738-126.373-73.128-178.643-87.032-49.698 95.152-13.55 186.622 48.772 238.038 29.158 25.513 73.097 41.968 119.047 41.627z" fill="url(#c)"/>
<path d="m107.395-49.37c0-16.763-5.9-31.045-17.694-42.839-11.801-11.801-26.076-17.694-42.839-17.694h-72.175c-16.764 0-31.046 5.894-42.84 17.694-11.801 11.794-17.694 26.076-17.694 42.839v181.137c12.856 0 23.827-6.287 32.923-18.859 9.094-12.572 13.642-27.706 13.642-45.4v-116.878c0-9.312 4.656-13.969 13.97-13.969h72.175c9.312 0 13.969 4.656 13.969 13.969v55.412c0 9-4.656 13.656-13.969 13.97h-13.97c-18.007.626-33.221 5.326-45.633 14.107-12.42 8.774-18.626 19.594-18.626 32.457h78.229c16.763 0 31.038-5.901 42.839-17.694 11.794-11.801 17.694-26.076 17.694-42.84v-55.412z" fill="#757575" />
<path d="m103.971-51.741c0-16.763-5.9-31.045-17.694-42.839-11.801-11.801-26.076-17.694-42.839-17.694h-72.175c-16.763 0-31.045 5.894-42.839 17.694-11.801 11.794-17.694 26.076-17.694 42.839v181.136c12.856 0 23.828-6.287 32.922-18.859s13.642-27.706 13.642-45.4v-116.877c0-9.313 4.656-13.969 13.969-13.969h72.175c9.312 0 13.969 4.656 13.969 13.969v55.412c0 9-4.656 13.656-13.969 13.969h-13.97c-18.007.625-33.221 5.326-45.633 14.107-12.419 8.774-18.625 19.594-18.625 32.457h78.229c16.763 0 31.038-5.901 42.839-17.694 11.794-11.801 17.694-26.076 17.694-42.839v-55.412z" fill="#fff"/>
</symbol>
<linearGradient id="b" gradientUnits="userSpaceOnUse" x1="-113.8594" x2="113.8594" y1="162.6079" y2="-162.6081">
<stop offset="0" stop-color="#283274"/>
<stop offset=".7088" stop-color="#283375"/>
<stop offset=".967" stop-color="#273f88"/>
</linearGradient>
<linearGradient id="c" gradientUnits="userSpaceOnUse" x1="-109.1797" x2="5.1006" y1="156.1684" y2="-7.0408">
<stop offset="0" stop-color="#bfc8e6"/>
<stop offset=".0772" stop-color="#b6bedd"/>
<stop offset=".2039" stop-color="#9fa4c9"/>
<stop offset=".3642" stop-color="#7f82ae"/>
<stop offset=".5519" stop-color="#585c92"/>
<stop offset=".7582" stop-color="#283375"/>
</linearGradient>
<use xlink:href="#a" width="414.981" height="414.981" transform="matrix(1 0 0 -1 208.5918 208.3076)" x="-207.491" y="-207.49"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -1,7 +0,0 @@
<svg width="200" height="200" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M100 200C155.228 200 200 155.228 200 100C200 44.7715 155.228 0 100 0C44.7715 0 0 44.7715 0 100C0 155.228 44.7715 200 100 200Z" fill="#0DBD8B"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M81.7169 46.5946C81.7169 42.5581 84.9959 39.2859 89.0408 39.2859C116.456 39.2859 138.681 61.4642 138.681 88.8225C138.681 92.859 135.401 96.1312 131.357 96.1312C127.312 96.1312 124.033 92.859 124.033 88.8225C124.033 69.5372 108.366 53.9033 89.0408 53.9033C84.9959 53.9033 81.7169 50.6311 81.7169 46.5946Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M153.39 81.5137C157.435 81.5137 160.714 84.7859 160.714 88.8224C160.714 116.181 138.49 138.359 111.075 138.359C107.03 138.359 103.751 135.087 103.751 131.05C103.751 127.014 107.03 123.742 111.075 123.742C130.4 123.742 146.066 108.108 146.066 88.8224C146.066 84.7859 149.345 81.5137 153.39 81.5137Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M118.398 153.405C118.398 157.442 115.119 160.714 111.074 160.714C83.6592 160.714 61.4347 138.536 61.4347 111.177C61.4347 107.141 64.7138 103.869 68.7587 103.869C72.8035 103.869 76.0826 107.141 76.0826 111.177C76.0826 130.463 91.7489 146.097 111.074 146.097C115.119 146.097 118.398 149.369 118.398 153.405Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M46.6097 118.486C42.5648 118.486 39.2858 115.214 39.2858 111.178C39.2858 83.8193 61.5102 61.6409 88.9255 61.6409C92.9704 61.6409 96.2494 64.9132 96.2494 68.9497C96.2494 72.9862 92.9704 76.2584 88.9255 76.2584C69.6 76.2584 53.9337 91.8922 53.9337 111.178C53.9337 115.214 50.6546 118.486 46.6097 118.486Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" id="main_outline" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 640 640" style="enable-background:new 0 0 640 640;" xml:space="preserve">
<g>
<path id="teabag" style="fill:#FFFFFF" d="M395.9,484.2l-126.9-61c-12.5-6-17.9-21.2-11.8-33.8l61-126.9c6-12.5,21.2-17.9,33.8-11.8 c17.2,8.3,27.1,13,27.1,13l-0.1-109.2l16.7-0.1l0.1,117.1c0,0,57.4,24.2,83.1,40.1c3.7,2.3,10.2,6.8,12.9,14.4 c2.1,6.1,2,13.1-1,19.3l-61,126.9C423.6,484.9,408.4,490.3,395.9,484.2z"/>
<g>
<g>
<path style="fill:#609926" d="M622.7,149.8c-4.1-4.1-9.6-4-9.6-4s-117.2,6.6-177.9,8c-13.3,0.3-26.5,0.6-39.6,0.7c0,39.1,0,78.2,0,117.2 c-5.5-2.6-11.1-5.3-16.6-7.9c0-36.4-0.1-109.2-0.1-109.2c-29,0.4-89.2-2.2-89.2-2.2s-141.4-7.1-156.8-8.5 c-9.8-0.6-22.5-2.1-39,1.5c-8.7,1.8-33.5,7.4-53.8,26.9C-4.9,212.4,6.6,276.2,8,285.8c1.7,11.7,6.9,44.2,31.7,72.5 c45.8,56.1,144.4,54.8,144.4,54.8s12.1,28.9,30.6,55.5c25,33.1,50.7,58.9,75.7,62c63,0,188.9-0.1,188.9-0.1s12,0.1,28.3-10.3 c14-8.5,26.5-23.4,26.5-23.4s12.9-13.8,30.9-45.3c5.5-9.7,10.1-19.1,14.1-28c0,0,55.2-117.1,55.2-231.1 C633.2,157.9,624.7,151.8,622.7,149.8z M125.6,353.9c-25.9-8.5-36.9-18.7-36.9-18.7S69.6,321.8,60,295.4 c-16.5-44.2-1.4-71.2-1.4-71.2s8.4-22.5,38.5-30c13.8-3.7,31-3.1,31-3.1s7.1,59.4,15.7,94.2c7.2,29.2,24.8,77.7,24.8,77.7 S142.5,359.9,125.6,353.9z M425.9,461.5c0,0-6.1,14.5-19.6,15.4c-5.8,0.4-10.3-1.2-10.3-1.2s-0.3-0.1-5.3-2.1l-112.9-55 c0,0-10.9-5.7-12.8-15.6c-2.2-8.1,2.7-18.1,2.7-18.1L322,273c0,0,4.8-9.7,12.2-13c0.6-0.3,2.3-1,4.5-1.5c8.1-2.1,18,2.8,18,2.8 l110.7,53.7c0,0,12.6,5.7,15.3,16.2c1.9,7.4-0.5,14-1.8,17.2C474.6,363.8,425.9,461.5,425.9,461.5z"/>
<path style="fill:#609926" d="M326.8,380.1c-8.2,0.1-15.4,5.8-17.3,13.8c-1.9,8,2,16.3,9.1,20c7.7,4,17.5,1.8,22.7-5.4 c5.1-7.1,4.3-16.9-1.8-23.1l24-49.1c1.5,0.1,3.7,0.2,6.2-0.5c4.1-0.9,7.1-3.6,7.1-3.6c4.2,1.8,8.6,3.8,13.2,6.1 c4.8,2.4,9.3,4.9,13.4,7.3c0.9,0.5,1.8,1.1,2.8,1.9c1.6,1.3,3.4,3.1,4.7,5.5c1.9,5.5-1.9,14.9-1.9,14.9 c-2.3,7.6-18.4,40.6-18.4,40.6c-8.1-0.2-15.3,5-17.7,12.5c-2.6,8.1,1.1,17.3,8.9,21.3c7.8,4,17.4,1.7,22.5-5.3 c5-6.8,4.6-16.3-1.1-22.6c1.9-3.7,3.7-7.4,5.6-11.3c5-10.4,13.5-30.4,13.5-30.4c0.9-1.7,5.7-10.3,2.7-21.3 c-2.5-11.4-12.6-16.7-12.6-16.7c-12.2-7.9-29.2-15.2-29.2-15.2s0-4.1-1.1-7.1c-1.1-3.1-2.8-5.1-3.9-6.3c4.7-9.7,9.4-19.3,14.1-29 c-4.1-2-8.1-4-12.2-6.1c-4.8,9.8-9.7,19.7-14.5,29.5c-6.7-0.1-12.9,3.5-16.1,9.4c-3.4,6.3-2.7,14.1,1.9,19.8 C343.2,346.5,335,363.3,326.8,380.1z"/>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -1,129 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
sodipodi:docname="hedgedoc.svg"
id="svg49"
version="1.1"
width="414.10999"
viewBox="0 0 414.10999 414.11"
stroke-miterlimit="2"
stroke-linejoin="round"
height="414.10999"
fill-rule="evenodd"
clip-rule="evenodd">
<metadata
id="metadata55">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs53">
<inkscape:path-effect
lpeversion="1"
is_visible="true"
id="path-effect882"
effect="spiro" />
</defs>
<sodipodi:namedview
inkscape:current-layer="svg49"
inkscape:window-maximized="1"
inkscape:window-y="-8"
inkscape:window-x="-8"
inkscape:cy="207.05499"
inkscape:cx="825"
inkscape:zoom="0.81212121"
showgrid="false"
id="namedview51"
inkscape:window-height="1027"
inkscape:window-width="1920"
inkscape:pageshadow="2"
inkscape:pageopacity="0"
guidetolerance="10"
gridtolerance="10"
objecttolerance="10"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffff" />
<linearGradient
x2="1"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(200,-420,420,200,660,1340)"
id="a">
<stop
id="stop2"
stop-color="#fdd49a"
offset="0" />
<stop
id="stop4"
stop-color="#dca055"
offset="1" />
</linearGradient>
<g
id="g31"
transform="matrix(1.0002373,0,0,1,-50.01087,-265.89)"
fill-rule="nonzero">
<g
id="g29"
transform="matrix(0.27874,0,0,0.27874,10.207,226.1)">
<path
id="path23"
fill="#b51f08"
d="m 1553.7,961.08 75.25,-75.258 -75.25,-75.246 56.61,-90.096 -90.1,-56.616 35.15,-100.45 -100.44,-35.142 11.91,-105.75 -105.74,-11.912 -11.92,-105.75 -105.74,11.912 -35.15,-100.44 -100.43,35.145 -56.63,-90.1 -90.107,56.617 -75.242,-75.246 -75.242,75.25 -90.104,-56.612 -56.612,90.096 -100.44,-35.15 -35.142,100.44 -105.75,-11.916 -11.912,105.74 -105.74,11.913 11.917,105.74 -100.45,35.15 35.145,100.44 -90.1,56.612 56.621,90.117 -75.258,75.25 75.25,75.258 -56.613,90.107 90.1,56.61 -35.145,100.44 100.45,35.15 -11.913,105.73 105.74,11.92 11.912,105.74 105.75,-11.91 35.142,100.43 100.44,-35.13 56.617,90.1 90.096,-56.62 75.25,74.55 75.25,-74.53 90.099,56.61 56.61,-90.11 100.45,35.15 35.14,-100.44 105.75,11.91 11.91,-105.75 105.75,-11.91 -11.92,-105.74 100.45,-35.15 -35.15,-100.45 90.1,-56.61 z" />
<path
id="path25"
fill="#fdd49a"
d="m 1401.3,1004.8 c 0,-145.44 -117.9,-263.34 -263.34,-263.34 -72.24,0 -137.68,29.112 -185.25,76.225 l -0.033,-0.034 -67.096,67.1 -54.862,-54.862 c -48.267,-55.067 -119.07,-89.879 -198.04,-89.879 -145.44,0 -263.34,117.9 -263.34,263.34 0,76 32.23,144.43 83.721,192.49 l 432.78,432.55 423.22,-423.49 c 52.88,-49.77 92.25,-120 92.25,-200.1" />
<path
style="fill:url(#a)"
id="path27"
fill="url(#a)"
d="m 885.58,884.73 -54.862,-54.862 c -48.267,-55.067 -119.07,-89.879 -198.04,-89.879 -145.44,0 -263.34,117.9 -263.34,263.34 0,76 32.23,144.43 83.721,192.49 l 432.78,432.55" />
</g>
</g>
<g
id="g47"
stroke-width="0.27874">
<path
id="path33"
fill="none"
d="M 207.13,414.11 207.0592,206.82" />
<g
id="g45"
fill-rule="nonzero">
<path
id="path35"
fill="#010007"
d="m 228.08,393.26 c -5.3739,-5.3937 -12.799,-8.7275 -20.996,-8.7275 -8.1998,0 -15.622,3.3338 -20.998,8.7275 0.0859,11.523 9.4517,20.839 20.996,20.839 11.544,0 20.911,-9.3184 20.998,-20.839" />
<path
id="path37"
fill="#010007"
d="m 182.56,266.33 c 0,8.8641 -7.1824,16.047 -16.048,16.047 -8.8604,0 -16.044,-7.1832 -16.044,-16.047 0,-8.8641 7.1835,-16.047 16.044,-16.047 8.8652,0 16.048,7.1832 16.048,16.047" />
<path
id="path39"
fill="#fffffa"
d="m 177.06,263.93 c 0,2.4585 -1.9919,4.4432 -4.446,4.4432 -2.4552,0 -4.4482,-1.9847 -4.4482,-4.4432 0,-2.4557 1.993,-4.4488 4.4482,-4.4488 2.4541,0 4.446,1.993 4.446,4.4488" />
<path
id="path41"
fill="#010007"
d="m 263.94,266.33 c 0,8.8641 -7.1832,16.047 -16.047,16.047 -8.8613,0 -16.046,-7.1832 -16.046,-16.047 0,-8.8641 7.1852,-16.047 16.046,-16.047 8.8641,0 16.047,7.1832 16.047,16.047" />
<path
id="path43"
fill="#fffffa"
d="m 258.44,263.93 c 0,2.4585 -1.993,4.4432 -4.446,4.4432 -2.4557,0 -4.4488,-1.9847 -4.4488,-4.4432 0,-2.4557 1.993,-4.4488 4.4488,-4.4488 2.453,0 4.446,1.993 4.446,4.4488" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.1 KiB

View file

@ -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<HeaderProps> = () => {
</Link>
<div className="hidden sm:ml-6 sm:flex sm:space-x-8">
{/* 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) => (
<Link
key={app.name}
to={app.slug}
className={clsx(
'border-primary-50 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium litbutton',
{
'border-primary-500 litbutton-active hover:border-gray-300 inline-flex items-center px-1 pt-1 text-sm font-medium':
pathname.includes(app.slug),
},
)}
>
{app.name}
</Link>
))}
{apps.map((app) => (
<Link
key={app.name}
to={app.slug}
className={clsx(
'border-primary-50 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium litbutton',
{
'border-primary-500 litbutton-active hover:border-gray-300 inline-flex items-center px-1 pt-1 text-sm font-medium':
pathname.includes(app.slug),
},
)}
>
{app.name}
</Link>
))}
{/* {navigationItems.map((item) => (
<Link
key={item.name}

View file

@ -11,6 +11,7 @@ export const AppIframe: React.FC<any> = ({ app }: { app: any }) => {
position="absolute"
frameBorder={0}
overflow="hidden"
scrolling="no"
title={app.name}
url={app.url}
/>