chore: import MCTF services
- Added all seven issued service trees without omissions. - Preserved the supplied runtime configuration, binaries, and assets.
This commit is contained in:
commit
13f936bee9
1222 files changed
+21280
No files matched your search
+49
@@ -0,0 +1,49 @@
|
||||
from flask import Blueprint, g, request, abort
|
||||
from backend.app.infrastructure.persistence import repositories
|
||||
from backend.app.infrastructure.persistence.connection import database
|
||||
from backend.app.application import implants
|
||||
from backend.app.api.request import json_object
|
||||
from backend.app.api.context import ledger
|
||||
from backend.app.api.session import owner_session, claimed_username
|
||||
|
||||
|
||||
bp = Blueprint("implants", __name__, url_prefix="/home/api")
|
||||
|
||||
|
||||
@bp.post("/register_implant")
|
||||
@owner_session
|
||||
def register_implant():
|
||||
return implants.register(database(), ledger(), g.user["id"], json_object()), 201
|
||||
|
||||
@bp.get("/implants")
|
||||
@owner_session
|
||||
def list_implants():
|
||||
return implants.list_owned(database(), g.user["id"])
|
||||
|
||||
@bp.get("/telemetry")
|
||||
@owner_session
|
||||
def telemetry():
|
||||
username = request.args.get("username") or g.user["username"]
|
||||
if claimed_username(g.token) != username:
|
||||
return {"error": "access denied"}, 403
|
||||
user = repositories.get_user_by_username(database(), username)
|
||||
if user is None:
|
||||
abort(404)
|
||||
return implants.telemetry(database(), user["id"])
|
||||
|
||||
@bp.get("/implants/<implant_id>")
|
||||
@owner_session
|
||||
def implant_passport(implant_id):
|
||||
return implants.passport(database(), ledger(), implant_id, g.user["id"])
|
||||
|
||||
@bp.route("/check_certificate/<implant_id>/check", methods=["GET", "POST"])
|
||||
@owner_session
|
||||
def check_certificate(implant_id):
|
||||
payload = json_object() if request.method == "POST" else None
|
||||
return implants.check_certificate(database(), ledger(), implant_id, g.user["id"], payload)
|
||||
|
||||
|
||||
@bp.post("/reissue/<implant_id>")
|
||||
@owner_session
|
||||
def reissue_certificate(implant_id):
|
||||
return implants.reissue(database(), ledger(), implant_id, json_object()), 200
|
||||
Reference in new issue
Block a user