Skip to content
Snippets Groups Projects
Commit e4994e5e authored by Mart van Santen's avatar Mart van Santen
Browse files

cleanup code

parent 480bda07
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,6 @@ def login():
@api_v1.route("/hydra/callback")
@cross_origin()
def hydra_callback():
current_app.logger.info("Hydra callback A")
state = request.args.get("state")
code = request.args.get("code")
if state == None:
......@@ -30,36 +29,20 @@ def hydra_callback():
token = HydraOauth.get_token(state, code)
user_info = HydraOauth.get_user_info()
# Match Kratos identity with Hydra
#identities = KratosApi.get("/identities")
#identity = None
#current_app.logger.info("Hydra checkpoint 1")
#for i in identities.json():
# current_app.logger.info("Hydra checkpoint 2")
# current_app.logger.info(i)
# if i["traits"]["email"] == user_info["email"]:
# identity = i
#current_app.logger.info("Hydra checkpoint 3a")
# Short lifetime for token. If the session is still active, it will be
# automatically renewed via Hydra.
kratos_id = user_info["sub"]
# TODO: add a check to see if this a valid ID/active account
try:
access_token = create_access_token(
identity=token, expires_delta=timedelta(hours=1), additional_claims={"user_id": kratos_id}
)
except Exception as e:
current_app.logger.info("Hydra fail on token")
current_app.logger.info(e)
raise BadRequest("Error with creating token")
raise BadRequest("Error with creating auth token between backend and frontend")
current_app.logger.info("Hydra checkpoint 3b")
apps = App.query.all()
current_app.logger.info("Hydra checkpoint 4")
app_roles = []
for app in apps:
current_app.logger.info("Hydra checkpoint 5")
tmp_app_role = AppRole.query.filter_by(
user_id=kratos_id, app_id=app.id
).first()
......@@ -70,7 +53,6 @@ def hydra_callback():
}
)
current_app.logger.info("Hydra checkpoint 6")
return jsonify(
{
"accessToken": access_token,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment