From e4994e5e7cde859d3032b6f45158c555f66ba9e7 Mon Sep 17 00:00:00 2001 From: Mart van Santen <mart@greenhost.nl> Date: Tue, 15 Aug 2023 18:10:41 +0200 Subject: [PATCH] cleanup code --- backend/areas/auth/auth.py | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/backend/areas/auth/auth.py b/backend/areas/auth/auth.py index 54edbcf8..6cd27d34 100644 --- a/backend/areas/auth/auth.py +++ b/backend/areas/auth/auth.py @@ -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, -- GitLab