Skip to content

Commit

Permalink
Add debug log (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre committed Jun 17, 2024
1 parent d020edf commit 7532951
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion fence/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion fence/jwt/utils.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
2 changes: 1 addition & 1 deletion fence/sync/sync_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*"
Expand Down

0 comments on commit 7532951

Please sign in to comment.