Skip to content

Commit

Permalink
[SYNPY-1296] Config client error with api key or PAT (#990)
Browse files Browse the repository at this point in the history
* Update to check for blank username
  • Loading branch information
BryanFauble committed Oct 20, 2023
1 parent f2a4a40 commit 4f7cf52
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions synapseclient/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,18 +1792,23 @@ def _authenticate_login(syn, user, secret, **login_kwargs):

login_attempts = (
# a username is required when attempting a password login
("password", lambda user, secret: user is not None and secret is not None),
(
"password",
lambda user, secret: user is not None and user != "" and secret is not None,
),
# auth token login can be attempted without a username.
# although tokens are technically encoded, the client treats them as opaque so we don't do an encoding check
# on the secret itself
("authToken", lambda user, secret: secret is not None),
# username is required for an api key and secret is base 64 encoded
(
"apiKey",
lambda user, secret: user is not None and utils.is_base64_encoded(secret),
lambda user, secret: user is not None
and user != ""
and utils.is_base64_encoded(secret),
),
# an inputless login (i.e. derived from config or cache)
(None, lambda user, secret: user is None and secret is None),
(None, lambda user, secret: (user is None or user == "") and secret is None),
)

first_auth_ex = None
Expand Down

0 comments on commit 4f7cf52

Please sign in to comment.