Skip to content

Commit bc98505

Browse files
authored
feat: support ApisixConsumer (#170)
1 parent 9694400 commit bc98505

27 files changed

+1660
-793
lines changed

api/adc/plugin_types.go

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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 adc
14+
15+
// IPRestrictConfig is the rule config for ip-restriction plugin.
16+
// +k8s:deepcopy-gen=true
17+
type IPRestrictConfig struct {
18+
Allowlist []string `json:"whitelist,omitempty"`
19+
Blocklist []string `json:"blacklist,omitempty"`
20+
}
21+
22+
// CorsConfig is the rule config for cors plugin.
23+
// +k8s:deepcopy-gen=true
24+
type CorsConfig struct {
25+
AllowOrigins string `json:"allow_origins,omitempty"`
26+
AllowMethods string `json:"allow_methods,omitempty"`
27+
AllowHeaders string `json:"allow_headers,omitempty"`
28+
}
29+
30+
// CSRfConfig is the rule config for csrf plugin.
31+
// +k8s:deepcopy-gen=true
32+
type CSRFConfig struct {
33+
Key string `json:"key"`
34+
}
35+
36+
// KeyAuthConsumerConfig is the rule config for key-auth plugin
37+
// used in Consumer object.
38+
// +k8s:deepcopy-gen=true
39+
type KeyAuthConsumerConfig struct {
40+
Key string `json:"key"`
41+
}
42+
43+
// KeyAuthRouteConfig is the rule config for key-auth plugin
44+
// used in Route object.
45+
type KeyAuthRouteConfig struct {
46+
Header string `json:"header,omitempty"`
47+
}
48+
49+
// BasicAuthConsumerConfig is the rule config for basic-auth plugin
50+
// used in Consumer object.
51+
// +k8s:deepcopy-gen=true
52+
type BasicAuthConsumerConfig struct {
53+
Username string `json:"username"`
54+
Password string `json:"password"`
55+
}
56+
57+
// JwtAuthConsumerConfig is the rule config for jwt-auth plugin
58+
// used in Consumer object.
59+
// +k8s:deepcopy-gen=true
60+
type JwtAuthConsumerConfig struct {
61+
Key string `json:"key" yaml:"key"`
62+
Secret string `json:"secret,omitempty" yaml:"secret,omitempty"`
63+
PublicKey string `json:"public_key,omitempty" yaml:"public_key,omitempty"`
64+
PrivateKey string `json:"private_key" yaml:"private_key,omitempty"`
65+
Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"`
66+
Exp int64 `json:"exp,omitempty" yaml:"exp,omitempty"`
67+
Base64Secret bool `json:"base64_secret,omitempty" yaml:"base64_secret,omitempty"`
68+
LifetimeGracePeriod int64 `json:"lifetime_grace_period,omitempty" yaml:"lifetime_grace_period,omitempty"`
69+
}
70+
71+
// HMACAuthConsumerConfig is the rule config for hmac-auth plugin
72+
// used in Consumer object.
73+
// +k8s:deepcopy-gen=true
74+
type HMACAuthConsumerConfig struct {
75+
AccessKey string `json:"access_key" yaml:"access_key"`
76+
SecretKey string `json:"secret_key" yaml:"secret_key"`
77+
Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"`
78+
ClockSkew int64 `json:"clock_skew,omitempty" yaml:"clock_skew,omitempty"`
79+
SignedHeaders []string `json:"signed_headers,omitempty" yaml:"signed_headers,omitempty"`
80+
KeepHeaders bool `json:"keep_headers,omitempty" yaml:"keep_headers,omitempty"`
81+
EncodeURIParams bool `json:"encode_uri_params,omitempty" yaml:"encode_uri_params,omitempty"`
82+
ValidateRequestBody bool `json:"validate_request_body,omitempty" yaml:"validate_request_body,omitempty"`
83+
MaxReqBody int64 `json:"max_req_body,omitempty" yaml:"max_req_body,omitempty"`
84+
}
85+
86+
// LDAPAuthConsumerConfig is the rule config for ldap-auth plugin
87+
// used in Consumer object.
88+
// +k8s:deepcopy-gen=true
89+
type LDAPAuthConsumerConfig struct {
90+
UserDN string `json:"user_dn"`
91+
}
92+
93+
// BasicAuthRouteConfig is the rule config for basic-auth plugin
94+
// used in Route object.
95+
// +k8s:deepcopy-gen=true
96+
type BasicAuthRouteConfig struct{}
97+
98+
// WolfRBACConsumerConfig is the rule config for wolf-rbac plugin
99+
// used in Consumer object.
100+
// +k8s:deepcopy-gen=true
101+
type WolfRBACConsumerConfig struct {
102+
Server string `json:"server,omitempty"`
103+
Appid string `json:"appid,omitempty"`
104+
HeaderPrefix string `json:"header_prefix,omitempty"`
105+
}
106+
107+
// ForwardAuthConfig is the rule config for forward-auth plugin.
108+
// +k8s:deepcopy-gen=true
109+
type ForwardAuthConfig struct {
110+
URI string `json:"uri"`
111+
SSLVerify bool `json:"ssl_verify"`
112+
RequestHeaders []string `json:"request_headers,omitempty"`
113+
UpstreamHeaders []string `json:"upstream_headers,omitempty"`
114+
ClientHeaders []string `json:"client_headers,omitempty"`
115+
}
116+
117+
// BasicAuthConfig is the rule config for basic-auth plugin.
118+
// +k8s:deepcopy-gen=true
119+
type BasicAuthConfig struct {
120+
}
121+
122+
// KeyAuthConfig is the rule config for key-auth plugin.
123+
// +k8s:deepcopy-gen=true
124+
type KeyAuthConfig struct {
125+
}

api/adc/zz_generated.deepcopy.go

Lines changed: 225 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v2/apisixroute_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ type ApisixRoutePlugin struct {
140140
Enable bool `json:"enable" yaml:"enable"`
141141
// Plugin configuration.
142142
// +kubebuilder:validation:Optional
143-
Config ApisixRoutePluginConfig `json:"config" yaml:"config"`
143+
Config apiextensionsv1.JSON `json:"config" yaml:"config"`
144144
// Plugin configuration secretRef.
145145
// +kubebuilder:validation:Optional
146146
SecretRef string `json:"secretRef" yaml:"secretRef"`

0 commit comments

Comments
 (0)