ValidAction checks if the action is valid for the given object type.
(action policy.Action)
| 63 | |
| 64 | // ValidAction checks if the action is valid for the given object type. |
| 65 | func (z Object) ValidAction(action policy.Action) error { |
| 66 | perms, ok := policy.RBACPermissions[z.Type] |
| 67 | if !ok { |
| 68 | return xerrors.Errorf("invalid type %q", z.Type) |
| 69 | } |
| 70 | if _, ok := perms.Actions[action]; !ok { |
| 71 | return xerrors.Errorf("invalid action %q for type %q", action, z.Type) |
| 72 | } |
| 73 | |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | // AvailableActions returns all available actions for a given object. |
| 78 | // Wildcard is omitted. |