-
Notifications
You must be signed in to change notification settings - Fork 4
/
policy.go
40 lines (32 loc) · 972 Bytes
/
policy.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
package wfs
// CombinedPolicy allows to join multiple policies together
type CombinedPolicy struct {
Policies []Policy
}
// Comply method returns true only when all joined policies are complied
func (p CombinedPolicy) Comply(path FileID, operation int) bool {
for _, el := range p.Policies {
if el.Comply(path, operation) == false {
return false
}
}
return true
}
// ReadOnlyPolicy allows read access and blocks any modifications
type ReadOnlyPolicy struct{}
// Comply method returns true for read operations
func (p ReadOnlyPolicy) Comply(path FileID, operation int) bool {
return operation == ReadOperation
}
// AllowPolicy allows all operations
type AllowPolicy struct{}
// Comply method returns true
func (p AllowPolicy) Comply(path FileID, operation int) bool {
return true
}
// DenyPolicy allows all operations
type DenyPolicy struct{}
// Comply method returns false
func (p DenyPolicy) Comply(path FileID, operation int) bool {
return false
}