forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstatic_auth.go
41 lines (33 loc) · 1.2 KB
/
static_auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package store
import (
"context"
"github.com/grafana/grafana/pkg/infra/filestorage"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/user"
)
type createPathFilterByAction func(ctx context.Context, user *user.SignedInUser, storageName string) map[string]filestorage.PathFilter
func newStaticStorageAuthService(createPathFilterByAction createPathFilterByAction) storageAuthService {
return &staticStorageAuth{
denyAllFileGuardian: &denyAllFileGuardian{},
createPathFilterByAction: createPathFilterByAction,
log: log.New("staticStorageAuthService"),
}
}
type staticStorageAuth struct {
log log.Logger
denyAllFileGuardian fileGuardian
createPathFilterByAction createPathFilterByAction
}
func (a *staticStorageAuth) newGuardian(ctx context.Context, user *user.SignedInUser, storageName string) fileGuardian {
pathFilter := a.createPathFilterByAction(ctx, user, storageName)
if pathFilter == nil {
return a.denyAllFileGuardian
}
return &pathFilterFileGuardian{
ctx: ctx,
user: user,
log: a.log,
prefix: storageName,
pathFilterByAction: pathFilter,
}
}