Skip to content
Snippets Groups Projects
Commit 2bd2455a4827 authored by Arnaud Vergnet's avatar Arnaud Vergnet :sun_with_face:
Browse files

feat: catch more authentication errors

parent d6abe1425481
No related branches found
No related tags found
1 merge request!20feat: catch more authentication errors
Pipeline #135472 passed
......@@ -16,7 +16,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from enum import Enum
from cubicweb import AuthenticationError, QueryError
from cubicweb import AuthenticationError, QueryError, Unauthorized, Forbidden
from cubicweb.schema_exporters import JSONSchemaExporter
from rql import RQLException
from yams import ValidationError, UnknownType
......@@ -78,6 +78,6 @@
return func(request)
except HTTPError as e:
return e
except AuthenticationError as e:
except (AuthenticationError, Unauthorized) as e:
log.info(e.__class__.__name__, exc_info=True)
return get_http_error(401, e.__class__.__name__, str(e))
......@@ -82,5 +82,8 @@
log.info(e.__class__.__name__, exc_info=True)
return get_http_error(401, e.__class__.__name__, str(e))
except Forbidden as e:
log.info(e.__class__.__name__, exc_info=True)
return get_http_error(403, e.__class__.__name__, str(e))
except Exception:
log.info("ServerError", exc_info=True)
raise get_http_500_error()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment