Compare commits
1 commit
fork
...
single-log
Author | SHA1 | Date | |
---|---|---|---|
|
39a4adab92 |
4 changed files with 27 additions and 6 deletions
|
@ -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)
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -32,7 +32,21 @@ 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(
|
||||
|
|
Loading…
Reference in a new issue