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:
parent
92d3ba6237
commit
287b8303b2
1 changed files with 12 additions and 1 deletions
13
acl/acl.go
13
acl/acl.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue