@@ -24,6 +24,7 @@ import (
24
24
25
25
rbacv1 "k8s.io/api/rbac/v1"
26
26
"k8s.io/apimachinery/pkg/runtime/schema"
27
+ "k8s.io/apiserver/pkg/authentication/user"
27
28
"k8s.io/apiserver/pkg/authorization/authorizer"
28
29
utilfeature "k8s.io/apiserver/pkg/util/feature"
29
30
"k8s.io/component-base/featuregate"
@@ -58,8 +59,11 @@ type NodeAuthorizer struct {
58
59
features featuregate.FeatureGate
59
60
}
60
61
62
+ var _ = authorizer .Authorizer (& NodeAuthorizer {})
63
+ var _ = authorizer .RuleResolver (& NodeAuthorizer {})
64
+
61
65
// NewAuthorizer returns a new node authorizer
62
- func NewAuthorizer (graph * Graph , identifier nodeidentifier.NodeIdentifier , rules []rbacv1.PolicyRule ) authorizer. Authorizer {
66
+ func NewAuthorizer (graph * Graph , identifier nodeidentifier.NodeIdentifier , rules []rbacv1.PolicyRule ) * NodeAuthorizer {
63
67
return & NodeAuthorizer {
64
68
graph : graph ,
65
69
identifier : identifier ,
79
83
csiNodeResource = storageapi .Resource ("csinodes" )
80
84
)
81
85
86
+ func (r * NodeAuthorizer ) RulesFor (user user.Info , namespace string ) ([]authorizer.ResourceRuleInfo , []authorizer.NonResourceRuleInfo , bool , error ) {
87
+ if _ , isNode := r .identifier .NodeIdentity (user ); isNode {
88
+ // indicate nodes do not have fully enumerated permissions
89
+ return nil , nil , true , fmt .Errorf ("node authorizer does not support user rule resolution" )
90
+ }
91
+ return nil , nil , false , nil
92
+ }
93
+
82
94
func (r * NodeAuthorizer ) Authorize (ctx context.Context , attrs authorizer.Attributes ) (authorizer.Decision , string , error ) {
83
95
nodeName , isNode := r .identifier .NodeIdentity (attrs .GetUser ())
84
96
if ! isNode {
0 commit comments