Skip to content

Commit

Permalink
Merge pull request #177 from tdviet/devel
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
tdviet committed Nov 22, 2022
2 parents bc54cd5 + d889dbb commit 33460d0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/cheat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <flavor> --image <image> --user-data user.txt --key-name <keypair> testvm
fedcloud openstack server create --site $EGI_SITE --flavor <flavor> --image <image> --user-data user.txt --key-name <keypair> testvm

# Once you log into the VM you can retrieve the "mytoken" with
curl http://169.254.169.254/openstack/latest/user_data/
Expand Down
2 changes: 0 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
+-----------------------------+---------------------------------+------------------------------------+

Expand Down
11 changes: 6 additions & 5 deletions fedcloudclient/checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -61,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
"""
Expand All @@ -85,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
Expand Down Expand Up @@ -129,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:
Expand Down Expand Up @@ -170,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
Expand All @@ -192,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
Expand Down
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
setuptools>=65.5.0
jsonschema>=4.16.0
psutil>=5.9.0
hvac>=1.0.2
cryptography>=38.0.1

0 comments on commit 33460d0

Please sign in to comment.