diff --git a/fence/auth.py b/fence/auth.py index 3bc1873f3..e23ada890 100644 --- a/fence/auth.py +++ b/fence/auth.py @@ -35,7 +35,10 @@ def get_jwt(): try: bearer, token = header.split(" ") except ValueError: - raise Unauthorized("authorization header not in expected format") + msg = "authorization header not in expected format" + logger.debug(f"{msg}. Received header: {header}") + logger.error(f"{msg}.") + raise Unauthorized(msg) if bearer.lower() != "bearer": raise Unauthorized("expected bearer token in auth header") return token diff --git a/fence/jwt/utils.py b/fence/jwt/utils.py index eada044a7..be6c60f4b 100644 --- a/fence/jwt/utils.py +++ b/fence/jwt/utils.py @@ -1,8 +1,13 @@ import flask +from cdislogging import get_logger + from fence.errors import Unauthorized +logger = get_logger(__name__) + + def get_jwt_header(): """ Get the user's JWT from the Authorization header, or raise Unauthorized on failure. @@ -18,5 +23,8 @@ def get_jwt_header(): try: jwt = header.split(" ")[1] except IndexError: - raise Unauthorized("authorization header missing token") + msg = "authorization header missing token" + logger.debug(f"{msg}. Received header: {header}") + logger.error(f"{msg}.") + raise Unauthorized(msg) return jwt diff --git a/fence/sync/sync_users.py b/fence/sync/sync_users.py index bcecff599..4320e58ab 100644 --- a/fence/sync/sync_users.py +++ b/fence/sync/sync_users.py @@ -1546,7 +1546,7 @@ def _download(self, dbgap_config): return dbgap_files except Exception as e: self.logger.error(e) - exit(1) + raise def _sync(self, sess): """ diff --git a/poetry.lock b/poetry.lock index 0cfec2090..6fca33c54 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "addict" @@ -2574,4 +2574,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0.0" -content-hash = "15fa26563356231f953231220a30b01ef697832e438b43da018c0529e4e84c6d" +content-hash = "9e2f3df721c8367c7d0054a034d9e33d84e3ec981c1304ce8a0199d413437b6f" diff --git a/pyproject.toml b/pyproject.toml index 06be4f2e3..a26dc447e 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ alembic = "^1.7.7" authlib = {git = "https://github.com/uc-cdis/authlib", rev = "v0.11_CVE_patch_v1"} # authlib = "*" # let authutils decide which version we're using -authutils = "^6.2.2" +authutils = "<7" bcrypt = "^3.1.4" boto3 = "*" botocore = "*"