@@ -195,29 +195,34 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
195
195
}
196
196
return
197
197
}
198
- //RBAC
198
+
199
199
token := r .Header .Get ("token" )
200
- if executionDetail .AppId > 0 && executionDetail .EnvId > 0 {
201
- object := impl .enforcerUtil .GetAppRBACNameByAppId (appId )
202
- if ok := impl .enforcer .Enforce (token , casbin .ResourceApplications , casbin .ActionGet , object ); ! ok {
203
- common .WriteJsonResp (w , fmt .Errorf ("unauthorized user" ), "Unauthorized User" , http .StatusForbidden )
204
- return
205
- }
206
- object = impl .enforcerUtil .GetEnvRBACNameByAppId (appId , envId )
207
- if ok := impl .enforcer .Enforce (token , casbin .ResourceEnvironment , casbin .ActionGet , object ); ! ok {
208
- common .WriteJsonResp (w , fmt .Errorf ("unauthorized user" ), "Unauthorized User" , http .StatusForbidden )
209
- return
210
- }
211
- } else if executionDetail .AppId > 0 {
212
- object := impl .enforcerUtil .GetAppRBACNameByAppId (appId )
213
- if ok := impl .enforcer .Enforce (token , casbin .ResourceApplications , casbin .ActionGet , object ); ! ok {
200
+ if executionDetail != nil {
201
+ //RBAC
202
+ if executionDetail .AppId > 0 && executionDetail .EnvId > 0 {
203
+ object := impl .enforcerUtil .GetAppRBACNameByAppId (appId )
204
+ if ok := impl .enforcer .Enforce (token , casbin .ResourceApplications , casbin .ActionGet , object ); ! ok {
205
+ common .WriteJsonResp (w , fmt .Errorf ("unauthorized user" ), "Unauthorized User" , http .StatusForbidden )
206
+ return
207
+ }
208
+ object = impl .enforcerUtil .GetEnvRBACNameByAppId (appId , envId )
209
+ if ok := impl .enforcer .Enforce (token , casbin .ResourceEnvironment , casbin .ActionGet , object ); ! ok {
210
+ common .WriteJsonResp (w , fmt .Errorf ("unauthorized user" ), "Unauthorized User" , http .StatusForbidden )
211
+ return
212
+ }
213
+ } else if executionDetail .AppId > 0 {
214
+ object := impl .enforcerUtil .GetAppRBACNameByAppId (appId )
215
+ if ok := impl .enforcer .Enforce (token , casbin .ResourceApplications , casbin .ActionGet , object ); ! ok {
216
+ common .WriteJsonResp (w , fmt .Errorf ("unauthorized user" ), "Unauthorized User" , http .StatusForbidden )
217
+ return
218
+ }
219
+ } else {
214
220
common .WriteJsonResp (w , fmt .Errorf ("unauthorized user" ), "Unauthorized User" , http .StatusForbidden )
215
- return
216
221
}
222
+ //RBAC
217
223
} else {
218
- common .WriteJsonResp (w , fmt . Errorf ( "unauthorized user" ), "Unauthorized User" , http .StatusForbidden )
224
+ common .WriteJsonResp (w , err , & security. ImageScanExecutionDetail {} , http .StatusOK )
219
225
}
220
- //RBAC
221
226
222
227
common .WriteJsonResp (w , err , executionDetail , http .StatusOK )
223
228
}
0 commit comments