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