add username to our trip
This commit is contained in:
@@ -98,15 +98,15 @@ type Workflow struct {
|
||||
AbstractWorkflow // AbstractWorkflow contains the basic fields of a workflow
|
||||
}
|
||||
|
||||
func (ao *Workflow) VerifyAuth(peerID string, groups []string) bool {
|
||||
func (ao *Workflow) VerifyAuth(username string, peerID string, groups []string) bool {
|
||||
isAuthorized := false
|
||||
if len(ao.Shared) > 0 {
|
||||
for _, shared := range ao.Shared {
|
||||
shared, code, _ := shallow_collaborative_area.New(tools.COLLABORATIVE_AREA, peerID, groups, nil).LoadOne(shared)
|
||||
shared, code, _ := shallow_collaborative_area.New(tools.COLLABORATIVE_AREA, username, peerID, groups, nil).LoadOne(shared)
|
||||
if code != 200 || shared == nil {
|
||||
isAuthorized = false
|
||||
}
|
||||
isAuthorized = shared.VerifyAuth(peerID, groups)
|
||||
isAuthorized = shared.VerifyAuth(username, peerID, groups)
|
||||
}
|
||||
} else {
|
||||
isAuthorized = true
|
||||
@@ -122,7 +122,7 @@ func (wfa *Workflow) CheckBooking(caller *tools.HTTPCaller) (bool, error) {
|
||||
if wfa.Graph == nil { // no graph no booking
|
||||
return false, nil
|
||||
}
|
||||
accessor := (&resources.ComputeResource{}).GetAccessor("", []string{}, caller)
|
||||
accessor := (&resources.ComputeResource{}).GetAccessor("", "", []string{}, caller)
|
||||
for _, link := range wfa.Graph.Links {
|
||||
if ok, dc_id := wfa.isDCLink(link); ok { // check if the link is a link between a compute and a resource
|
||||
dc, code, _ := accessor.LoadOne(dc_id)
|
||||
@@ -143,6 +143,6 @@ func (wfa *Workflow) CheckBooking(caller *tools.HTTPCaller) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (d *Workflow) GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
|
||||
return New(tools.WORKFLOW, peerID, groups, caller) // Create a new instance of the accessor
|
||||
func (d *Workflow) GetAccessor(username string, peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
|
||||
return New(tools.WORKFLOW, username, peerID, groups, caller) // Create a new instance of the accessor
|
||||
}
|
||||
|
@@ -8,8 +8,8 @@ import (
|
||||
|
||||
type WorkflowHistory struct{ Workflow }
|
||||
|
||||
func (d *WorkflowHistory) GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
|
||||
return New(tools.WORKSPACE_HISTORY, peerID, groups, caller) // Create a new instance of the accessor
|
||||
func (d *WorkflowHistory) GetAccessor(username string, peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
|
||||
return New(tools.WORKSPACE_HISTORY, username, peerID, groups, caller) // Create a new instance of the accessor
|
||||
}
|
||||
func (r *WorkflowHistory) GenerateID() {
|
||||
r.UUID = uuid.New().String()
|
||||
|
@@ -30,16 +30,17 @@ type workflowMongoAccessor struct {
|
||||
}
|
||||
|
||||
// New creates a new instance of the workflowMongoAccessor
|
||||
func New(t tools.DataType, peerID string, groups []string, caller *tools.HTTPCaller) *workflowMongoAccessor {
|
||||
func New(t tools.DataType, username string, peerID string, groups []string, caller *tools.HTTPCaller) *workflowMongoAccessor {
|
||||
return &workflowMongoAccessor{
|
||||
computeResourceAccessor: (&resources.ComputeResource{}).GetAccessor(peerID, groups, nil),
|
||||
collaborativeAreaAccessor: (&shallow_collaborative_area.ShallowCollaborativeArea{}).GetAccessor(peerID, groups, nil),
|
||||
executionAccessor: (&workflow_execution.WorkflowExecution{}).GetAccessor(peerID, groups, nil),
|
||||
workspaceAccessor: (&workspace.Workspace{}).GetAccessor(peerID, groups, nil),
|
||||
computeResourceAccessor: (&resources.ComputeResource{}).GetAccessor(username, peerID, groups, nil),
|
||||
collaborativeAreaAccessor: (&shallow_collaborative_area.ShallowCollaborativeArea{}).GetAccessor(username, peerID, groups, nil),
|
||||
executionAccessor: (&workflow_execution.WorkflowExecution{}).GetAccessor(username, peerID, groups, nil),
|
||||
workspaceAccessor: (&workspace.Workspace{}).GetAccessor(username, peerID, groups, nil),
|
||||
AbstractAccessor: utils.AbstractAccessor{
|
||||
Logger: logs.CreateLogger(t.String()), // Create a logger with the data type
|
||||
Caller: caller,
|
||||
PeerID: peerID,
|
||||
User: username,
|
||||
Groups: groups, // Set the caller
|
||||
Type: t,
|
||||
},
|
||||
|
@@ -13,7 +13,7 @@ func TestStoreOneWorkflow(t *testing.T) {
|
||||
AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
|
||||
}
|
||||
|
||||
wma := New(tools.WORKFLOW, "", nil, nil)
|
||||
wma := New(tools.WORKFLOW, "", "", nil, nil)
|
||||
id, _, _ := wma.StoreOne(&w)
|
||||
|
||||
assert.NotEmpty(t, id)
|
||||
@@ -24,7 +24,7 @@ func TestLoadOneWorkflow(t *testing.T) {
|
||||
AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
|
||||
}
|
||||
|
||||
wma := New(tools.WORKFLOW, "", nil, nil)
|
||||
wma := New(tools.WORKFLOW, "", "", nil, nil)
|
||||
new_w, _, _ := wma.StoreOne(&w)
|
||||
assert.Equal(t, w, new_w)
|
||||
}
|
||||
|
Reference in New Issue
Block a user