|
| 1 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +// you may not use this file except in compliance with the License. |
| 3 | +// You may obtain a copy of the License at |
| 4 | +// |
| 5 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +// |
| 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 v2 |
| 14 | + |
| 15 | +import ( |
| 16 | + corev1 "k8s.io/api/core/v1" |
| 17 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 18 | +) |
| 19 | + |
| 20 | +// ApisixConsumerSpec defines the desired state of ApisixConsumer. |
| 21 | +type ApisixConsumerSpec struct { |
| 22 | + // IngressClassName is the name of an IngressClass cluster resource. |
| 23 | + // controller implementations use this field to know whether they should be |
| 24 | + // serving this ApisixConsumer resource, by a transitive connection |
| 25 | + // (controller -> IngressClass -> ApisixConsumer resource). |
| 26 | + IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"` |
| 27 | + |
| 28 | + AuthParameter ApisixConsumerAuthParameter `json:"authParameter" yaml:"authParameter"` |
| 29 | +} |
| 30 | + |
| 31 | +// ApisixConsumerStatus defines the observed state of ApisixConsumer. |
| 32 | +type ApisixConsumerStatus = ApisixStatus |
| 33 | + |
| 34 | +// +kubebuilder:object:root=true |
| 35 | +// +kubebuilder:subresource:status |
| 36 | + |
| 37 | +// ApisixConsumer is the Schema for the apisixconsumers API. |
| 38 | +type ApisixConsumer struct { |
| 39 | + metav1.TypeMeta `json:",inline"` |
| 40 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 41 | + |
| 42 | + Spec ApisixConsumerSpec `json:"spec,omitempty"` |
| 43 | + Status ApisixConsumerStatus `json:"status,omitempty"` |
| 44 | +} |
| 45 | + |
| 46 | +// +kubebuilder:object:root=true |
| 47 | + |
| 48 | +// ApisixConsumerList contains a list of ApisixConsumer. |
| 49 | +type ApisixConsumerList struct { |
| 50 | + metav1.TypeMeta `json:",inline"` |
| 51 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 52 | + Items []ApisixConsumer `json:"items"` |
| 53 | +} |
| 54 | + |
| 55 | +type ApisixConsumerAuthParameter struct { |
| 56 | + BasicAuth *ApisixConsumerBasicAuth `json:"basicAuth,omitempty" yaml:"basicAuth"` |
| 57 | + KeyAuth *ApisixConsumerKeyAuth `json:"keyAuth,omitempty" yaml:"keyAuth"` |
| 58 | + WolfRBAC *ApisixConsumerWolfRBAC `json:"wolfRBAC,omitempty" yaml:"wolfRBAC"` |
| 59 | + JwtAuth *ApisixConsumerJwtAuth `json:"jwtAuth,omitempty" yaml:"jwtAuth"` |
| 60 | + HMACAuth *ApisixConsumerHMACAuth `json:"hmacAuth,omitempty" yaml:"hmacAuth"` |
| 61 | + LDAPAuth *ApisixConsumerLDAPAuth `json:"ldapAuth,omitempty" yaml:"ldapAuth"` |
| 62 | +} |
| 63 | + |
| 64 | +// ApisixConsumerBasicAuth defines the configuration for basic auth. |
| 65 | +type ApisixConsumerBasicAuth struct { |
| 66 | + SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"` |
| 67 | + Value *ApisixConsumerBasicAuthValue `json:"value,omitempty" yaml:"value,omitempty"` |
| 68 | +} |
| 69 | + |
| 70 | +// ApisixConsumerBasicAuthValue defines the in-place username and password configuration for basic auth. |
| 71 | +type ApisixConsumerBasicAuthValue struct { |
| 72 | + Username string `json:"username" yaml:"username"` |
| 73 | + Password string `json:"password" yaml:"password"` |
| 74 | +} |
| 75 | + |
| 76 | +// ApisixConsumerKeyAuth defines the configuration for the key auth. |
| 77 | +type ApisixConsumerKeyAuth struct { |
| 78 | + SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"` |
| 79 | + Value *ApisixConsumerKeyAuthValue `json:"value,omitempty" yaml:"value,omitempty"` |
| 80 | +} |
| 81 | + |
| 82 | +// ApisixConsumerKeyAuthValue defines the in-place configuration for basic auth. |
| 83 | +type ApisixConsumerKeyAuthValue struct { |
| 84 | + Key string `json:"key" yaml:"key"` |
| 85 | +} |
| 86 | + |
| 87 | +// ApisixConsumerWolfRBAC defines the configuration for the wolf-rbac auth. |
| 88 | +type ApisixConsumerWolfRBAC struct { |
| 89 | + SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"` |
| 90 | + Value *ApisixConsumerWolfRBACValue `json:"value,omitempty" yaml:"value,omitempty"` |
| 91 | +} |
| 92 | + |
| 93 | +// ApisixConsumerWolfRBAC defines the in-place server and appid and header_prefix configuration for wolf-rbac auth. |
| 94 | +type ApisixConsumerWolfRBACValue struct { |
| 95 | + Server string `json:"server,omitempty" yaml:"server,omitempty"` |
| 96 | + Appid string `json:"appid,omitempty" yaml:"appid,omitempty"` |
| 97 | + HeaderPrefix string `json:"header_prefix,omitempty" yaml:"header_prefix,omitempty"` |
| 98 | +} |
| 99 | + |
| 100 | +// ApisixConsumerJwtAuth defines the configuration for the jwt auth. |
| 101 | +type ApisixConsumerJwtAuth struct { |
| 102 | + SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"` |
| 103 | + Value *ApisixConsumerJwtAuthValue `json:"value,omitempty" yaml:"value,omitempty"` |
| 104 | +} |
| 105 | + |
| 106 | +// ApisixConsumerJwtAuthValue defines the in-place configuration for jwt auth. |
| 107 | +type ApisixConsumerJwtAuthValue struct { |
| 108 | + Key string `json:"key" yaml:"key"` |
| 109 | + Secret string `json:"secret,omitempty" yaml:"secret,omitempty"` |
| 110 | + PublicKey string `json:"public_key,omitempty" yaml:"public_key,omitempty"` |
| 111 | + PrivateKey string `json:"private_key" yaml:"private_key,omitempty"` |
| 112 | + Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"` |
| 113 | + Exp int64 `json:"exp,omitempty" yaml:"exp,omitempty"` |
| 114 | + Base64Secret bool `json:"base64_secret,omitempty" yaml:"base64_secret,omitempty"` |
| 115 | + LifetimeGracePeriod int64 `json:"lifetime_grace_period,omitempty" yaml:"lifetime_grace_period,omitempty"` |
| 116 | +} |
| 117 | + |
| 118 | +// ApisixConsumerHMACAuth defines the configuration for the hmac auth. |
| 119 | +type ApisixConsumerHMACAuth struct { |
| 120 | + SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"` |
| 121 | + Value *ApisixConsumerHMACAuthValue `json:"value,omitempty" yaml:"value,omitempty"` |
| 122 | +} |
| 123 | + |
| 124 | +// ApisixConsumerHMACAuthValue defines the in-place configuration for hmac auth. |
| 125 | +type ApisixConsumerHMACAuthValue struct { |
| 126 | + AccessKey string `json:"access_key" yaml:"access_key"` |
| 127 | + SecretKey string `json:"secret_key" yaml:"secret_key"` |
| 128 | + Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"` |
| 129 | + ClockSkew int64 `json:"clock_skew,omitempty" yaml:"clock_skew,omitempty"` |
| 130 | + SignedHeaders []string `json:"signed_headers,omitempty" yaml:"signed_headers,omitempty"` |
| 131 | + KeepHeaders bool `json:"keep_headers,omitempty" yaml:"keep_headers,omitempty"` |
| 132 | + EncodeURIParams bool `json:"encode_uri_params,omitempty" yaml:"encode_uri_params,omitempty"` |
| 133 | + ValidateRequestBody bool `json:"validate_request_body,omitempty" yaml:"validate_request_body,omitempty"` |
| 134 | + MaxReqBody int64 `json:"max_req_body,omitempty" yaml:"max_req_body,omitempty"` |
| 135 | +} |
| 136 | + |
| 137 | +// ApisixConsumerLDAPAuth defines the configuration for the ldap auth. |
| 138 | +type ApisixConsumerLDAPAuth struct { |
| 139 | + SecretRef *corev1.LocalObjectReference `json:"secretRef" yaml:"secret"` |
| 140 | + Value *ApisixConsumerLDAPAuthValue `json:"value,omitempty" yaml:"value,omitempty"` |
| 141 | +} |
| 142 | + |
| 143 | +// ApisixConsumerLDAPAuthValue defines the in-place configuration for ldap auth. |
| 144 | +type ApisixConsumerLDAPAuthValue struct { |
| 145 | + UserDN string `json:"user_dn" yaml:"user_dn"` |
| 146 | +} |
| 147 | + |
| 148 | +func init() { |
| 149 | + SchemeBuilder.Register(&ApisixConsumer{}, &ApisixConsumerList{}) |
| 150 | +} |
0 commit comments