k8s.io/kubernetes@v1.29.3/pkg/apis/abac/v1beta1/types.go (about)

     1  /*
     2  Copyright 2015 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  // +k8s:openapi-gen=true
    18  
    19  package v1beta1
    20  
    21  import (
    22  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    23  )
    24  
    25  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    26  
    27  // Policy contains a single ABAC policy rule
    28  type Policy struct {
    29  	metav1.TypeMeta `json:",inline"`
    30  
    31  	// Spec describes the policy rule
    32  	Spec PolicySpec `json:"spec"`
    33  }
    34  
    35  // PolicySpec contains the attributes for a policy rule
    36  type PolicySpec struct {
    37  	// User is the username this rule applies to.
    38  	// Either user or group is required to match the request.
    39  	// "*" matches all users.
    40  	// +optional
    41  	User string `json:"user,omitempty"`
    42  
    43  	// Group is the group this rule applies to.
    44  	// Either user or group is required to match the request.
    45  	// "*" matches all groups.
    46  	// +optional
    47  	Group string `json:"group,omitempty"`
    48  
    49  	// Readonly matches readonly requests when true, and all requests when false
    50  	// +optional
    51  	Readonly bool `json:"readonly,omitempty"`
    52  
    53  	// APIGroup is the name of an API group. APIGroup, Resource, and Namespace are required to match resource requests.
    54  	// "*" matches all API groups
    55  	// +optional
    56  	APIGroup string `json:"apiGroup,omitempty"`
    57  
    58  	// Resource is the name of a resource. APIGroup, Resource, and Namespace are required to match resource requests.
    59  	// "*" matches all resources
    60  	// +optional
    61  	Resource string `json:"resource,omitempty"`
    62  
    63  	// Namespace is the name of a namespace. APIGroup, Resource, and Namespace are required to match resource requests.
    64  	// "*" matches all namespaces (including unnamespaced requests)
    65  	// +optional
    66  	Namespace string `json:"namespace,omitempty"`
    67  
    68  	// NonResourcePath matches non-resource request paths.
    69  	// "*" matches all paths
    70  	// "/foo/*" matches all subpaths of foo
    71  	// +optional
    72  	NonResourcePath string `json:"nonResourcePath,omitempty"`
    73  }