diff --git a/nvflare/app_common/widgets/external_configurator.py b/nvflare/app_common/widgets/external_configurator.py index b9b8c5b14d..d3127bf975 100644 --- a/nvflare/app_common/widgets/external_configurator.py +++ b/nvflare/app_common/widgets/external_configurator.py @@ -16,10 +16,11 @@ from typing import List from nvflare.apis.event_type import EventType -from nvflare.apis.fl_constant import FLMetaKey +from nvflare.apis.fl_constant import FLMetaKey, SecureTrainConst from nvflare.apis.fl_context import FLContext from nvflare.client.config import write_config_to_file from nvflare.client.constants import CLIENT_API_CONFIG +from nvflare.fuel.data_event.utils import get_scope_property from nvflare.fuel.utils.attributes_exportable import ExportMode, export_components from nvflare.fuel.utils.validation_utils import check_object_type from nvflare.widgets.widget import Widget @@ -47,8 +48,19 @@ def __init__( def handle_event(self, event_type: str, fl_ctx: FLContext): if event_type == EventType.ABOUT_TO_START_RUN: components_data = self._export_all_components(fl_ctx) - components_data[FLMetaKey.SITE_NAME] = fl_ctx.get_identity_name() + + site_name = fl_ctx.get_identity_name() + auth_token = get_scope_property(scope_name=site_name, key=FLMetaKey.AUTH_TOKEN, default="NA") + signature = get_scope_property(scope_name=site_name, key=FLMetaKey.AUTH_TOKEN_SIGNATURE, default="NA") + + components_data[FLMetaKey.SITE_NAME] = site_name components_data[FLMetaKey.JOB_ID] = fl_ctx.get_job_id() + components_data[FLMetaKey.AUTH_TOKEN] = auth_token + components_data[FLMetaKey.AUTH_TOKEN_SIGNATURE] = signature + + conn_sec = get_scope_property(site_name, SecureTrainConst.CONNECTION_SECURITY) + if conn_sec: + components_data[SecureTrainConst.CONNECTION_SECURITY] = conn_sec config_file_path = self._get_external_config_file_path(fl_ctx) write_config_to_file(config_data=components_data, config_file_path=config_file_path) @@ -65,5 +77,11 @@ def _export_all_components(self, fl_ctx: FLContext) -> dict: engine = fl_ctx.get_engine() all_components = engine.get_all_components() components = {i: all_components.get(i) for i in self._component_ids} - reserved_keys = [FLMetaKey.SITE_NAME, FLMetaKey.JOB_ID] + reserved_keys = [ + FLMetaKey.SITE_NAME, + FLMetaKey.JOB_ID, + FLMetaKey.AUTH_TOKEN, + FLMetaKey.AUTH_TOKEN_SIGNATURE, + SecureTrainConst.CONNECTION_SECURITY, + ] return export_components(components=components, reserved_keys=reserved_keys, export_mode=ExportMode.PEER)