diff --git a/seahub/adfs_auth/backends.py b/seahub/adfs_auth/backends.py index 4eb5df597a..47d99ab76f 100644 --- a/seahub/adfs_auth/backends.py +++ b/seahub/adfs_auth/backends.py @@ -50,7 +50,6 @@ class Saml2Backend(ModelBackend): def authenticate(self, session_info=None, attribute_mapping=None, create_unknown_user=True, org_id=None, **kwargs): if session_info is None or attribute_mapping is None: - logger.error('Session info or attribute mapping are None') return None name_id = session_info.get('name_id', '') diff --git a/seahub/adfs_auth/views.py b/seahub/adfs_auth/views.py index 5a4b273b62..d63b076550 100644 --- a/seahub/adfs_auth/views.py +++ b/seahub/adfs_auth/views.py @@ -276,6 +276,10 @@ def assertion_consumer_service(request, org_id=None, attribute_mapping=None, cre oq_cache.delete(session_id) session_info = response.session_info() attribute_mapping = attribute_mapping or SAML_ATTRIBUTE_MAPPING + if not attribute_mapping: + logger.error('ADFS attribute mapping is not valid.') + return render_error(request, login_failed_error_msg) + # saml2 connect relay_state = request.POST.get('RelayState', '/saml/complete/') @@ -314,6 +318,7 @@ def assertion_consumer_service(request, org_id=None, attribute_mapping=None, cre return HttpResponseRedirect(relay_state) if not session_info: + logger.error('ADFS session info is not valid.') return render_error(request, login_failed_error_msg) name_id = session_info.get('name_id', '') diff --git a/seahub/seadoc/apis.py b/seahub/seadoc/apis.py index d59822f793..327f6d6bf4 100644 --- a/seahub/seadoc/apis.py +++ b/seahub/seadoc/apis.py @@ -414,6 +414,9 @@ def latest_entry(request, file_uuid, filename): filepath = os.path.join(parent_path, filename) filepath = os.path.normpath(filepath) file_obj = seafile_api.get_dirent_by_path(repo_id, filepath) + if not file_obj: + logger.warning(f'file {filepath} not found') + return None dt = datetime.fromtimestamp(file_obj.mtime) return dt except Exception as e: