2022-03-03 16:36:08 +01:00
|
|
|
from fastapi import FastAPI, Request
|
2022-03-04 18:51:33 +01:00
|
|
|
|
|
|
|
from app.authentik.authentik import Authentik
|
2022-03-03 16:36:08 +01:00
|
|
|
from .wekan.api import Wekan
|
|
|
|
import json
|
2022-03-02 16:10:17 +01:00
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
@app.get("/")
|
|
|
|
async def root():
|
2022-03-03 16:36:08 +01:00
|
|
|
return {'message': 'Hello World'}
|
|
|
|
|
2022-03-04 18:51:33 +01:00
|
|
|
@app.post("/authentik/hook")
|
2022-03-03 16:36:08 +01:00
|
|
|
async def hook(request: Request):
|
2022-03-04 18:51:33 +01:00
|
|
|
# print(await request.body())
|
2022-03-03 16:36:08 +01:00
|
|
|
r = await request.json()
|
|
|
|
# model_created = json.loads(r['body'].split("model_created: ")[1])["model"]
|
2022-03-04 18:51:33 +01:00
|
|
|
# hook wekan.create_user(model_created["pk"])
|
|
|
|
|
|
|
|
@app.get("/authentik/create_hook")
|
|
|
|
async def hook(request: Request):
|
|
|
|
a = Authentik(base="http://localhost:9000/", token="foobar123", hook_endpoint="http://172.17.0.1:8000/authentik/hook")
|
|
|
|
res = a.create_web_hook()
|
|
|
|
print(res)
|