modes.go 1.6 KB

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