[dd-sso-admin] bugfix and add tracing for 3p cbs
parent
0eb8f5f549
commit
822ed98ab4
|
@ -116,19 +116,25 @@ class Admin:
|
|||
|
||||
def third_party_add_user(self, user_id : str, user : DDUser) -> bool:
|
||||
res = True
|
||||
log.warning(f" 3P Callbacks: Add {user_id}")
|
||||
for tp in self.third_party_cbs:
|
||||
log.warning(f" 3P Callbacks: Add {user_id} to {tp.tpkeys.their_name}")
|
||||
res = res and tp.add_user(user_id, user)
|
||||
return res
|
||||
|
||||
def third_party_update_user(self, user_id : str, user : DDUser) -> bool:
|
||||
res = True
|
||||
log.warning(f" 3P Callbacks: update {user_id}")
|
||||
for tp in self.third_party_cbs:
|
||||
log.warning(f" 3P Callbacks: update {user_id} to {tp.tpkeys.their_name}")
|
||||
res = res and tp.update_user(user_id, user)
|
||||
return res
|
||||
|
||||
def third_party_delete_user(self, user_id : str) -> bool:
|
||||
res = True
|
||||
log.warning(f" 3P Callbacks: delete {user_id}")
|
||||
for tp in self.third_party_cbs:
|
||||
log.warning(f" 3P Callbacks: delete {user_id} to {tp.tpkeys.their_name}")
|
||||
res = res and tp.delete_user(user_id)
|
||||
return res
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import copy
|
||||
import logging as log
|
||||
import traceback
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
import requests
|
||||
|
@ -77,25 +79,27 @@ class ThirdPartyCallbacks:
|
|||
|
||||
@property
|
||||
def add_users_url(self) -> str:
|
||||
return f"{self.tpkeys.their_service_domain}{self.endpoint_add_users[1]}"
|
||||
return f"https://{self.tpkeys.their_service_domain}{self.endpoint_add_users[1]}"
|
||||
|
||||
@property
|
||||
def update_users_url(self) -> str:
|
||||
return f"{self.tpkeys.their_service_domain}{self.endpoint_update_users[1]}"
|
||||
return f"https://{self.tpkeys.their_service_domain}{self.endpoint_update_users[1]}"
|
||||
|
||||
@property
|
||||
def delete_users_url(self) -> str:
|
||||
return f"{self.tpkeys.their_service_domain}{self.endpoint_delete_users[1]}"
|
||||
return f"https://{self.tpkeys.their_service_domain}{self.endpoint_delete_users[1]}"
|
||||
|
||||
def _request(self, method: str, url: str, data: DDUser) -> bool:
|
||||
# The endpoints are prepared for batch operations, but the way
|
||||
# the admin lib is set up, it is currently not doable.
|
||||
prepared_data = [user_parser(data)]
|
||||
log.warning(f" {method} {url} {data.get('id', '?')}")
|
||||
try:
|
||||
enc_data = self.tpkeys.sign_and_encrypt_outgoing_json(prepared_data)
|
||||
headers = self.tpkeys.get_outgoing_request_headers()
|
||||
res = requests.request(method, url, data=enc_data, headers=headers)
|
||||
except:
|
||||
log.error(traceback.format_exc())
|
||||
# Something went wrong sending the request
|
||||
return False
|
||||
return res.status_code == 200
|
||||
|
|
Loading…
Reference in New Issue