Skip to content

Commit

Permalink
[COST-5711] - Add new middleware access check (#5400)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcouzens authored Nov 26, 2024
1 parent b8af477 commit a53b35f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions koku/koku/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ def is_no_entitled(request):
return no_auth


def is_no_access(request):
"""Check condition for user access."""
no_access_list = ["aws-s3-regions"]
no_auth = any(no_auth_path in request.path for no_auth_path in no_access_list)
return no_auth


class HttpResponseUnauthorizedRequest(HttpResponse):
"""A subclass of HttpResponse to return a 401.
Used if identity header is not sent.
Expand Down Expand Up @@ -190,6 +197,8 @@ def _check_user_has_access(self, request):
PermissionDenied: If the user does not have permissions for Cost Management.
"""
if is_no_access(request):
return
if not request.user.admin and not request.user.access:
msg = f"User {request.user.username} does not have permissions for Cost Management."
LOG.warning(msg)
Expand Down

0 comments on commit a53b35f

Please sign in to comment.