2022-04-29 14:13:54 +02:00
|
|
|
import logging
|
|
|
|
from app import dependencies
|
|
|
|
from app.authentik.api import Authentik
|
|
|
|
from app.event_controller import Authentik_Hook_Model, EventController, Http_request
|
2022-04-29 15:50:33 +02:00
|
|
|
from fastapi import APIRouter, Depends, BackgroundTasks
|
2022-04-29 14:13:54 +02:00
|
|
|
from app.authentik.settings import AuthentikSettings
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
2022-04-29 15:50:33 +02:00
|
|
|
|
2022-04-29 14:13:54 +02:00
|
|
|
@router.post("/authentik/hook/")
|
|
|
|
async def hook(model: Authentik_Hook_Model,
|
2022-04-29 15:50:33 +02:00
|
|
|
http_request: Http_request,
|
|
|
|
background_tasks: BackgroundTasks
|
|
|
|
):
|
2022-04-29 14:13:54 +02:00
|
|
|
logging.info(model)
|
|
|
|
logging.info(http_request)
|
|
|
|
ec = EventController(Authentik(AuthentikSettings()))
|
|
|
|
if http_request.path == "/api/v3/core/users/":
|
2022-04-29 15:50:33 +02:00
|
|
|
background_tasks.add_task(ec.handle_model_created_event, model)
|
|
|
|
return 200
|