Skip to content

Commit

Permalink
fixing baseclient oidc import rucio#3609
Browse files Browse the repository at this point in the history
  • Loading branch information
gumond committed May 19, 2020
1 parent 9519b30 commit 230435e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bin/rucio
Expand Up @@ -33,7 +33,7 @@
# - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2018-2019
# - Dimitrios Christidis <dimitrios.christidis@cern.ch>, 2018-2020
# - Ruturaj Gujar, <ruturaj.gujar23@gmail.com>, 2019
# - Jaroslav Guenther <jaroslav.guenther@gmail.com>, 2019
# - Jaroslav Guenther <jaroslav.guenther@gmail.com>, 2019-2020
# - Benedikt Ziemons <benedikt.ziemons@cern.ch>, 2020
#
# PY3K COMPATIBLE
Expand Down
2 changes: 1 addition & 1 deletion bin/rucio-admin
Expand Up @@ -29,7 +29,7 @@
# - Hannes Hansen, <hannes.jakob.hansen@cern.ch>, 2018-2019
# - Dimitrios Christidis, <dimitrios.christidis@cern.ch>, 2019-2020
# - Ruturaj Gujar, <ruturaj.gujar23@gmail.com>, 2019
# - Jaroslav Guenther <jaroslav.guenther@gmail.com>, 2019
# - Jaroslav Guenther <jaroslav.guenther@gmail.com>, 2019-2020
#
# PY3K COMPATIBLE

Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/api/authentication.py
Expand Up @@ -18,7 +18,7 @@
# - Martin Barisits <martin.barisits@cern.ch>, 2017
# - Andrew Lister, <andrew.lister@stfc.ac.uk>, 2019
# - Ruturaj Gujar <ruturaj.gujar23@gmail.com>, 2019
# - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019
# - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019, 2020
#
# PY3K COMPATIBLE

Expand Down
25 changes: 14 additions & 11 deletions lib/rucio/client/baseclient.py
Expand Up @@ -174,25 +174,28 @@ def __init__(self, rucio_host=None, auth_host=None, account=None, ca_cert=None,
raise MissingClientParameter('Option \'%s\' cannot be found in config file' % error.args[0])

if self.auth_type == 'oidc':
if self.creds['oidc_refresh_lifetime'] is None:
if not self.creds:
self.creds = {}
# if there are defautl values, check if rucio.cfg does not specify them, otherwise put default
if 'oidc_refresh_lifetime' not in self.creds or self.creds['oidc_refresh_lifetime'] is None:
self.creds['oidc_refresh_lifetime'] = config_get('client', 'oidc_refresh_lifetime', False, None)
if self.creds['oidc_issuer'] is None:
if 'oidc_issuer' not in self.creds or self.creds['oidc_issuer'] is None:
self.creds['oidc_issuer'] = config_get('client', 'oidc_issuer', False, None)
if self.creds['oidc_audience'] is None:
self.creds['oidc_audience'] = config_get('client', 'oidc_audience', False, '')
if self.creds['oidc_auto'] is False:
if 'oidc_audience' not in self.creds or self.creds['oidc_audience'] is None:
self.creds['oidc_audience'] = config_get('client', 'oidc_audience', False, None)
if 'oidc_auto' not in self.creds or self.creds['oidc_auto'] is False:
self.creds['oidc_auto'] = config_get_bool('client', 'oidc_auto', False, False)
if self.creds['oidc_auto']:
if self.creds['oidc_username'] is None:
if 'oidc_username' not in self.creds or self.creds['oidc_username'] is None:
self.creds['oidc_username'] = config_get('client', 'oidc_username', False, None)
if self.creds['oidc_password'] is None:
if 'oidc_password' not in self.creds or self.creds['oidc_password'] is None:
self.creds['oidc_password'] = config_get('client', 'oidc_password', False, None)
if self.creds['oidc_scope'] == 'openid profile':
if 'oidc_scope' not in self.creds or self.creds['oidc_scope'] == 'openid profile':
self.creds['oidc_scope'] = config_get('client', 'oidc_scope', False, 'openid profile')
if self.creds['oidc_polling'] is False:
if 'oidc_polling' not in self.creds or self.creds['oidc_polling'] is False:
self.creds['oidc_polling'] = config_get_bool('client', 'oidc_polling', False, False)

if creds is None:
if not self.creds:
LOG.debug('no creds passed. Trying to get it from the config file.')
self.creds = {}
try:
Expand Down Expand Up @@ -428,6 +431,7 @@ def __refresh_token_OIDC(self):

headers = {'X-Rucio-Account': self.account,
'X-Rucio-Auth-Token': self.auth_token}
headers = {}

for retry in range(self.AUTH_RETRIES + 1):
try:
Expand Down Expand Up @@ -915,7 +919,6 @@ def __authenticate(self):
"""
Main method for authentication. It first tries to read a locally saved token. If not available it requests a new one.
"""

if self.auth_type == 'userpass':
if self.creds['username'] is None or self.creds['password'] is None:
raise NoAuthInformation('No username or password passed')
Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/core/authentication.py
Expand Up @@ -22,7 +22,7 @@
# - Thomas Beermann <thomas.beermann@cern.ch>, 2017
# - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2018
# - Ruturaj Gujar <ruturaj.gujar23@gmail.com>, 2019
# - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019
# - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019, 2020
#
# PY3K COMPATIBLE

Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/core/oidc.py
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
#
# Authors:
# - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019-2020
# - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019, 2020
#
# PY3K COMPATIBLE

Expand Down
2 changes: 1 addition & 1 deletion lib/rucio/web/rest/webpy/v1/authentication.py
Expand Up @@ -23,7 +23,7 @@
# - Martin Barisits <martin.barisits@cern.ch>, 2017
# - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2018-2019
# - Ruturaj Gujar, <ruturaj.gujar23@gmail.com>, 2019
# - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019
# - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019, 2020
#
# PY3K COMPATIBLE

Expand Down

0 comments on commit 230435e

Please sign in to comment.