@@ -600,27 +600,32 @@ type AccessControl struct {
600600
601601// RateLimit defines a rate limit policy.
602602type RateLimit struct {
603- Rate string `json:"rate"`
604- Key string `json:"key"`
605- Delay * int `json:"delay"`
606- NoDelay * bool `json:"noDelay"`
607- Burst * int `json:"burst"`
608- ZoneSize string `json:"zoneSize"`
609- DryRun * bool `json:"dryRun"`
610- LogLevel string `json:"logLevel"`
611- RejectCode * int `json:"rejectCode"`
612- Scale bool `json:"scale"`
613- Condition * RateLimitCondition `json:"condition"`
614- }
615-
616- // TODO: add valition at CRD level
603+ Rate string `json:"rate"`
604+ Key string `json:"key"`
605+ Delay * int `json:"delay"`
606+ NoDelay * bool `json:"noDelay"`
607+ Burst * int `json:"burst"`
608+ ZoneSize string `json:"zoneSize"`
609+ DryRun * bool `json:"dryRun"`
610+ LogLevel string `json:"logLevel"`
611+ RejectCode * int `json:"rejectCode"`
612+ Scale bool `json:"scale"`
613+ // +kubebuilder:validation:Optional
614+ Condition * RateLimitCondition `json:"condition"`
615+ }
616+
617617type RateLimitCondition struct {
618- JWT JWTCondition `json:"jwt"`
619- Default bool `json:"default"`
618+ JWT JWTCondition `json:"jwt"`
619+ // +kubebuilder:validation:Optional
620+ Default bool `json:"default"`
620621}
621622
622623type JWTCondition struct {
624+ // +kubebuilder:validation:Required
625+ // +kubebuilder:validation:Pattern=^([^$\s"'])*$
623626 Claim string `json:"claim"`
627+ // +kubebuilder:validation:Required
628+ // +kubebuilder:validation:Pattern=^([^$\s."'])*$
624629 Match string `json:"match"`
625630}
626631
0 commit comments