[hydra] also set redirect url on setup

master
tuxcoder 2023-12-24 11:10:49 +01:00
parent 2d2766ac30
commit aaf91cb580
1 changed files with 5 additions and 3 deletions

View File

@ -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")