forked from TrueCloudLab/frostfs-node
* Introduce Request type converted from RequestInfo type to implement policy-engine's Request interface * Implement basic ape checker to check if a request is permitted to be performed * Make put handlers use APE checker instead EACL Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
34 lines
891 B
Go
34 lines
891 B
Go
package main
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
policyengine "git.frostfs.info/TrueCloudLab/policy-engine"
|
|
)
|
|
|
|
type apeChainSourceImpl struct {
|
|
mtx sync.Mutex
|
|
localChainStorage map[cid.ID]policyengine.CachedChainStorage
|
|
}
|
|
|
|
func NewAPESource() container.AccessPolicyEngineChainSource {
|
|
return &apeChainSourceImpl{
|
|
localChainStorage: make(map[cid.ID]policyengine.CachedChainStorage),
|
|
}
|
|
}
|
|
|
|
var _ container.AccessPolicyEngineChainSource = (*apeChainSourceImpl)(nil)
|
|
|
|
func (c *apeChainSourceImpl) GetChainSource(cid cid.ID) (policyengine.CachedChainStorage, error) {
|
|
c.mtx.Lock()
|
|
defer c.mtx.Unlock()
|
|
|
|
s, ok := c.localChainStorage[cid]
|
|
if ok {
|
|
return s, nil
|
|
}
|
|
c.localChainStorage[cid] = policyengine.NewInMemory()
|
|
return c.localChainStorage[cid], nil
|
|
}
|