ParseScope parses a scope string into resource and action
(scope string)
| 66 | |
| 67 | // ParseScope parses a scope string into resource and action |
| 68 | func ParseScope(scope string) (Resource, Action) { |
| 69 | parts := strings.Split(scope, ":") |
| 70 | if len(parts) != 2 { |
| 71 | return "", "" |
| 72 | } |
| 73 | return Resource(parts[0]), Action(parts[1]) |
| 74 | } |
| 75 | |
| 76 | // HasPermission checks if a set of scopes has permission for a given resource and HTTP method |
| 77 | func HasPermission(scopes []string, resource Resource, method string) bool { |