oc-lib/models/workspace/workspace.go

36 lines
1.6 KiB
Go
Raw Normal View History

2024-07-25 09:28:55 +02:00
package workspace
import (
2024-12-03 11:57:51 +01:00
"fmt"
2024-12-03 10:57:28 +01:00
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area"
2024-07-26 10:36:23 +02:00
"cloud.o-forge.io/core/oc-lib/models/resources"
2024-07-25 09:28:55 +02:00
"cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/tools"
2024-07-25 09:28:55 +02:00
)
// Workspace is a struct that represents a workspace
2024-07-25 09:28:55 +02:00
type Workspace struct {
utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name)
2024-11-07 11:05:24 +01:00
resources.ResourceSet // ResourceSet contains the resources of the workspace (data, compute, processing, storage, workflow)
IsContextual bool `json:"is_contextual" bson:"is_contextual" default:"false"` // IsContextual is a flag that indicates if the workspace is contextual
Active bool `json:"active" bson:"active" default:"false"` // Active is a flag that indicates if the workspace is active
Shared string `json:"shared,omitempty" bson:"shared,omitempty"` // Shared is the ID of the shared workspace
2024-07-25 09:28:55 +02:00
}
2024-11-28 11:05:54 +01:00
func (d *Workspace) GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
2024-11-28 13:19:01 +01:00
return New(tools.WORKSPACE, peerID, groups, caller) // Create a new instance of the accessor
2024-07-25 09:28:55 +02:00
}
2024-12-03 10:57:28 +01:00
func (ao *Workspace) VerifyAuth(peerID string, groups []string) bool {
2024-12-03 11:57:51 +01:00
fmt.Println("Workspace.VerifyAuth", ao.Shared)
2024-12-03 10:57:28 +01:00
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)
}
2024-12-03 12:51:41 +01:00
return true
2024-12-03 10:57:28 +01:00
}