From 6f3a4538db71d7c90b6e4fd6bd61ec0f6a1b2d15 Mon Sep 17 00:00:00 2001 From: tdviet Date: Mon, 24 Oct 2022 16:46:36 +0200 Subject: [PATCH 1/6] Remove unnecessary constant --- fedcloudclient/checkin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/fedcloudclient/checkin.py b/fedcloudclient/checkin.py index abcd7e7..2bf5f5b 100644 --- a/fedcloudclient/checkin.py +++ b/fedcloudclient/checkin.py @@ -18,7 +18,6 @@ # Minimal lifetime of the access token is 30s and max 24h _MIN_ACCESS_TOKEN_TIME = 30 -_MAX_ACCESS_TOKEN_TIME = 24 * 3600 VO_PATTERN = "urn:mace:egi.eu:group:(.+?):(.+:)*role=member#aai.egi.eu" From 216edba8b8e1e66e22e2ee5d5b0943e182814fae Mon Sep 17 00:00:00 2001 From: tdviet Date: Mon, 24 Oct 2022 16:55:07 +0200 Subject: [PATCH 2/6] Remove unnecessary constant --- fedcloudclient/checkin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fedcloudclient/checkin.py b/fedcloudclient/checkin.py index 59c7163..552932e 100644 --- a/fedcloudclient/checkin.py +++ b/fedcloudclient/checkin.py @@ -60,6 +60,7 @@ def oidc_discover(oidc_url): def get_token_from_oidc_agent(oidc_agent_account, quiet=False): """ Get access token from oidc-agent + :param quiet: :param oidc_agent_account: account name in oidc-agent :return: access token, or None on error """ @@ -84,6 +85,7 @@ def get_token_from_oidc_agent(oidc_agent_account, quiet=False): def get_token_from_mytoken_server(mytoken, mytoken_server, quiet=False): """ Get access token from mytoken server + :param quiet: :param mytoken: :param mytoken_server: :return: access token, or None on error From c417c5e8637d697bff97058a85c37000305dd2e6 Mon Sep 17 00:00:00 2001 From: tdviet Date: Mon, 24 Oct 2022 17:03:51 +0200 Subject: [PATCH 3/6] Upgrade libraries --- requirements.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index c16eb06..b495c60 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,15 @@ click~=8.1.3 click_option_group>=0.5.3 -tabulate==0.8.10 -requests~=2.28.0 +tabulate>=0.8.9 +requests>=2.27.1 defusedxml~=0.7.1 -pyjwt~=2.4.0 -python-openstackclient==5.8.0 +pyjwt>=2.3.0 +python-openstackclient>=5.7.0 liboidcagent~=0.4.0 jsonpath-ng==1.5.3 PyYAML~=6.0 -setuptools~=62.6.0 -jsonschema~=4.6.0 -psutil~=5.9.1 -hvac~=0.11.2 -cryptography==37.0.2 \ No newline at end of file +setuptools>=65.5.0 +jsonschema>=4.16.0 +psutil>=5.9.0 +hvac>=1.0.2 +cryptography>=38.0.1 \ No newline at end of file From a560d59ad951af5fdc9eaa2f90580b396ae32bad Mon Sep 17 00:00:00 2001 From: tdviet Date: Mon, 24 Oct 2022 18:06:30 +0200 Subject: [PATCH 4/6] Print error messages (quiet=False) when trying to get access token --- fedcloudclient/checkin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fedcloudclient/checkin.py b/fedcloudclient/checkin.py index 552932e..2a3ec01 100644 --- a/fedcloudclient/checkin.py +++ b/fedcloudclient/checkin.py @@ -130,7 +130,7 @@ def check_token(oidc_token, verbose=False): exp_time_in_sec = exp_timestamp - current_timestamp if exp_time_in_sec < _MIN_ACCESS_TOKEN_TIME: - print_error("Error: Expired access token.", True) + print_error("Error: Expired access token.", False) return None if verbose: @@ -193,12 +193,12 @@ def get_access_token( # then try to get access token from mytoken server if mytoken and access_token is None: access_token = get_token_from_mytoken_server( - mytoken, mytoken_server, quiet=True + mytoken, mytoken_server, quiet=False ) # then, try to get access token from oidc-agent if oidc_agent_account and access_token is None: - access_token = get_token_from_oidc_agent(oidc_agent_account, quiet=True) + access_token = get_token_from_oidc_agent(oidc_agent_account, quiet=False) if access_token is None: # Nothing available From ffd1ff6af925e5ee9be112d35f9c1046016a355f Mon Sep 17 00:00:00 2001 From: tdviet Date: Tue, 22 Nov 2022 13:26:53 +0100 Subject: [PATCH 5/6] Print error messages (quiet=False) when if parameter (mytoken, oidc-account) are set and cannot to get access token --- fedcloudclient/checkin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedcloudclient/checkin.py b/fedcloudclient/checkin.py index 2a3ec01..41b03bd 100644 --- a/fedcloudclient/checkin.py +++ b/fedcloudclient/checkin.py @@ -171,7 +171,7 @@ def get_access_token( ): """ Get access token - Generates new access token from oidc-agent or + Generates new access token from oidc-agent or mytoken Check expiration time of access token From d889dbb50f1581370d1c59121e1dd84de8001845 Mon Sep 17 00:00:00 2001 From: tdviet Date: Tue, 22 Nov 2022 13:27:28 +0100 Subject: [PATCH 6/6] Update documentation for removing EGI_SITE envvar --- docs/cheat.rst | 2 +- docs/usage.rst | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/cheat.rst b/docs/cheat.rst index fd68d06..2a3e0a5 100644 --- a/docs/cheat.rst +++ b/docs/cheat.rst @@ -236,7 +236,7 @@ Useful commands # Pass it to OpenStack EGI_SITE=IISAS-FedCloud EGI_VO=vo.access.egi.eu - fedcloud openstack server create --flavor --image --user-data user.txt --key-name testvm + fedcloud openstack server create --site $EGI_SITE --flavor --image --user-data user.txt --key-name testvm # Once you log into the VM you can retrieve the "mytoken" with curl http://169.254.169.254/openstack/latest/user_data/ diff --git a/docs/usage.rst b/docs/usage.rst index 914aa54..24c78ec 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -58,8 +58,6 @@ Most of fedcloud options, including options for tokens can be set via environmen +-----------------------------+---------------------------------+------------------------------------+ | OPENSTACK_AUTH_TYPE | --openstack-auth-type | v3oidcaccesstoken | +-----------------------------+---------------------------------+------------------------------------+ -| EGI_SITE | --site | | -+-----------------------------+---------------------------------+------------------------------------+ | EGI_VO | --vo | | +-----------------------------+---------------------------------+------------------------------------+