-
Notifications
You must be signed in to change notification settings - Fork 14
/
scope_authz.go
61 lines (55 loc) · 1.29 KB
/
scope_authz.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
package getstream
// ScopeAction defines the Actions allowed by a scope token
type ScopeAction uint32
const (
// ScopeActionRead : GET, OPTIONS, HEAD
ScopeActionRead ScopeAction = 1
// ScopeActionWrite : POST, PUT, PATCH
ScopeActionWrite ScopeAction = 2
// ScopeActionDelete : DELETE
ScopeActionDelete ScopeAction = 4
// ScopeActionAll : The JWT has permission to all HTTP verbs
ScopeActionAll ScopeAction = 8
)
// Value returns a string representation
func (a ScopeAction) Value() string {
switch a {
case 1:
return "read"
case 2:
return "write"
case 4:
return "delete"
case 8:
return "*"
default:
return ""
}
}
// ScopeContext defines the resources accessible by a scope token
type ScopeContext uint32
const (
// ScopeContextActivities : Activities Endpoint
ScopeContextActivities ScopeContext = 1
// ScopeContextFeed : Feed Endpoint
ScopeContextFeed ScopeContext = 2
// ScopeContextFollower : Following + Followers Endpoint
ScopeContextFollower ScopeContext = 4
// ScopeContextAll : Allow access to any resource
ScopeContextAll ScopeContext = 8
)
// Value returns a string representation
func (a ScopeContext) Value() string {
switch a {
case 1:
return "activities"
case 2:
return "feed"
case 4:
return "follower"
case 8:
return "*"
default:
return ""
}
}