-
Notifications
You must be signed in to change notification settings - Fork 347
/
authz_basic_impl.go
65 lines (53 loc) · 1.78 KB
/
authz_basic_impl.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package templates
import (
"context"
"github.com/determined-ai/determined/master/internal/db"
"github.com/determined-ai/determined/master/pkg/model"
)
// TemplateAuthZBasic is basic OSS controls.
type TemplateAuthZBasic struct{}
// ViewableScopes implements the TemplateAuthZ interface.
func (a *TemplateAuthZBasic) ViewableScopes(
ctx context.Context, curUser *model.User, requestedScope model.AccessScopeID,
) (model.AccessScopeSet, error) {
var ids []int
returnScope := model.AccessScopeSet{requestedScope: true}
if requestedScope == 0 {
err := db.Bun().NewSelect().Table("workspaces").Column("id").Scan(ctx, &ids)
if err != nil {
return nil, err
}
for _, id := range ids {
returnScope[model.AccessScopeID(id)] = true
}
return returnScope, nil
}
return returnScope, nil
}
// CanCreateTemplate implements the TemplateAuthZ interface.
func (a *TemplateAuthZBasic) CanCreateTemplate(
ctx context.Context, curUser *model.User, workspaceID model.AccessScopeID,
) (permErr error, err error) {
return nil, nil
}
// CanViewTemplate implements the TemplateAuthZ interface.
func (a *TemplateAuthZBasic) CanViewTemplate(
ctx context.Context, curUser *model.User, workspaceID model.AccessScopeID,
) (permErr error, err error) {
return nil, nil
}
// CanUpdateTemplate implements the TemplateAuthZ interface.
func (a *TemplateAuthZBasic) CanUpdateTemplate(
ctx context.Context, curUser *model.User, workspaceID model.AccessScopeID,
) (permErr error, err error) {
return nil, nil
}
// CanDeleteTemplate implements the TemplateAuthZ interface.
func (a *TemplateAuthZBasic) CanDeleteTemplate(
ctx context.Context, curUser *model.User, workspaceID model.AccessScopeID,
) (permErr error, err error) {
return nil, nil
}
func init() {
AuthZProvider.Register("basic", &TemplateAuthZBasic{})
}