From aaf91cb580727c35184b628a10b176d21742af8d Mon Sep 17 00:00:00 2001 From: tuxcoder Date: Sun, 24 Dec 2023 11:10:49 +0100 Subject: [PATCH] [hydra] also set redirect url on setup --- lenticular_cloud/hydra.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lenticular_cloud/hydra.py b/lenticular_cloud/hydra.py index be6a31a..fafaeff 100644 --- a/lenticular_cloud/hydra.py +++ b/lenticular_cloud/hydra.py @@ -24,6 +24,7 @@ class HydraService: client_name = app.config['OAUTH_ID'] client_secret = app.config['OAUTH_SECRET'] + public_url = app.config['PUBLIC_URL'] clients = list_o_auth_2_clients.sync_detailed(_client=self.hydra_client).parsed if clients is None: @@ -35,8 +36,7 @@ class HydraService: break if client is None: - public_url = app.config['PUBLIC_URL'] - client = OAuth20Client( + client_req = OAuth20Client( client_name="identiy_provider", # client_id=client_id, client_secret=client_secret, @@ -46,11 +46,13 @@ class HydraService: redirect_uris=[ f"{public_url}/oauth/authorized" ], token_endpoint_auth_method="client_secret_basic", ) - ret = create_o_auth_2_client.sync(json_body=client, _client=self.hydra_client) + ret = create_o_auth_2_client.sync(json_body=client_req, _client=self.hydra_client) if ret is None: raise RuntimeError("could not create account") + client = ret else: client.client_secret = client_secret + client.redirect_uris = [ f"{public_url}/oauth/authorized" ] ret = set_o_auth_2_client.sync(id=client.client_id, json_body=client, _client=self.hydra_client) if ret is None: raise RuntimeError("could not update account")