23 lines
367 B
Go
23 lines
367 B
Go
package common
|
|
|
|
type Perm string
|
|
|
|
const (
|
|
PermRead Perm = "read"
|
|
PermWrite Perm = "write"
|
|
PermAdmin Perm = "admin"
|
|
)
|
|
|
|
// PermRank gives perm a hierarchy for implication checks: a grant of rank N
|
|
// satisfies a request of rank <= N.
|
|
func (perm Perm) PermRank() int {
|
|
switch perm {
|
|
case PermAdmin:
|
|
return 3
|
|
case PermWrite:
|
|
return 2
|
|
default:
|
|
return 1
|
|
}
|
|
}
|