blob: 8f7d9d9effcf06ce1660b5070b5d235842f479bc [file] [log] [blame]
Matthias Andreas Benkard832a54e2019-01-29 09:27:38 +01001/*
2Copyright 2017 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package authorizer
18
19type ResourceRuleInfo interface {
20 // GetVerbs returns a list of kubernetes resource API verbs.
21 GetVerbs() []string
22 // GetAPIGroups return the names of the APIGroup that contains the resources.
23 GetAPIGroups() []string
24 // GetResources return a list of resources the rule applies to.
25 GetResources() []string
26 // GetResourceNames return a white list of names that the rule applies to.
27 GetResourceNames() []string
28}
29
30// DefaultResourceRuleInfo holds information that describes a rule for the resource
31type DefaultResourceRuleInfo struct {
32 Verbs []string
33 APIGroups []string
34 Resources []string
35 ResourceNames []string
36}
37
38func (i *DefaultResourceRuleInfo) GetVerbs() []string {
39 return i.Verbs
40}
41
42func (i *DefaultResourceRuleInfo) GetAPIGroups() []string {
43 return i.APIGroups
44}
45
46func (i *DefaultResourceRuleInfo) GetResources() []string {
47 return i.Resources
48}
49
50func (i *DefaultResourceRuleInfo) GetResourceNames() []string {
51 return i.ResourceNames
52}
53
54type NonResourceRuleInfo interface {
55 // GetVerbs returns a list of kubernetes resource API verbs.
56 GetVerbs() []string
57 // GetNonResourceURLs return a set of partial urls that a user should have access to.
58 GetNonResourceURLs() []string
59}
60
61// DefaultNonResourceRuleInfo holds information that describes a rule for the non-resource
62type DefaultNonResourceRuleInfo struct {
63 Verbs []string
64 NonResourceURLs []string
65}
66
67func (i *DefaultNonResourceRuleInfo) GetVerbs() []string {
68 return i.Verbs
69}
70
71func (i *DefaultNonResourceRuleInfo) GetNonResourceURLs() []string {
72 return i.NonResourceURLs
73}