Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: perm_insure checking missing late extend django apps #1490

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def has_object_permission(self, request, view, obj: Union[Application, Module]):
elif isinstance(obj, Module):
return user_has_app_action_perm(request.user, obj.application, action)
else:
logger.error("Application permission checked on incorrect object, type: %s", type(obj))
return False
raise TypeError(f"Permission check on incorrect type: {type(obj)}")

return AppModulePermission

Expand Down Expand Up @@ -101,8 +100,7 @@ def has_object_permission(self, request, view, obj: Union[Application, Module]):
elif isinstance(obj, Module):
return user_has_app_action_perm(request.user, obj.application, action)
else:
logger.error("Application permission checked on incorrect object, type: %s", type(obj))
return False
raise TypeError(f"Permission check on incorrect type: {type(obj)}")

return AppViewActionsPermission

Expand Down
7 changes: 5 additions & 2 deletions apiserver/paasng/paasng/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,17 @@
"paas_wl.infras.resources.generation",
# 蓝鲸通知中心
"bk_notice_sdk",
# This app helps us to make sure the permission was configured correctly
"paasng.infras.perm_insure",
]

# Allow extending installed apps
EXTRA_INSTALLED_APPS = settings.get("EXTRA_INSTALLED_APPS", [])
INSTALLED_APPS += EXTRA_INSTALLED_APPS

# The "perm_insure" module helps us to make sure that the permission is configured
# correctly, put it at the end of the list to make sure that all URL confs have been
# added to the root url before the perm checking starts.
INSTALLED_APPS.append("paasng.infras.perm_insure")

MIDDLEWARE = [
"django_prometheus.middleware.PrometheusBeforeMiddleware",
"paasng.infras.accounts.middlewares.RequestIDProvider", # 注入 RequestID
Expand Down