Skip to content

Commit

Permalink
fix issue of admin API not having poc_key in poc mode (NVIDIA#449)
Browse files Browse the repository at this point in the history
* fix issue of admin API not having poc_key in poc mode

* fix issue with poc mode using username and poc_key, move to inside AdminAPI
  • Loading branch information
nvkevlu authored Apr 27, 2022
1 parent 9f2c8b9 commit 9571667
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
10 changes: 3 additions & 7 deletions nvflare/fuel/hci/client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def __init__(
overseer_agent: OverseerAgent = None,
auto_login: bool = False,
user_name: str = None,
poc_key: str = None,
poc: bool = False,
debug: bool = False,
):
Expand All @@ -122,7 +121,6 @@ def __init__(
overseer_agent: initialized OverseerAgent to obtain the primary service provider to set the host and port of the active server
auto_login: Whether to use stored credentials to automatically log in (required to be True with OverseerAgent to provide high availability)
user_name: Username to authenticate with FL server
poc_key: Key used in POC mode to authenticate with FL server (not used in secure mode with SSL)
poc: Whether to enable poc mode for using the proof of concept example without secure communication.
debug: Whether to print debug messages, which can help with diagnosing problems. False by default.
"""
Expand All @@ -145,7 +143,9 @@ def __init__(
self.host = host
self.port = port
self.poc = poc
if not self.poc:
if self.poc:
self.poc_key = "admin"
else:
if len(ca_cert) <= 0:
raise Exception("missing CA Cert file name")
self.ca_cert = ca_cert
Expand Down Expand Up @@ -176,10 +176,6 @@ def __init__(
if not user_name:
raise Exception("for auto_login, user_name is required.")
self.user_name = user_name
if self.poc:
if not poc_key:
raise Exception("for auto_login, poc_key is required for poc mode.")
self.poc_key = poc_key

self.server_cmd_reg = CommandRegister(app_ctx=self)
self.client_cmd_reg = CommandRegister(app_ctx=self)
Expand Down
2 changes: 2 additions & 0 deletions nvflare/fuel/hci/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def __init__(
modules.append(m)

poc = True if self.credential_type == CredentialType.PASSWORD else False
if poc:
self.user_name = "admin"

self._get_login_creds()

Expand Down
3 changes: 0 additions & 3 deletions nvflare/fuel/hci/client/fl_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __init__(
cmd_modules: Optional[List] = None,
overseer_agent: OverseerAgent = None,
user_name: str = None,
poc_key: str = None,
poc=False,
debug=False,
):
Expand All @@ -112,7 +111,6 @@ def __init__(
cmd_modules: command modules to load and register. Note that FileTransferModule is initialized here with upload_dir and download_dir if cmd_modules is None.
overseer_agent: initialized OverseerAgent to obtain the primary service provider to set the host and port of the active server
user_name: Username to authenticate with FL server
poc_key: Key used in POC mode to authenticate with FL server (not used in secure mode with SSL)
poc: Whether to enable poc mode for using the proof of concept example without secure communication.
debug: Whether to print debug messages. False by default.
"""
Expand All @@ -127,7 +125,6 @@ def __init__(
overseer_agent=overseer_agent,
auto_login=True,
user_name=user_name,
poc_key=poc_key,
poc=poc,
debug=debug,
)
Expand Down
5 changes: 1 addition & 4 deletions nvflare/fuel/hci/client/fl_admin_api_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ def __init__(
os.makedirs(download_dir)

assert os.path.isdir(admin_dir), f"admin directory does not exist at {admin_dir}"
if self.poc:
poc_key = "admin"
else:
if not self.poc:
assert os.path.isfile(ca_cert), f"rootCA.pem does not exist at {ca_cert}"
assert os.path.isfile(client_cert), f"client.crt does not exist at {client_cert}"
assert os.path.isfile(client_key), f"client.key does not exist at {client_key}"
Expand All @@ -137,7 +135,6 @@ def __init__(
download_dir=download_dir,
overseer_agent=conf.overseer_agent,
user_name=username,
poc_key=poc_key,
poc=self.poc,
debug=debug,
)
Expand Down
1 change: 0 additions & 1 deletion tests/integration_test/admin_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(self, jobs_root_dir, ha, poll_period=10):
poc=True,
debug=False,
user_name="admin",
poc_key="admin",
)

self.logger = logging.getLogger(self.__class__.__name__)
Expand Down

0 comments on commit 9571667

Please sign in to comment.