revert auth.py

This commit is contained in:
Philipp Rothmann 2022-11-02 11:32:26 +01:00
parent dea8773ff6
commit 9d9f95f99d

View file

@ -30,39 +30,38 @@ def hydra_callback():
token = HydraOauth.get_token(state, code) token = HydraOauth.get_token(state, code)
user_info = HydraOauth.get_user_info() user_info = HydraOauth.get_user_info()
# Match Kratos identity with Hydra # Match Kratos identity with Hydra
# identities = KratosApi.get("/identities") identities = KratosApi.get("/identities")
# identity = None identity = None
# for i in identities.json(): for i in identities.json():
# if i["traits"]["email"] == user_info["email"]: if i["traits"]["email"] == user_info["email"]:
# identity = i identity = i
access_token = create_access_token( access_token = create_access_token(
identity=token, expires_delta=timedelta(days=365), identity=token, expires_delta=timedelta(days=365), additional_claims={"user_id": identity["id"]}
#additional_claims={"user_id": identity["id"]}
) )
# apps = App.query.all() apps = App.query.all()
# app_roles = [] app_roles = []
# for app in apps: for app in apps:
# tmp_app_role = AppRole.query.filter_by( tmp_app_role = AppRole.query.filter_by(
# user_id=identity["id"], app_id=app.id user_id=identity["id"], app_id=app.id
# ).first() ).first()
# app_roles.append( app_roles.append(
# { {
# "name": app.slug, "name": app.slug,
# "role_id": tmp_app_role.role_id if tmp_app_role else None, "role_id": tmp_app_role.role_id if tmp_app_role else None,
# } }
# ) )
return jsonify( return jsonify(
{ {
"accessToken": access_token, "accessToken": access_token,
"userInfo": { "userInfo": {
"id": user_info["email"], "id": identity["id"],
"email": user_info["email"], "email": user_info["email"],
"name": user_info["name"], "name": user_info["name"],
"preferredUsername": user_info["preferred_username"], "preferredUsername": user_info["preferred_username"],
# "app_roles": app_roles, "app_roles": app_roles,
}, },
} }
) )