forwarded-auth
This commit is contained in:
@@ -52,14 +52,16 @@ func (o *WorkflowSchedulerController) Schedule() {
|
||||
})
|
||||
|
||||
logger.Info().Msg("Booking for " + wfId)
|
||||
req := oclib.NewRequest(collection, user, peerID, groups, caller)
|
||||
req := oclib.NewRequestAdmin(collection, caller)
|
||||
// req := oclib.NewRequest(collection, user, peerID, groups, caller)
|
||||
resp.UUID = uuid.New().String()
|
||||
|
||||
fmt.Println(user, peerID, groups)
|
||||
sch, _, execs, err := resp.Schedules(wfId, &tools.APIRequest{
|
||||
Username: user,
|
||||
PeerID: peerID,
|
||||
Groups: groups,
|
||||
Caller: caller,
|
||||
Admin: true,
|
||||
})
|
||||
if err != nil {
|
||||
if sch != nil {
|
||||
@@ -113,7 +115,7 @@ func (o *WorkflowSchedulerController) Schedule() {
|
||||
// @Success 200 {workspace} models.workspace
|
||||
// @router /:id [delete]
|
||||
func (o *WorkflowSchedulerController) UnSchedule() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
// user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
// TODO UNSCHEDULER
|
||||
filter := &dbs.Filters{
|
||||
@@ -121,7 +123,9 @@ func (o *WorkflowSchedulerController) UnSchedule() {
|
||||
"workflow_id": {{Operator: dbs.EQUAL.String(), Value: id}},
|
||||
},
|
||||
}
|
||||
o.Data["json"] = oclib.NewRequest(collection, user, peerID, groups, nil).Search(filter, "", true)
|
||||
o.Data["json"] = oclib.NewRequestAdmin(collection, nil).Search(filter, "", true)
|
||||
|
||||
// o.Data["json"] = oclib.NewRequest(collection, user, peerID, groups, nil).Search(filter, "", true)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
@@ -133,19 +137,22 @@ func (o *WorkflowSchedulerController) UnSchedule() {
|
||||
func (o *WorkflowSchedulerController) SearchScheduledDraftOrder() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
fmt.Println(user, peerID, groups)
|
||||
filter := &dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
"workflow_id": {{Operator: dbs.EQUAL.String(), Value: id}},
|
||||
"order_by": {{Operator: dbs.EQUAL.String(), Value: peerID}},
|
||||
},
|
||||
}
|
||||
o.Data["json"] = oclib.NewRequest(orderCollection, user, peerID, groups, nil).Search(filter, "", true)
|
||||
o.Data["json"] = oclib.NewRequestAdmin(orderCollection, nil).Search(filter, "", true)
|
||||
|
||||
//o.Data["json"] = oclib.NewRequest(orderCollection, user, peerID, groups, nil).Search(filter, "", true)
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
func createStorageServiceAccount(execId string, peerID string, wfId string, wfs *infrastructure.WorkflowSchedule, caller *tools.HTTPCaller, user string, groups []string) error {
|
||||
// Retrieve the Workflow in the WorkflowSchedule
|
||||
wf := loadWorkflow(wfId, peerID)
|
||||
wf := loadWorkflow(wfId)
|
||||
// storageItems := wf.GetGraphItems(wf.Graph.IsStorage)
|
||||
itemMap := wf.GetItemsByResources()
|
||||
// mapStorageRessources, err := getItemByRessourceId(wf, storageItems)
|
||||
@@ -185,7 +192,7 @@ func createStorageServiceAccount(execId string, peerID string, wfId string, wfs
|
||||
return err
|
||||
}
|
||||
// post on computing datacenter /minio/createSAsecret
|
||||
err = postS3Secret(peerID, *s, caller, execId, wfId, *c, access, secret) // create the secret holding the retrieved access on c's peer
|
||||
err = postS3Secret(*s, caller, execId, wfId, *c, access, secret) // create the secret holding the retrieved access on c's peer
|
||||
if err != nil {
|
||||
// Add a logger.Info() here
|
||||
return err
|
||||
@@ -204,10 +211,10 @@ func createStorageServiceAccount(execId string, peerID string, wfId string, wfs
|
||||
func postCreateServiceAccount(peerID string, s *resources.StorageResource, caller *tools.HTTPCaller, execId string, wfId string) error {
|
||||
l := oclib.GetLogger()
|
||||
fmt.Println("Creating a service account on " + peerID + " for " + s.Name)
|
||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.PEER), "", peerID, []string{}, nil).LoadOne(s.CreatorID)
|
||||
res := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.PEER), nil).LoadOne(s.CreatorID)
|
||||
if res.Code != 200 {
|
||||
l.Error().Msg("Error while loading a peer for creation of the serviceAccount")
|
||||
return fmt.Errorf(res.Err)
|
||||
return fmt.Errorf("%s", res.Err)
|
||||
}
|
||||
p := res.ToPeer()
|
||||
|
||||
@@ -226,15 +233,15 @@ func postCreateServiceAccount(peerID string, s *resources.StorageResource, calle
|
||||
l.Error().Msg(fmt.Sprint("Error when trying to create a serviceAccount on storage " + s.Name + " on peer at " + p.APIUrl))
|
||||
if _, ok := caller.LastResults["body"]; ok {
|
||||
l.Error().Msg(string(caller.LastResults["body"].([]byte)))
|
||||
return fmt.Errorf(string(caller.LastResults["body"].(map[string]interface{})["error"].([]byte)))
|
||||
return fmt.Errorf("%s", string(caller.LastResults["body"].(map[string]interface{})["error"].([]byte)))
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadWorkflow(workflowId string, peerId string) *workflow.Workflow {
|
||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW), "", peerId, []string{}, nil).LoadOne(workflowId)
|
||||
func loadWorkflow(workflowId string) *workflow.Workflow {
|
||||
res := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.WORKFLOW), nil).LoadOne(workflowId)
|
||||
if res.Code != 200 {
|
||||
l := oclib.GetLogger()
|
||||
l.Error().Msg("Error while loading a workflow for creation of the serviceAccount")
|
||||
@@ -302,10 +309,10 @@ func getComputeProcessing(wf workflow.Workflow, processingId string) (res string
|
||||
func getServiceAccountCredentials(peerID string, storageRes resources.StorageResource, caller *tools.HTTPCaller, execId string, wfId string, computeRes resources.ComputeResource) (string, string, error) {
|
||||
l := oclib.GetLogger()
|
||||
fmt.Println("Getting a service account for" + computeRes.CreatorID + " on S3 " + storageRes.Name + " on peer " + storageRes.CreatorID)
|
||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.PEER), "", peerID, []string{}, nil).LoadOne(storageRes.CreatorID)
|
||||
res := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.PEER), nil).LoadOne(storageRes.CreatorID)
|
||||
if res.Code != 200 {
|
||||
l.Error().Msg("Error while loading a peer for creation of the serviceAccount")
|
||||
return "", "", fmt.Errorf(res.Err)
|
||||
return "", "", fmt.Errorf("%s", res.Err)
|
||||
}
|
||||
p := res.ToPeer()
|
||||
|
||||
@@ -327,19 +334,19 @@ func getServiceAccountCredentials(peerID string, storageRes resources.StorageRes
|
||||
l.Error().Msg(fmt.Sprint("Error when trying to create a serviceAccount on storage " + storageRes.Name + " on peer at " + p.APIUrl))
|
||||
if _, ok := caller.LastResults["body"]; ok {
|
||||
l.Error().Msg(string(caller.LastResults["body"].([]byte)))
|
||||
return "", "", fmt.Errorf(string(caller.LastResults["body"].(map[string]interface{})["error"].([]byte)))
|
||||
return "", "", fmt.Errorf("%s", string(caller.LastResults["body"].(map[string]interface{})["error"].([]byte)))
|
||||
}
|
||||
}
|
||||
|
||||
var access, secret string
|
||||
if a, ok := resp["access"]; !ok {
|
||||
return "", "", fmt.Errorf("Error in the response returned when creating a S3 serviceAccount on " + storageRes.Name + " on peer " + p.UUID)
|
||||
return "", "", fmt.Errorf("%s", "Error in the response returned when creating a S3 serviceAccount on "+storageRes.Name+" on peer "+p.UUID)
|
||||
} else {
|
||||
access = a.(string)
|
||||
}
|
||||
|
||||
if s, ok := resp["secret"]; !ok {
|
||||
return "", "", fmt.Errorf("Error in the response returned when creating a S3 serviceAccount on " + storageRes.Name + " on peer " + p.UUID)
|
||||
return "", "", fmt.Errorf("%s", "Error in the response returned when creating a S3 serviceAccount on "+storageRes.Name+" on peer "+p.UUID)
|
||||
} else {
|
||||
secret = s.(string)
|
||||
}
|
||||
@@ -347,13 +354,13 @@ func getServiceAccountCredentials(peerID string, storageRes resources.StorageRes
|
||||
return access, secret, nil
|
||||
}
|
||||
|
||||
func postS3Secret(peerID string, s resources.StorageResource, caller *tools.HTTPCaller, execId string, wfId string, c resources.ComputeResource, access string, secret string) error {
|
||||
func postS3Secret(s resources.StorageResource, caller *tools.HTTPCaller, execId string, wfId string, c resources.ComputeResource, access string, secret string) error {
|
||||
l := oclib.GetLogger()
|
||||
|
||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.PEER), "", peerID, []string{}, nil).LoadOne(c.CreatorID)
|
||||
res := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.PEER), nil).LoadOne(c.CreatorID)
|
||||
if res.Code != 200 {
|
||||
l.Error().Msg("Error while loading a peer for creation of the serviceAccount")
|
||||
return fmt.Errorf(res.Err)
|
||||
return fmt.Errorf("%s", res.Err)
|
||||
}
|
||||
p := res.ToPeer()
|
||||
|
||||
@@ -366,7 +373,7 @@ func postS3Secret(peerID string, s resources.StorageResource, caller *tools.HTTP
|
||||
if err != nil {
|
||||
l.Error().Msg("Error when executing on peer at " + p.APIUrl + " when creating a secret holding s3 credentials in namespace " + execId)
|
||||
l.Error().Msg(err.Error())
|
||||
return fmt.Errorf("Error when executing on peer at " + p.APIUrl + " when creating a secret holding s3 credentials" + " : " + err.Error())
|
||||
return fmt.Errorf("%s", "Error when executing on peer at "+p.APIUrl+" when creating a secret holding s3 credentials"+" : "+err.Error())
|
||||
}
|
||||
|
||||
result_code := caller.LastResults["code"].(int)
|
||||
@@ -374,7 +381,7 @@ func postS3Secret(peerID string, s resources.StorageResource, caller *tools.HTTP
|
||||
l.Error().Msg(fmt.Sprint("Error when trying to post the credential to " + s.Name + "to a secret on peer at " + p.APIUrl))
|
||||
if _, ok := caller.LastResults["body"]; ok {
|
||||
l.Error().Msg(string(caller.LastResults["body"].([]byte)))
|
||||
return fmt.Errorf(string(caller.LastResults["body"].(map[string]interface{})["error"].([]byte)))
|
||||
return fmt.Errorf("%s", string(caller.LastResults["body"].(map[string]interface{})["error"].([]byte)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user