1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

acl service permissions method

This commit is contained in:
Sergey Cherepanov 2024-02-29 09:49:17 +01:00
parent 92d3ba6237
commit 287b8303b2
No known key found for this signature in database
GPG key ID: 87F8EDE8FBDF637C

View file

@ -14,6 +14,7 @@ import (
"github.com/anyproto/any-sync/consensus/consensusclient"
"github.com/anyproto/any-sync/consensus/consensusproto"
"github.com/anyproto/any-sync/metric"
"github.com/anyproto/any-sync/util/crypto"
)
const CName = "coordinator.acl"
@ -47,7 +48,7 @@ func (as *aclService) Init(a *app.App) (err error) {
as.cache = ocache.New(as.loadObject,
ocache.WithTTL(5*time.Minute),
ocache.WithLogger(log.Sugar()),
ocache.WithPrometheus(metricReg, "coordinator", "acl"),
ocache.WithPrometheus(metricReg, "acl", ""),
)
return
}
@ -95,6 +96,16 @@ func (as *aclService) RecordsAfter(ctx context.Context, spaceId, aclHead string)
return acl.RecordsAfter(ctx, aclHead)
}
func (as *aclService) Permissions(ctx context.Context, identity crypto.PubKey, spaceId string) (res list.AclPermissions, err error) {
acl, err := as.get(ctx, spaceId)
if err != nil {
return
}
acl.RLock()
defer acl.RUnlock()
return acl.AclState().Permissions(identity), nil
}
func (as *aclService) Run(ctx context.Context) (err error) {
return
}