From 2165d71d328181709ea64be1f93f76be61203974 Mon Sep 17 00:00:00 2001 From: Oleg Zharkov Date: Thu, 22 Oct 2020 15:12:09 +0200 Subject: [PATCH 1/6] proper error msg --- lib/galaxy/webapps/galaxy/api/authenticate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/webapps/galaxy/api/authenticate.py b/lib/galaxy/webapps/galaxy/api/authenticate.py index 570ad83cc52..c3ea5cafca9 100644 --- a/lib/galaxy/webapps/galaxy/api/authenticate.py +++ b/lib/galaxy/webapps/galaxy/api/authenticate.py @@ -92,7 +92,14 @@ class AuthenticationController(BaseAPIController): :raises: HTTPBadRequest """ - split = encoded_str.strip().split(' ') + try: + split = encoded_str.strip().split(' ') + except AttributeError: + if not encoded_str: + raise exceptions.MessageException( + 'Authentication is missing') + raise exceptions.MessageException( + 'Failed to authenticate') # If split is only one element, try to decode the email and password # directly. From c54015466bb1851762a9e90cebc580ca1e9f9863 Mon Sep 17 00:00:00 2001 From: Oleg Zharkov Date: Thu, 22 Oct 2020 15:22:48 +0200 Subject: [PATCH 2/6] formating --- lib/galaxy/webapps/galaxy/api/authenticate.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/api/authenticate.py b/lib/galaxy/webapps/galaxy/api/authenticate.py index c3ea5cafca9..d8d03eaff0d 100644 --- a/lib/galaxy/webapps/galaxy/api/authenticate.py +++ b/lib/galaxy/webapps/galaxy/api/authenticate.py @@ -98,8 +98,9 @@ class AuthenticationController(BaseAPIController): if not encoded_str: raise exceptions.MessageException( 'Authentication is missing') - raise exceptions.MessageException( - 'Failed to authenticate') + else: + raise exceptions.MessageException( + 'Failed to authenticate') # If split is only one element, try to decode the email and password # directly. From ef155452cf55255afec6097e4a6c3c5ddef40a95 Mon Sep 17 00:00:00 2001 From: Oleg Zharkov Date: Thu, 22 Oct 2020 16:23:14 +0200 Subject: [PATCH 3/6] Update lib/galaxy/webapps/galaxy/api/authenticate.py Co-authored-by: Dannon --- lib/galaxy/webapps/galaxy/api/authenticate.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/api/authenticate.py b/lib/galaxy/webapps/galaxy/api/authenticate.py index d8d03eaff0d..e3a6bb103bf 100644 --- a/lib/galaxy/webapps/galaxy/api/authenticate.py +++ b/lib/galaxy/webapps/galaxy/api/authenticate.py @@ -96,11 +96,9 @@ class AuthenticationController(BaseAPIController): split = encoded_str.strip().split(' ') except AttributeError: if not encoded_str: - raise exceptions.MessageException( - 'Authentication is missing') + raise exceptions.MessageException('Authentication is missing') else: - raise exceptions.MessageException( - 'Failed to authenticate') + raise exceptions.MessageException('Failed to authenticate') # If split is only one element, try to decode the email and password # directly. From 754da6bcc60476d1758a56f500853a8da4e29442 Mon Sep 17 00:00:00 2001 From: Oleg Zharkov Date: Fri, 23 Oct 2020 13:03:44 +0200 Subject: [PATCH 4/6] Update lib/galaxy/webapps/galaxy/api/authenticate.py Co-authored-by: Dannon --- lib/galaxy/webapps/galaxy/api/authenticate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/webapps/galaxy/api/authenticate.py b/lib/galaxy/webapps/galaxy/api/authenticate.py index e3a6bb103bf..475347957dd 100644 --- a/lib/galaxy/webapps/galaxy/api/authenticate.py +++ b/lib/galaxy/webapps/galaxy/api/authenticate.py @@ -96,7 +96,7 @@ class AuthenticationController(BaseAPIController): split = encoded_str.strip().split(' ') except AttributeError: if not encoded_str: - raise exceptions.MessageException('Authentication is missing') + raise exceptions.RequestParameterInvalidException('Authentication is missing') else: raise exceptions.MessageException('Failed to authenticate') From 19a783ca04cf4e6a222bcfd89705741cdf24af1e Mon Sep 17 00:00:00 2001 From: Oleg Zharkov Date: Fri, 23 Oct 2020 13:16:25 +0200 Subject: [PATCH 5/6] remove if condition --- lib/galaxy/webapps/galaxy/api/authenticate.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/api/authenticate.py b/lib/galaxy/webapps/galaxy/api/authenticate.py index 475347957dd..ac29256dce0 100644 --- a/lib/galaxy/webapps/galaxy/api/authenticate.py +++ b/lib/galaxy/webapps/galaxy/api/authenticate.py @@ -95,10 +95,8 @@ class AuthenticationController(BaseAPIController): try: split = encoded_str.strip().split(' ') except AttributeError: - if not encoded_str: - raise exceptions.RequestParameterInvalidException('Authentication is missing') - else: - raise exceptions.MessageException('Failed to authenticate') + raise exceptions.RequestParameterInvalidException('Authentication is missing') + # If split is only one element, try to decode the email and password # directly. From eccf4e3f35e10ab5e2c95bf13b5adfb5ff6075b4 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Fri, 23 Oct 2020 08:10:03 -0400 Subject: [PATCH 6/6] Minor lint fix --- lib/galaxy/webapps/galaxy/api/authenticate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/galaxy/webapps/galaxy/api/authenticate.py b/lib/galaxy/webapps/galaxy/api/authenticate.py index ac29256dce0..914bbbedf69 100644 --- a/lib/galaxy/webapps/galaxy/api/authenticate.py +++ b/lib/galaxy/webapps/galaxy/api/authenticate.py @@ -97,7 +97,6 @@ class AuthenticationController(BaseAPIController): except AttributeError: raise exceptions.RequestParameterInvalidException('Authentication is missing') - # If split is only one element, try to decode the email and password # directly. if len(split) == 1: