Skip to content

Commit

Permalink
support conn sec for cell pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
yanchengnv committed Dec 12, 2024
1 parent f73e127 commit e001178
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
6 changes: 5 additions & 1 deletion nvflare/app_common/executors/client_api_launcher_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os
from typing import Optional

from nvflare.apis.fl_constant import FLMetaKey
from nvflare.apis.fl_constant import FLMetaKey, SecureTrainConst
from nvflare.apis.fl_context import FLContext
from nvflare.app_common.app_constant import AppConstants
from nvflare.app_common.executors.launcher_executor import LauncherExecutor
Expand Down Expand Up @@ -138,6 +138,10 @@ def prepare_config_for_launch(self, fl_ctx: FLContext):
FLMetaKey.AUTH_TOKEN_SIGNATURE: signature,
}

conn_sec = get_scope_property(site_name, SecureTrainConst.CONNECTION_SECURITY)
if conn_sec:
config_data[SecureTrainConst.CONNECTION_SECURITY] = conn_sec

config_file_path = self._get_external_config_file_path(fl_ctx)
write_config_to_file(config_data=config_data, config_file_path=config_file_path)

Expand Down
5 changes: 4 additions & 1 deletion nvflare/client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import os
from typing import Dict, Optional

from nvflare.apis.fl_constant import FLMetaKey
from nvflare.apis.fl_constant import FLMetaKey, SecureTrainConst
from nvflare.fuel.utils.config_factory import ConfigFactory


Expand Down Expand Up @@ -165,6 +165,9 @@ def get_auth_token(self):
def get_auth_token_signature(self):
return self.config.get(FLMetaKey.AUTH_TOKEN_SIGNATURE)

def get_connection_security(self):
return self.config.get(SecureTrainConst.CONNECTION_SECURITY)

def to_json(self, config_file: str):
with open(config_file, "w") as f:
json.dump(self.config, f, indent=2)
Expand Down
7 changes: 6 additions & 1 deletion nvflare/client/ex_process/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Any, Dict, Optional, Tuple

from nvflare.apis.analytix import AnalyticsDataType
from nvflare.apis.fl_constant import FLMetaKey
from nvflare.apis.fl_constant import FLMetaKey, SecureTrainConst
from nvflare.apis.utils.analytix_utils import create_analytic_dxo
from nvflare.app_common.abstract.fl_model import FLModel
from nvflare.client.api_spec import APISpec
Expand Down Expand Up @@ -45,6 +45,11 @@ def _create_client_config(config: str) -> ClientConfig:
site_name = client_config.get_site_name()
set_scope_property(scope_name=site_name, key=FLMetaKey.AUTH_TOKEN, value=auth_token)
set_scope_property(scope_name=site_name, key=FLMetaKey.AUTH_TOKEN_SIGNATURE, value=signature)

conn_sec = client_config.get_connection_security()
if conn_sec:
set_scope_property(site_name, SecureTrainConst.CONNECTION_SECURITY, conn_sec)

return client_config


Expand Down
6 changes: 5 additions & 1 deletion nvflare/fuel/utils/pipe/cell_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import time
from typing import Tuple, Union

from nvflare.apis.fl_constant import CellMessageAuthHeaderKey, FLMetaKey, SystemVarName
from nvflare.apis.fl_constant import CellMessageAuthHeaderKey, FLMetaKey, SecureTrainConst, SystemVarName
from nvflare.fuel.data_event.utils import get_scope_property
from nvflare.fuel.f3.cellnet.cell import Cell
from nvflare.fuel.f3.cellnet.cell import Message as CellMessage
Expand Down Expand Up @@ -149,6 +149,10 @@ def _build_cell(cls, mode, root_url, site_name, token, secure_mode, workspace_di
DriverParams.CA_CERT.value: root_cert_path,
}

conn_sec = get_scope_property(site_name, SecureTrainConst.CONNECTION_SECURITY)
if conn_sec:
credentials[DriverParams.CONNECTION_SECURITY.value] = conn_sec

cell = Cell(
fqcn=_cell_fqcn(mode, site_name, token),
root_url=root_url,
Expand Down
1 change: 1 addition & 0 deletions nvflare/private/fed/client/fed_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def _create_cell(self, location, scheme):
conn_security = self.client_args.get(SecureTrainConst.CONNECTION_SECURITY)
if conn_security:
credentials[DriverParams.CONNECTION_SECURITY.value] = conn_security
set_scope_prop(self.client_name, SecureTrainConst.CONNECTION_SECURITY, conn_security)
else:
credentials = {}
self.cell = Cell(
Expand Down

0 comments on commit e001178

Please sign in to comment.