debug
This commit is contained in:
parent
471e0c9d9b
commit
ea55c94c73
@ -212,12 +212,7 @@ func genericLoadAll[T DBObject](res *mgb.Cursor, code int, err error, f func(DBO
|
|||||||
if err = res.All(mongo.MngoCtx, &results); err != nil {
|
if err = res.All(mongo.MngoCtx, &results); err != nil {
|
||||||
return nil, 404, err
|
return nil, 404, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var test []map[string]interface{}
|
|
||||||
_ = res.All(mongo.MngoCtx, &test)
|
|
||||||
fmt.Println("results 1", res, results, test, err)
|
|
||||||
for _, r := range results {
|
for _, r := range results {
|
||||||
fmt.Println("results", r)
|
|
||||||
if !r.VerifyAuth(a.GetPeerID(), a.GetGroups()) {
|
if !r.VerifyAuth(a.GetPeerID(), a.GetGroups()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package workflow
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/peer"
|
"cloud.o-forge.io/core/oc-lib/models/peer"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
@ -97,6 +98,20 @@ type Workflow struct {
|
|||||||
AbstractWorkflow // AbstractWorkflow contains the basic fields of a workflow
|
AbstractWorkflow // AbstractWorkflow contains the basic fields of a workflow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ao *Workflow) VerifyAuth(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)
|
||||||
|
if code != 200 || shared == nil {
|
||||||
|
isAuthorized = false
|
||||||
|
}
|
||||||
|
isAuthorized = shared.VerifyAuth(peerID, groups)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isAuthorized
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CheckBooking is a function that checks the booking of the workflow on peers (even ourselves)
|
* CheckBooking is a function that checks the booking of the workflow on peers (even ourselves)
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package workspace
|
package workspace
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
"cloud.o-forge.io/core/oc-lib/tools"
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
@ -18,3 +19,14 @@ type Workspace struct {
|
|||||||
func (d *Workspace) GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
|
func (d *Workspace) GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
|
||||||
return New(tools.WORKSPACE, peerID, groups, caller) // Create a new instance of the accessor
|
return New(tools.WORKSPACE, peerID, groups, caller) // Create a new instance of the accessor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ao *Workspace) VerifyAuth(peerID string, groups []string) bool {
|
||||||
|
if ao.Shared != "" {
|
||||||
|
shared, code, _ := shallow_collaborative_area.New(tools.COLLABORATIVE_AREA, peerID, groups, nil).LoadOne(ao.Shared)
|
||||||
|
if code != 200 || shared == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return shared.VerifyAuth(peerID, groups)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user