...

Source file src/k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes/modes.go

Documentation: k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes

     1  /*
     2  Copyright 2017 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package modes
    18  
    19  import "k8s.io/apimachinery/pkg/util/sets"
    20  
    21  const (
    22  	// ModeAlwaysAllow is the mode to set all requests as authorized
    23  	ModeAlwaysAllow string = "AlwaysAllow"
    24  	// ModeAlwaysDeny is the mode to set no requests as authorized
    25  	ModeAlwaysDeny string = "AlwaysDeny"
    26  	// ModeABAC is the mode to use Attribute Based Access Control to authorize
    27  	ModeABAC string = "ABAC"
    28  	// ModeWebhook is the mode to make an external webhook call to authorize
    29  	ModeWebhook string = "Webhook"
    30  	// ModeRBAC is the mode to use Role Based Access Control to authorize
    31  	ModeRBAC string = "RBAC"
    32  	// ModeNode is an authorization mode that authorizes API requests made by kubelets.
    33  	ModeNode string = "Node"
    34  )
    35  
    36  // AuthorizationModeChoices is the list of supported authorization modes
    37  var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABAC, ModeWebhook, ModeRBAC, ModeNode}
    38  
    39  // IsValidAuthorizationMode returns true if the given authorization mode is a valid one for the apiserver
    40  func IsValidAuthorizationMode(authzMode string) bool {
    41  	return sets.NewString(AuthorizationModeChoices...).Has(authzMode)
    42  }
    43  

View as plain text