frostfs-s3-gw/internal/frostfs/policy/storage.go
Denis Kirillov 9272f4e108 [#259] Support contract based policies
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
2023-12-11 10:01:46 +03:00

42 lines
1.1 KiB
Go

package policy
import (
"git.frostfs.info/TrueCloudLab/policy-engine/pkg/chain"
"git.frostfs.info/TrueCloudLab/policy-engine/pkg/engine"
"git.frostfs.info/TrueCloudLab/policy-engine/pkg/engine/inmemory"
"git.frostfs.info/TrueCloudLab/policy-engine/pkg/resource"
)
const S3ChainName chain.Name = "s3"
type Storage struct {
router engine.ChainRouter
morph engine.MorphRuleChainStorage
local engine.LocalOverrideStorage
}
var _ engine.LocalOverrideEngine = (*Storage)(nil)
func NewStorage(morph engine.MorphRuleChainStorage) *Storage {
local := inmemory.NewInmemoryLocalStorage()
return &Storage{
router: engine.NewDefaultChainRouterWithLocalOverrides(morph, local),
morph: morph,
local: local,
}
}
func (s Storage) IsAllowed(name chain.Name, target engine.RequestTarget, r resource.Request) (status chain.Status, found bool, err error) {
return s.router.IsAllowed(name, target, r)
}
func (s Storage) MorphRuleChainStorage() engine.MorphRuleChainStorage {
return s.morph
}
func (s Storage) LocalStorage() engine.LocalOverrideStorage {
return s.local
}