foo
This commit is contained in:
parent
44e4e4eb42
commit
39a4adab92
4 changed files with 27 additions and 6 deletions
|
@ -46,7 +46,7 @@ Migrate(app, db)
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
|
|
||||||
|
|
||||||
app.logger.setLevel(logging.INFO)
|
app.logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
app.register_blueprint(api_v1)
|
app.register_blueprint(api_v1)
|
||||||
app.register_blueprint(web)
|
app.register_blueprint(web)
|
||||||
|
|
|
@ -8,14 +8,12 @@ from areas.apps import App, AppRole
|
||||||
from config import *
|
from config import *
|
||||||
from helpers import HydraOauth, BadRequest, KratosApi
|
from helpers import HydraOauth, BadRequest, KratosApi
|
||||||
|
|
||||||
|
|
||||||
@api_v1.route("/login", methods=["POST"])
|
@api_v1.route("/login", methods=["POST"])
|
||||||
@cross_origin()
|
@cross_origin()
|
||||||
def login():
|
def login():
|
||||||
authorization_url = HydraOauth.authorize()
|
authorization_url = HydraOauth.authorize()
|
||||||
return jsonify({"authorizationUrl": authorization_url})
|
return jsonify({"authorizationUrl": authorization_url})
|
||||||
|
|
||||||
|
|
||||||
@api_v1.route("/hydra/callback")
|
@api_v1.route("/hydra/callback")
|
||||||
@cross_origin()
|
@cross_origin()
|
||||||
def hydra_callback():
|
def hydra_callback():
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
from multiprocessing import current_process
|
from multiprocessing import current_process
|
||||||
from flask import jsonify, request
|
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 flask_cors import cross_origin
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from helpers.authentik_api import AuthentikApi
|
||||||
|
|
||||||
from areas import api_v1
|
from areas import api_v1
|
||||||
from config import *
|
from config import *
|
||||||
from helpers import LITOauth, BadRequest
|
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"])
|
@api_v1.route("/login", methods=["POST"])
|
||||||
@cross_origin()
|
@cross_origin()
|
||||||
def login():
|
def login():
|
||||||
|
|
|
@ -32,7 +32,21 @@ class AuthentikApi: # TODO: check if can be replaced with apispec generated api
|
||||||
raise AuthentikError()
|
raise AuthentikError()
|
||||||
|
|
||||||
@staticmethod
|
@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"]
|
results = res.json()["results"]
|
||||||
for page in range(1, res.json()["pagination"]["total_pages"]):
|
for page in range(1, res.json()["pagination"]["total_pages"]):
|
||||||
res = requests.get(
|
res = requests.get(
|
||||||
|
|
Loading…
Reference in a new issue