k8s.io/apiserver@v0.31.1/pkg/apis/apiserver/v1beta1/types.go (about)

     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 v1beta1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  	tracingapi "k8s.io/component-base/tracing/api/v1"
    22  )
    23  
    24  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    25  
    26  // EgressSelectorConfiguration provides versioned configuration for egress selector clients.
    27  type EgressSelectorConfiguration struct {
    28  	metav1.TypeMeta `json:",inline"`
    29  
    30  	// connectionServices contains a list of egress selection client configurations
    31  	EgressSelections []EgressSelection `json:"egressSelections"`
    32  }
    33  
    34  // EgressSelection provides the configuration for a single egress selection client.
    35  type EgressSelection struct {
    36  	// name is the name of the egress selection.
    37  	// Currently supported values are "controlplane", "master", "etcd" and "cluster"
    38  	// The "master" egress selector is deprecated in favor of "controlplane"
    39  	Name string `json:"name"`
    40  
    41  	// connection is the exact information used to configure the egress selection
    42  	Connection Connection `json:"connection"`
    43  }
    44  
    45  // Connection provides the configuration for a single egress selection client.
    46  type Connection struct {
    47  	// Protocol is the protocol used to connect from client to the konnectivity server.
    48  	ProxyProtocol ProtocolType `json:"proxyProtocol,omitempty"`
    49  
    50  	// Transport defines the transport configurations we use to dial to the konnectivity server.
    51  	// This is required if ProxyProtocol is HTTPConnect or GRPC.
    52  	// +optional
    53  	Transport *Transport `json:"transport,omitempty"`
    54  }
    55  
    56  // ProtocolType is a set of valid values for Connection.ProtocolType
    57  type ProtocolType string
    58  
    59  // Valid types for ProtocolType for konnectivity server
    60  const (
    61  	// Use HTTPConnect to connect to konnectivity server
    62  	ProtocolHTTPConnect ProtocolType = "HTTPConnect"
    63  	// Use grpc to connect to konnectivity server
    64  	ProtocolGRPC ProtocolType = "GRPC"
    65  	// Connect directly (skip konnectivity server)
    66  	ProtocolDirect ProtocolType = "Direct"
    67  )
    68  
    69  // Transport defines the transport configurations we use to dial to the konnectivity server
    70  type Transport struct {
    71  	// TCP is the TCP configuration for communicating with the konnectivity server via TCP
    72  	// ProxyProtocol of GRPC is not supported with TCP transport at the moment
    73  	// Requires at least one of TCP or UDS to be set
    74  	// +optional
    75  	TCP *TCPTransport `json:"tcp,omitempty"`
    76  
    77  	// UDS is the UDS configuration for communicating with the konnectivity server via UDS
    78  	// Requires at least one of TCP or UDS to be set
    79  	// +optional
    80  	UDS *UDSTransport `json:"uds,omitempty"`
    81  }
    82  
    83  // TCPTransport provides the information to connect to konnectivity server via TCP
    84  type TCPTransport struct {
    85  	// URL is the location of the konnectivity server to connect to.
    86  	// As an example it might be "https://127.0.0.1:8131"
    87  	URL string `json:"url,omitempty"`
    88  
    89  	// TLSConfig is the config needed to use TLS when connecting to konnectivity server
    90  	// +optional
    91  	TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
    92  }
    93  
    94  // UDSTransport provides the information to connect to konnectivity server via UDS
    95  type UDSTransport struct {
    96  	// UDSName is the name of the unix domain socket to connect to konnectivity server
    97  	// This does not use a unix:// prefix. (Eg: /etc/srv/kubernetes/konnectivity-server/konnectivity-server.socket)
    98  	UDSName string `json:"udsName,omitempty"`
    99  }
   100  
   101  // TLSConfig provides the authentication information to connect to konnectivity server
   102  // Only used with TCPTransport
   103  type TLSConfig struct {
   104  	// caBundle is the file location of the CA to be used to determine trust with the konnectivity server.
   105  	// Must be absent/empty if TCPTransport.URL is prefixed with http://
   106  	// If absent while TCPTransport.URL is prefixed with https://, default to system trust roots.
   107  	// +optional
   108  	CABundle string `json:"caBundle,omitempty"`
   109  
   110  	// clientKey is the file location of the client key to be used in mtls handshakes with the konnectivity server.
   111  	// Must be absent/empty if TCPTransport.URL is prefixed with http://
   112  	// Must be configured if TCPTransport.URL is prefixed with https://
   113  	// +optional
   114  	ClientKey string `json:"clientKey,omitempty"`
   115  
   116  	// clientCert is the file location of the client certificate to be used in mtls handshakes with the konnectivity server.
   117  	// Must be absent/empty if TCPTransport.URL is prefixed with http://
   118  	// Must be configured if TCPTransport.URL is prefixed with https://
   119  	// +optional
   120  	ClientCert string `json:"clientCert,omitempty"`
   121  }
   122  
   123  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   124  
   125  // TracingConfiguration provides versioned configuration for tracing clients.
   126  type TracingConfiguration struct {
   127  	metav1.TypeMeta `json:",inline"`
   128  
   129  	// Embed the component config tracing configuration struct
   130  	tracingapi.TracingConfiguration `json:",inline"`
   131  }
   132  
   133  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   134  
   135  // AuthenticationConfiguration provides versioned configuration for authentication.
   136  type AuthenticationConfiguration struct {
   137  	metav1.TypeMeta
   138  
   139  	// jwt is a list of authenticator to authenticate Kubernetes users using
   140  	// JWT compliant tokens. The authenticator will attempt to parse a raw ID token,
   141  	// verify it's been signed by the configured issuer. The public key to verify the
   142  	// signature is discovered from the issuer's public endpoint using OIDC discovery.
   143  	// For an incoming token, each JWT authenticator will be attempted in
   144  	// the order in which it is specified in this list.  Note however that
   145  	// other authenticators may run before or after the JWT authenticators.
   146  	// The specific position of JWT authenticators in relation to other
   147  	// authenticators is neither defined nor stable across releases.  Since
   148  	// each JWT authenticator must have a unique issuer URL, at most one
   149  	// JWT authenticator will attempt to cryptographically validate the token.
   150  	//
   151  	// The minimum valid JWT payload must contain the following claims:
   152  	// {
   153  	//		"iss": "https://issuer.example.com",
   154  	//		"aud": ["audience"],
   155  	//		"exp": 1234567890,
   156  	//		"<username claim>": "username"
   157  	// }
   158  	JWT []JWTAuthenticator `json:"jwt"`
   159  
   160  	// If present --anonymous-auth must not be set
   161  	Anonymous *AnonymousAuthConfig `json:"anonymous,omitempty"`
   162  }
   163  
   164  // AnonymousAuthConfig provides the configuration for the anonymous authenticator.
   165  type AnonymousAuthConfig struct {
   166  	Enabled bool `json:"enabled"`
   167  
   168  	// If set, anonymous auth is only allowed if the request meets one of the
   169  	// conditions.
   170  	Conditions []AnonymousAuthCondition `json:"conditions,omitempty"`
   171  }
   172  
   173  // AnonymousAuthCondition describes the condition under which anonymous auth
   174  // should be enabled.
   175  type AnonymousAuthCondition struct {
   176  	// Path for which anonymous auth is enabled.
   177  	Path string `json:"path"`
   178  }
   179  
   180  // JWTAuthenticator provides the configuration for a single JWT authenticator.
   181  type JWTAuthenticator struct {
   182  	// issuer contains the basic OIDC provider connection options.
   183  	// +required
   184  	Issuer Issuer `json:"issuer"`
   185  
   186  	// claimValidationRules are rules that are applied to validate token claims to authenticate users.
   187  	// +optional
   188  	ClaimValidationRules []ClaimValidationRule `json:"claimValidationRules,omitempty"`
   189  
   190  	// claimMappings points claims of a token to be treated as user attributes.
   191  	// +required
   192  	ClaimMappings ClaimMappings `json:"claimMappings"`
   193  
   194  	// userValidationRules are rules that are applied to final user before completing authentication.
   195  	// These allow invariants to be applied to incoming identities such as preventing the
   196  	// use of the system: prefix that is commonly used by Kubernetes components.
   197  	// The validation rules are logically ANDed together and must all return true for the validation to pass.
   198  	// +optional
   199  	UserValidationRules []UserValidationRule `json:"userValidationRules,omitempty"`
   200  }
   201  
   202  // Issuer provides the configuration for an external provider's specific settings.
   203  type Issuer struct {
   204  	// url points to the issuer URL in a format https://url or https://url/path.
   205  	// This must match the "iss" claim in the presented JWT, and the issuer returned from discovery.
   206  	// Same value as the --oidc-issuer-url flag.
   207  	// Discovery information is fetched from "{url}/.well-known/openid-configuration" unless overridden by discoveryURL.
   208  	// Required to be unique across all JWT authenticators.
   209  	// Note that egress selection configuration is not used for this network connection.
   210  	// +required
   211  	URL string `json:"url"`
   212  
   213  	// discoveryURL, if specified, overrides the URL used to fetch discovery
   214  	// information instead of using "{url}/.well-known/openid-configuration".
   215  	// The exact value specified is used, so "/.well-known/openid-configuration"
   216  	// must be included in discoveryURL if needed.
   217  	//
   218  	// The "issuer" field in the fetched discovery information must match the "issuer.url" field
   219  	// in the AuthenticationConfiguration and will be used to validate the "iss" claim in the presented JWT.
   220  	// This is for scenarios where the well-known and jwks endpoints are hosted at a different
   221  	// location than the issuer (such as locally in the cluster).
   222  	//
   223  	// Example:
   224  	// A discovery url that is exposed using kubernetes service 'oidc' in namespace 'oidc-namespace'
   225  	// and discovery information is available at '/.well-known/openid-configuration'.
   226  	// discoveryURL: "https://oidc.oidc-namespace/.well-known/openid-configuration"
   227  	// certificateAuthority is used to verify the TLS connection and the hostname on the leaf certificate
   228  	// must be set to 'oidc.oidc-namespace'.
   229  	//
   230  	// curl https://oidc.oidc-namespace/.well-known/openid-configuration (.discoveryURL field)
   231  	// {
   232  	//     issuer: "https://oidc.example.com" (.url field)
   233  	// }
   234  	//
   235  	// discoveryURL must be different from url.
   236  	// Required to be unique across all JWT authenticators.
   237  	// Note that egress selection configuration is not used for this network connection.
   238  	// +optional
   239  	DiscoveryURL *string `json:"discoveryURL,omitempty"`
   240  
   241  	// certificateAuthority contains PEM-encoded certificate authority certificates
   242  	// used to validate the connection when fetching discovery information.
   243  	// If unset, the system verifier is used.
   244  	// Same value as the content of the file referenced by the --oidc-ca-file flag.
   245  	// +optional
   246  	CertificateAuthority string `json:"certificateAuthority,omitempty"`
   247  
   248  	// audiences is the set of acceptable audiences the JWT must be issued to.
   249  	// At least one of the entries must match the "aud" claim in presented JWTs.
   250  	// Same value as the --oidc-client-id flag (though this field supports an array).
   251  	// Required to be non-empty.
   252  	// +required
   253  	Audiences []string `json:"audiences"`
   254  
   255  	// audienceMatchPolicy defines how the "audiences" field is used to match the "aud" claim in the presented JWT.
   256  	// Allowed values are:
   257  	// 1. "MatchAny" when multiple audiences are specified and
   258  	// 2. empty (or unset) or "MatchAny" when a single audience is specified.
   259  	//
   260  	// - MatchAny: the "aud" claim in the presented JWT must match at least one of the entries in the "audiences" field.
   261  	// For example, if "audiences" is ["foo", "bar"], the "aud" claim in the presented JWT must contain either "foo" or "bar" (and may contain both).
   262  	//
   263  	// - "": The match policy can be empty (or unset) when a single audience is specified in the "audiences" field. The "aud" claim in the presented JWT must contain the single audience (and may contain others).
   264  	//
   265  	// For more nuanced audience validation, use claimValidationRules.
   266  	//   example: claimValidationRule[].expression: 'sets.equivalent(claims.aud, ["bar", "foo", "baz"])' to require an exact match.
   267  	// +optional
   268  	AudienceMatchPolicy AudienceMatchPolicyType `json:"audienceMatchPolicy,omitempty"`
   269  }
   270  
   271  // AudienceMatchPolicyType is a set of valid values for issuer.audienceMatchPolicy
   272  type AudienceMatchPolicyType string
   273  
   274  // Valid types for AudienceMatchPolicyType
   275  const (
   276  	// MatchAny means the "aud" claim in the presented JWT must match at least one of the entries in the "audiences" field.
   277  	AudienceMatchPolicyMatchAny AudienceMatchPolicyType = "MatchAny"
   278  )
   279  
   280  // ClaimValidationRule provides the configuration for a single claim validation rule.
   281  type ClaimValidationRule struct {
   282  	// claim is the name of a required claim.
   283  	// Same as --oidc-required-claim flag.
   284  	// Only string claim keys are supported.
   285  	// Mutually exclusive with expression and message.
   286  	// +optional
   287  	Claim string `json:"claim,omitempty"`
   288  	// requiredValue is the value of a required claim.
   289  	// Same as --oidc-required-claim flag.
   290  	// Only string claim values are supported.
   291  	// If claim is set and requiredValue is not set, the claim must be present with a value set to the empty string.
   292  	// Mutually exclusive with expression and message.
   293  	// +optional
   294  	RequiredValue string `json:"requiredValue,omitempty"`
   295  
   296  	// expression represents the expression which will be evaluated by CEL.
   297  	// Must produce a boolean.
   298  	//
   299  	// CEL expressions have access to the contents of the token claims, organized into CEL variable:
   300  	// - 'claims' is a map of claim names to claim values.
   301  	//   For example, a variable named 'sub' can be accessed as 'claims.sub'.
   302  	//   Nested claims can be accessed using dot notation, e.g. 'claims.foo.bar'.
   303  	// Must return true for the validation to pass.
   304  	//
   305  	// Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
   306  	//
   307  	// Mutually exclusive with claim and requiredValue.
   308  	// +optional
   309  	Expression string `json:"expression,omitempty"`
   310  	// message customizes the returned error message when expression returns false.
   311  	// message is a literal string.
   312  	// Mutually exclusive with claim and requiredValue.
   313  	// +optional
   314  	Message string `json:"message,omitempty"`
   315  }
   316  
   317  // ClaimMappings provides the configuration for claim mapping
   318  type ClaimMappings struct {
   319  	// username represents an option for the username attribute.
   320  	// The claim's value must be a singular string.
   321  	// Same as the --oidc-username-claim and --oidc-username-prefix flags.
   322  	// If username.expression is set, the expression must produce a string value.
   323  	// If username.expression uses 'claims.email', then 'claims.email_verified' must be used in
   324  	// username.expression or extra[*].valueExpression or claimValidationRules[*].expression.
   325  	// An example claim validation rule expression that matches the validation automatically
   326  	// applied when username.claim is set to 'email' is 'claims.?email_verified.orValue(true)'.
   327  	//
   328  	// In the flag based approach, the --oidc-username-claim and --oidc-username-prefix are optional. If --oidc-username-claim is not set,
   329  	// the default value is "sub". For the authentication config, there is no defaulting for claim or prefix. The claim and prefix must be set explicitly.
   330  	// For claim, if --oidc-username-claim was not set with legacy flag approach, configure username.claim="sub" in the authentication config.
   331  	// For prefix:
   332  	//     (1) --oidc-username-prefix="-", no prefix was added to the username. For the same behavior using authentication config,
   333  	//         set username.prefix=""
   334  	//     (2) --oidc-username-prefix="" and  --oidc-username-claim != "email", prefix was "<value of --oidc-issuer-url>#". For the same
   335  	//         behavior using authentication config, set username.prefix="<value of issuer.url>#"
   336  	//     (3) --oidc-username-prefix="<value>". For the same behavior using authentication config, set username.prefix="<value>"
   337  	// +required
   338  	Username PrefixedClaimOrExpression `json:"username"`
   339  	// groups represents an option for the groups attribute.
   340  	// The claim's value must be a string or string array claim.
   341  	// If groups.claim is set, the prefix must be specified (and can be the empty string).
   342  	// If groups.expression is set, the expression must produce a string or string array value.
   343  	//  "", [], and null values are treated as the group mapping not being present.
   344  	// +optional
   345  	Groups PrefixedClaimOrExpression `json:"groups,omitempty"`
   346  
   347  	// uid represents an option for the uid attribute.
   348  	// Claim must be a singular string claim.
   349  	// If uid.expression is set, the expression must produce a string value.
   350  	// +optional
   351  	UID ClaimOrExpression `json:"uid"`
   352  
   353  	// extra represents an option for the extra attribute.
   354  	// expression must produce a string or string array value.
   355  	// If the value is empty, the extra mapping will not be present.
   356  	//
   357  	// hard-coded extra key/value
   358  	// - key: "foo"
   359  	//   valueExpression: "'bar'"
   360  	// This will result in an extra attribute - foo: ["bar"]
   361  	//
   362  	// hard-coded key, value copying claim value
   363  	// - key: "foo"
   364  	//   valueExpression: "claims.some_claim"
   365  	// This will result in an extra attribute - foo: [value of some_claim]
   366  	//
   367  	// hard-coded key, value derived from claim value
   368  	// - key: "admin"
   369  	//   valueExpression: '(has(claims.is_admin) && claims.is_admin) ? "true":""'
   370  	// This will result in:
   371  	//  - if is_admin claim is present and true, extra attribute - admin: ["true"]
   372  	//  - if is_admin claim is present and false or is_admin claim is not present, no extra attribute will be added
   373  	//
   374  	// +optional
   375  	Extra []ExtraMapping `json:"extra,omitempty"`
   376  }
   377  
   378  // PrefixedClaimOrExpression provides the configuration for a single prefixed claim or expression.
   379  type PrefixedClaimOrExpression struct {
   380  	// claim is the JWT claim to use.
   381  	// Mutually exclusive with expression.
   382  	// +optional
   383  	Claim string `json:"claim,omitempty"`
   384  	// prefix is prepended to claim's value to prevent clashes with existing names.
   385  	// prefix needs to be set if claim is set and can be the empty string.
   386  	// Mutually exclusive with expression.
   387  	// +optional
   388  	Prefix *string `json:"prefix,omitempty"`
   389  
   390  	// expression represents the expression which will be evaluated by CEL.
   391  	//
   392  	// CEL expressions have access to the contents of the token claims, organized into CEL variable:
   393  	// - 'claims' is a map of claim names to claim values.
   394  	//   For example, a variable named 'sub' can be accessed as 'claims.sub'.
   395  	//   Nested claims can be accessed using dot notation, e.g. 'claims.foo.bar'.
   396  	//
   397  	// Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
   398  	//
   399  	// Mutually exclusive with claim and prefix.
   400  	// +optional
   401  	Expression string `json:"expression,omitempty"`
   402  }
   403  
   404  // ClaimOrExpression provides the configuration for a single claim or expression.
   405  type ClaimOrExpression struct {
   406  	// claim is the JWT claim to use.
   407  	// Either claim or expression must be set.
   408  	// Mutually exclusive with expression.
   409  	// +optional
   410  	Claim string `json:"claim,omitempty"`
   411  
   412  	// expression represents the expression which will be evaluated by CEL.
   413  	//
   414  	// CEL expressions have access to the contents of the token claims, organized into CEL variable:
   415  	// - 'claims' is a map of claim names to claim values.
   416  	//   For example, a variable named 'sub' can be accessed as 'claims.sub'.
   417  	//   Nested claims can be accessed using dot notation, e.g. 'claims.foo.bar'.
   418  	//
   419  	// Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
   420  	//
   421  	// Mutually exclusive with claim.
   422  	// +optional
   423  	Expression string `json:"expression,omitempty"`
   424  }
   425  
   426  // ExtraMapping provides the configuration for a single extra mapping.
   427  type ExtraMapping struct {
   428  	// key is a string to use as the extra attribute key.
   429  	// key must be a domain-prefix path (e.g. example.org/foo). All characters before the first "/" must be a valid
   430  	// subdomain as defined by RFC 1123. All characters trailing the first "/" must
   431  	// be valid HTTP Path characters as defined by RFC 3986.
   432  	// key must be lowercase.
   433  	// Required to be unique.
   434  	// +required
   435  	Key string `json:"key"`
   436  
   437  	// valueExpression is a CEL expression to extract extra attribute value.
   438  	// valueExpression must produce a string or string array value.
   439  	// "", [], and null values are treated as the extra mapping not being present.
   440  	// Empty string values contained within a string array are filtered out.
   441  	//
   442  	// CEL expressions have access to the contents of the token claims, organized into CEL variable:
   443  	// - 'claims' is a map of claim names to claim values.
   444  	//   For example, a variable named 'sub' can be accessed as 'claims.sub'.
   445  	//   Nested claims can be accessed using dot notation, e.g. 'claims.foo.bar'.
   446  	//
   447  	// Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
   448  	//
   449  	// +required
   450  	ValueExpression string `json:"valueExpression"`
   451  }
   452  
   453  // UserValidationRule provides the configuration for a single user info validation rule.
   454  type UserValidationRule struct {
   455  	// expression represents the expression which will be evaluated by CEL.
   456  	// Must return true for the validation to pass.
   457  	//
   458  	// CEL expressions have access to the contents of UserInfo, organized into CEL variable:
   459  	// - 'user' - authentication.k8s.io/v1, Kind=UserInfo object
   460  	//    Refer to https://github.com/kubernetes/api/blob/release-1.28/authentication/v1/types.go#L105-L122 for the definition.
   461  	//    API documentation: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#userinfo-v1-authentication-k8s-io
   462  	//
   463  	// Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
   464  	//
   465  	// +required
   466  	Expression string `json:"expression"`
   467  
   468  	// message customizes the returned error message when rule returns false.
   469  	// message is a literal string.
   470  	// +optional
   471  	Message string `json:"message,omitempty"`
   472  }
   473  
   474  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   475  
   476  type AuthorizationConfiguration struct {
   477  	metav1.TypeMeta
   478  
   479  	// Authorizers is an ordered list of authorizers to
   480  	// authorize requests against.
   481  	// This is similar to the --authorization-modes kube-apiserver flag
   482  	// Must be at least one.
   483  	Authorizers []AuthorizerConfiguration `json:"authorizers"`
   484  }
   485  
   486  const (
   487  	TypeWebhook                                          AuthorizerType = "Webhook"
   488  	FailurePolicyNoOpinion                               string         = "NoOpinion"
   489  	FailurePolicyDeny                                    string         = "Deny"
   490  	AuthorizationWebhookConnectionInfoTypeKubeConfigFile string         = "KubeConfigFile"
   491  	AuthorizationWebhookConnectionInfoTypeInCluster      string         = "InClusterConfig"
   492  )
   493  
   494  type AuthorizerType string
   495  
   496  type AuthorizerConfiguration struct {
   497  	// Type refers to the type of the authorizer
   498  	// "Webhook" is supported in the generic API server
   499  	// Other API servers may support additional authorizer
   500  	// types like Node, RBAC, ABAC, etc.
   501  	Type string `json:"type"`
   502  
   503  	// Name used to describe the webhook
   504  	// This is explicitly used in monitoring machinery for metrics
   505  	// Note: Names must be DNS1123 labels like `myauthorizername` or
   506  	//		 subdomains like `myauthorizer.example.domain`
   507  	// Required, with no default
   508  	Name string `json:"name"`
   509  
   510  	// Webhook defines the configuration for a Webhook authorizer
   511  	// Must be defined when Type=Webhook
   512  	// Must not be defined when Type!=Webhook
   513  	Webhook *WebhookConfiguration `json:"webhook,omitempty"`
   514  }
   515  
   516  type WebhookConfiguration struct {
   517  	// The duration to cache 'authorized' responses from the webhook
   518  	// authorizer.
   519  	// Same as setting `--authorization-webhook-cache-authorized-ttl` flag
   520  	// Default: 5m0s
   521  	AuthorizedTTL metav1.Duration `json:"authorizedTTL"`
   522  	// The duration to cache 'unauthorized' responses from the webhook
   523  	// authorizer.
   524  	// Same as setting `--authorization-webhook-cache-unauthorized-ttl` flag
   525  	// Default: 30s
   526  	UnauthorizedTTL metav1.Duration `json:"unauthorizedTTL"`
   527  	// Timeout for the webhook request
   528  	// Maximum allowed value is 30s.
   529  	// Required, no default value.
   530  	Timeout metav1.Duration `json:"timeout"`
   531  	// The API version of the authorization.k8s.io SubjectAccessReview to
   532  	// send to and expect from the webhook.
   533  	// Same as setting `--authorization-webhook-version` flag
   534  	// Valid values: v1beta1, v1
   535  	// Required, no default value
   536  	SubjectAccessReviewVersion string `json:"subjectAccessReviewVersion"`
   537  	// MatchConditionSubjectAccessReviewVersion specifies the SubjectAccessReview
   538  	// version the CEL expressions are evaluated against
   539  	// Valid values: v1
   540  	// Required, no default value
   541  	MatchConditionSubjectAccessReviewVersion string `json:"matchConditionSubjectAccessReviewVersion"`
   542  	// Controls the authorization decision when a webhook request fails to
   543  	// complete or returns a malformed response or errors evaluating
   544  	// matchConditions.
   545  	// Valid values:
   546  	//   - NoOpinion: continue to subsequent authorizers to see if one of
   547  	//     them allows the request
   548  	//   - Deny: reject the request without consulting subsequent authorizers
   549  	// Required, with no default.
   550  	FailurePolicy string `json:"failurePolicy"`
   551  
   552  	// ConnectionInfo defines how we talk to the webhook
   553  	ConnectionInfo WebhookConnectionInfo `json:"connectionInfo"`
   554  
   555  	// matchConditions is a list of conditions that must be met for a request to be sent to this
   556  	// webhook. An empty list of matchConditions matches all requests.
   557  	// There are a maximum of 64 match conditions allowed.
   558  	//
   559  	// The exact matching logic is (in order):
   560  	//   1. If at least one matchCondition evaluates to FALSE, then the webhook is skipped.
   561  	//   2. If ALL matchConditions evaluate to TRUE, then the webhook is called.
   562  	//   3. If at least one matchCondition evaluates to an error (but none are FALSE):
   563  	//      - If failurePolicy=Deny, then the webhook rejects the request
   564  	//      - If failurePolicy=NoOpinion, then the error is ignored and the webhook is skipped
   565  	MatchConditions []WebhookMatchCondition `json:"matchConditions"`
   566  }
   567  
   568  type WebhookConnectionInfo struct {
   569  	// Controls how the webhook should communicate with the server.
   570  	// Valid values:
   571  	// - KubeConfigFile: use the file specified in kubeConfigFile to locate the
   572  	//   server.
   573  	// - InClusterConfig: use the in-cluster configuration to call the
   574  	//   SubjectAccessReview API hosted by kube-apiserver. This mode is not
   575  	//   allowed for kube-apiserver.
   576  	Type string `json:"type"`
   577  
   578  	// Path to KubeConfigFile for connection info
   579  	// Required, if connectionInfo.Type is KubeConfig
   580  	KubeConfigFile *string `json:"kubeConfigFile"`
   581  }
   582  
   583  type WebhookMatchCondition struct {
   584  	// expression represents the expression which will be evaluated by CEL. Must evaluate to bool.
   585  	// CEL expressions have access to the contents of the SubjectAccessReview in v1 version.
   586  	// If version specified by subjectAccessReviewVersion in the request variable is v1beta1,
   587  	// the contents would be converted to the v1 version before evaluating the CEL expression.
   588  	//
   589  	// Documentation on CEL: https://kubernetes.io/docs/reference/using-api/cel/
   590  	Expression string `json:"expression"`
   591  }