Skip to content

Commit a53b35f

Browse files
authored
[COST-5711] - Add new middleware access check (#5400)
1 parent b8af477 commit a53b35f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

koku/koku/middleware.py

+9
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ def is_no_entitled(request):
7373
return no_auth
7474

7575

76+
def is_no_access(request):
77+
"""Check condition for user access."""
78+
no_access_list = ["aws-s3-regions"]
79+
no_auth = any(no_auth_path in request.path for no_auth_path in no_access_list)
80+
return no_auth
81+
82+
7683
class HttpResponseUnauthorizedRequest(HttpResponse):
7784
"""A subclass of HttpResponse to return a 401.
7885
Used if identity header is not sent.
@@ -190,6 +197,8 @@ def _check_user_has_access(self, request):
190197
PermissionDenied: If the user does not have permissions for Cost Management.
191198
192199
"""
200+
if is_no_access(request):
201+
return
193202
if not request.user.admin and not request.user.access:
194203
msg = f"User {request.user.username} does not have permissions for Cost Management."
195204
LOG.warning(msg)

0 commit comments

Comments
 (0)