MCPcopy Create free account
hub / github.com/actiontech/dtle / checkJobAccess

Function checkJobAccess

api/handler/v2/job.go:2072–2092  ·  view source on GitHub ↗
(c echo.Context, jobId string)

Source from the content-addressed store, hash-verified

2070}
2071
2072func checkJobAccess(c echo.Context, jobId string) error {
2073 logger := handler.NewLogger().Named("checkJobAccess")
2074 logger.Info("start checkJobAccess")
2075 user, err := getCurrentUser(c)
2076 if err != nil {
2077 return fmt.Errorf("consul_addr=%v; connect to consul failed: %v", handler.ConsulAddr, err)
2078 }
2079 storeManager, err := common.NewStoreManager([]string{handler.ConsulAddr}, logger)
2080 if err != nil {
2081 return fmt.Errorf("consul_addr=%v; connect to consul failed: %v", handler.ConsulAddr, err)
2082 }
2083 job, err := storeManager.GetJobInfo(jobId)
2084 if nil != err {
2085 return fmt.Errorf("consul_addr=%v ; get job status list failed: %v", handler.ConsulAddr, err)
2086 }
2087
2088 if !userHasAccess(storeManager, job.User, user) {
2089 return fmt.Errorf("current user %v:%v has not access to operate job job_id=%v", user.Tenant, user.Username, jobId)
2090 }
2091 return nil
2092}
2093
2094func checkUpdateJobInfo(c echo.Context, jobId string, create bool) error {
2095 logger := handler.NewLogger().Named("checkUpdateJobInfo")

Callers 9

GetJobDetailFunction · 0.85
PauseJobV2Function · 0.85
ResumeJobV2Function · 0.85
DeleteJobV2Function · 0.85
GetJobPositionV2Function · 0.85
ReverseStartJobV2Function · 0.85
ReverseJobV2Function · 0.85
checkUpdateJobInfoFunction · 0.85

Calls 5

GetJobInfoMethod · 0.95
NewLoggerFunction · 0.92
NewStoreManagerFunction · 0.92
getCurrentUserFunction · 0.85
userHasAccessFunction · 0.85

Tested by

no test coverage detected