@@ -119,6 +119,9 @@ def get(self):
119119 )
120120 args = parser .parse_args ()
121121
122+ # 权限校验:列表接口需要 read 权限
123+ self .check_can_read ()
124+
122125 client = AppService ()
123126 pagination = client .get_paginate_apps (current_user , args )
124127 response = marshal (pagination , fields .app_pagination_fields )
@@ -214,6 +217,8 @@ def post(self):
214217 "enable_api" , type = inputs .boolean , location = "json" , required = False
215218 )
216219 args = parser .parse_args ()
220+
221+ self .check_can_read ()
217222 client = AppService ()
218223 pagination = client .get_paginate_apps (current_user , args )
219224 response = marshal (pagination , fields .app_pagination_fields )
@@ -244,6 +249,9 @@ def get(self, app_id):
244249 """
245250 # 如果是通过子画布的接口来访问,会拿不到app_model
246251 app_model = AppService ().get_app (app_id , raise_error = False )
252+ if app_model :
253+ self .check_can_read_object (app_model )
254+
247255 return marshal (app_model , fields .app_detail_fields )
248256
249257 @login_required
@@ -490,6 +498,9 @@ def get(self, app_id):
490498 args = parser .parse_args ()
491499
492500 app_model = AppService ().get_app (app_id , raise_error = False )
501+ if app_model :
502+ self .check_can_write_object (app_model )
503+
493504 result = marshal (app_model , fields .app_export_fields )
494505 workflow = Workflow .default_getone (app_id , args ["version" ])
495506 result ["graph" ] = workflow .nested_graph_dict if workflow else {}
@@ -573,6 +584,10 @@ def post(self, app_id):
573584 parser = reqparse .RequestParser ()
574585 parser .add_argument ("file" , type = FileStorage , required = True , location = "files" )
575586 uploaded_file = parser .parse_args ()["file" ]
587+
588+ app_model = AppService ().get_app (app_id , raise_error = False )
589+ if app_model :
590+ self .check_can_write_object (app_model )
576591
577592 rawdata = json .loads (uploaded_file .read ())
578593
@@ -622,6 +637,7 @@ def get(self):
622637 ) # mine/group/builtin/already
623638 args = parser .parse_args ()
624639
640+ self .check_can_read ()
625641 client = TemplateService ()
626642 app_pagination = client .get_paginate_apps (current_user , args )
627643 if not app_pagination :
@@ -644,6 +660,7 @@ def get(self, app_id):
644660 ValueError: 当模板不存在时抛出
645661 """
646662 template = TemplateService ().get_app (app_id )
663+ self .check_can_read_object (template )
647664 return marshal (template , fields .app_detail_fields )
648665
649666 @login_required
@@ -729,6 +746,9 @@ def post(self):
729746
730747 client = TemplateService ()
731748 template = client .get_app (args ["id" ])
749+ if template :
750+ self .check_can_read_object (template )
751+
732752 app = client .convert_to_app (current_user , template , args )
733753 LogService ().add (Module .APP_STORE , Action .CREATE_APP_TMP , name = app .name )
734754 return app , 201
@@ -1176,7 +1196,11 @@ def get(self, app_id):
11761196
11771197
11781198class CheckVersionsCount (Resource ):
1199+ @login_required
11791200 def get (self , app_id ):
1201+ app_model = AppService ().get_app (app_id , raise_error = False )
1202+ if app_model :
1203+ self .check_can_write_object (app_model )
11801204 version_count = AppService ().get_version_count (app_id )
11811205 message = ""
11821206 is_over_limit = False
0 commit comments