-
Notifications
You must be signed in to change notification settings - Fork 80
/
policy_config.go
310 lines (253 loc) · 15.9 KB
/
policy_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
// Copyright (c) 2016, 2018, 2024, Oracle and/or its affiliates. All rights reserved.
// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
// Code generated. DO NOT EDIT.
// Web Application Acceleration and Security Services API
//
// OCI Web Application Acceleration and Security Services
//
package waas
import (
"encoding/json"
"fmt"
"github.com/oracle/oci-go-sdk/v65/common"
"strings"
)
// PolicyConfig The configuration details for the WAAS policy.
type PolicyConfig struct {
// The OCID of the SSL certificate to use if HTTPS is supported.
CertificateId *string `mandatory:"false" json:"certificateId"`
// Enable or disable HTTPS support. If true, a `certificateId` is required. If unspecified, defaults to `false`.
IsHttpsEnabled *bool `mandatory:"false" json:"isHttpsEnabled"`
// Force HTTP to HTTPS redirection. If unspecified, defaults to `false`.
IsHttpsForced *bool `mandatory:"false" json:"isHttpsForced"`
// A list of allowed TLS protocols. Only applicable when HTTPS support is enabled.
// The TLS protocol is negotiated while the request is connecting and the most recent protocol supported by both the edge node and client browser will be selected. If no such version exists, the connection will be aborted.
// - **TLS_V1:** corresponds to TLS 1.0 specification.
// - **TLS_V1_1:** corresponds to TLS 1.1 specification.
// - **TLS_V1_2:** corresponds to TLS 1.2 specification.
// - **TLS_V1_3:** corresponds to TLS 1.3 specification.
// Enabled TLS protocols must go in a row. For example if `TLS_v1_1` and `TLS_V1_3` are enabled, `TLS_V1_2` must be enabled too.
TlsProtocols []PolicyConfigTlsProtocolsEnum `mandatory:"false" json:"tlsProtocols,omitempty"`
// Enable or disable GZIP compression of origin responses. If enabled, the header `Accept-Encoding: gzip` is sent to origin, otherwise, the empty `Accept-Encoding:` header is used.
IsOriginCompressionEnabled *bool `mandatory:"false" json:"isOriginCompressionEnabled"`
// Enabling `isBehindCdn` allows for the collection of IP addresses from client requests if the WAF is connected to a CDN.
IsBehindCdn *bool `mandatory:"false" json:"isBehindCdn"`
// Specifies an HTTP header name which is treated as the connecting client's IP address. Applicable only if `isBehindCdn` is enabled.
// The edge node reads this header and its value and sets the client IP address as specified. It does not create the header if the header is not present in the request. If the header is not present, the connecting IP address will be used as the client's true IP address. It uses the last IP address in the header's value as the true IP address.
// Example: `X-Client-Ip: 11.1.1.1, 13.3.3.3`
// In the case of multiple headers with the same name, only the first header will be used. It is assumed that CDN sets the correct client IP address to prevent spoofing.
// - **X_FORWARDED_FOR:** Corresponds to `X-Forwarded-For` header name.
// - **X_CLIENT_IP:** Corresponds to `X-Client-Ip` header name.
// - **X_REAL_IP:** Corresponds to `X-Real-Ip` header name.
// - **CLIENT_IP:** Corresponds to `Client-Ip` header name.
// - **TRUE_CLIENT_IP:** Corresponds to `True-Client-Ip` header name.
ClientAddressHeader PolicyConfigClientAddressHeaderEnum `mandatory:"false" json:"clientAddressHeader,omitempty"`
// Enable or disable automatic content caching based on the response `cache-control` header. This feature enables the origin to act as a proxy cache. Caching is usually defined using `cache-control` header. For example `cache-control: max-age=120` means that the returned resource is valid for 120 seconds. Caching rules will overwrite this setting.
IsCacheControlRespected *bool `mandatory:"false" json:"isCacheControlRespected"`
// Enable or disable buffering of responses from the origin. Buffering improves overall stability in case of network issues, but slightly increases Time To First Byte.
IsResponseBufferingEnabled *bool `mandatory:"false" json:"isResponseBufferingEnabled"`
// The set cipher group for the configured TLS protocol. This sets the configuration for the TLS connections between clients and edge nodes only.
// - **DEFAULT:** Cipher group supports TLS 1.0, TLS 1.1, TLS 1.2, TLS 1.3 protocols. It has the following ciphers enabled: `ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:!DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA`
CipherGroup PolicyConfigCipherGroupEnum `mandatory:"false" json:"cipherGroup,omitempty"`
// An object that represents a load balancing method and its properties.
LoadBalancingMethod LoadBalancingMethod `mandatory:"false" json:"loadBalancingMethod"`
// ModSecurity is not capable to inspect WebSockets. Therefore paths specified here have WAF disabled if Connection request header from the client has the value Upgrade (case insensitive matching) and Upgrade request header has the value websocket (case insensitive matching). Paths matches if the concatenation of request URL path and query starts with the contents of the one of `websocketPathPrefixes` array value. In All other cases challenges, like JSC, HIC and etc., remain active.
WebsocketPathPrefixes []string `mandatory:"false" json:"websocketPathPrefixes"`
// SNI stands for Server Name Indication and is an extension of the TLS protocol. It indicates which hostname is being contacted by the browser at the beginning of the 'handshake'-process. This allows a server to connect multiple SSL Certificates to one IP address and port.
IsSniEnabled *bool `mandatory:"false" json:"isSniEnabled"`
HealthChecks *HealthCheck `mandatory:"false" json:"healthChecks"`
}
func (m PolicyConfig) String() string {
return common.PointerString(m)
}
// ValidateEnumValue returns an error when providing an unsupported enum value
// This function is being called during constructing API request process
// Not recommended for calling this function directly
func (m PolicyConfig) ValidateEnumValue() (bool, error) {
errMessage := []string{}
for _, val := range m.TlsProtocols {
if _, ok := GetMappingPolicyConfigTlsProtocolsEnum(string(val)); !ok && val != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for TlsProtocols: %s. Supported values are: %s.", val, strings.Join(GetPolicyConfigTlsProtocolsEnumStringValues(), ",")))
}
}
if _, ok := GetMappingPolicyConfigClientAddressHeaderEnum(string(m.ClientAddressHeader)); !ok && m.ClientAddressHeader != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for ClientAddressHeader: %s. Supported values are: %s.", m.ClientAddressHeader, strings.Join(GetPolicyConfigClientAddressHeaderEnumStringValues(), ",")))
}
if _, ok := GetMappingPolicyConfigCipherGroupEnum(string(m.CipherGroup)); !ok && m.CipherGroup != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for CipherGroup: %s. Supported values are: %s.", m.CipherGroup, strings.Join(GetPolicyConfigCipherGroupEnumStringValues(), ",")))
}
if len(errMessage) > 0 {
return true, fmt.Errorf(strings.Join(errMessage, "\n"))
}
return false, nil
}
// UnmarshalJSON unmarshals from json
func (m *PolicyConfig) UnmarshalJSON(data []byte) (e error) {
model := struct {
CertificateId *string `json:"certificateId"`
IsHttpsEnabled *bool `json:"isHttpsEnabled"`
IsHttpsForced *bool `json:"isHttpsForced"`
TlsProtocols []PolicyConfigTlsProtocolsEnum `json:"tlsProtocols"`
IsOriginCompressionEnabled *bool `json:"isOriginCompressionEnabled"`
IsBehindCdn *bool `json:"isBehindCdn"`
ClientAddressHeader PolicyConfigClientAddressHeaderEnum `json:"clientAddressHeader"`
IsCacheControlRespected *bool `json:"isCacheControlRespected"`
IsResponseBufferingEnabled *bool `json:"isResponseBufferingEnabled"`
CipherGroup PolicyConfigCipherGroupEnum `json:"cipherGroup"`
LoadBalancingMethod loadbalancingmethod `json:"loadBalancingMethod"`
WebsocketPathPrefixes []string `json:"websocketPathPrefixes"`
IsSniEnabled *bool `json:"isSniEnabled"`
HealthChecks *HealthCheck `json:"healthChecks"`
}{}
e = json.Unmarshal(data, &model)
if e != nil {
return
}
var nn interface{}
m.CertificateId = model.CertificateId
m.IsHttpsEnabled = model.IsHttpsEnabled
m.IsHttpsForced = model.IsHttpsForced
m.TlsProtocols = make([]PolicyConfigTlsProtocolsEnum, len(model.TlsProtocols))
copy(m.TlsProtocols, model.TlsProtocols)
m.IsOriginCompressionEnabled = model.IsOriginCompressionEnabled
m.IsBehindCdn = model.IsBehindCdn
m.ClientAddressHeader = model.ClientAddressHeader
m.IsCacheControlRespected = model.IsCacheControlRespected
m.IsResponseBufferingEnabled = model.IsResponseBufferingEnabled
m.CipherGroup = model.CipherGroup
nn, e = model.LoadBalancingMethod.UnmarshalPolymorphicJSON(model.LoadBalancingMethod.JsonData)
if e != nil {
return
}
if nn != nil {
m.LoadBalancingMethod = nn.(LoadBalancingMethod)
} else {
m.LoadBalancingMethod = nil
}
m.WebsocketPathPrefixes = make([]string, len(model.WebsocketPathPrefixes))
copy(m.WebsocketPathPrefixes, model.WebsocketPathPrefixes)
m.IsSniEnabled = model.IsSniEnabled
m.HealthChecks = model.HealthChecks
return
}
// PolicyConfigTlsProtocolsEnum Enum with underlying type: string
type PolicyConfigTlsProtocolsEnum string
// Set of constants representing the allowable values for PolicyConfigTlsProtocolsEnum
const (
PolicyConfigTlsProtocolsV1 PolicyConfigTlsProtocolsEnum = "TLS_V1"
PolicyConfigTlsProtocolsV11 PolicyConfigTlsProtocolsEnum = "TLS_V1_1"
PolicyConfigTlsProtocolsV12 PolicyConfigTlsProtocolsEnum = "TLS_V1_2"
PolicyConfigTlsProtocolsV13 PolicyConfigTlsProtocolsEnum = "TLS_V1_3"
)
var mappingPolicyConfigTlsProtocolsEnum = map[string]PolicyConfigTlsProtocolsEnum{
"TLS_V1": PolicyConfigTlsProtocolsV1,
"TLS_V1_1": PolicyConfigTlsProtocolsV11,
"TLS_V1_2": PolicyConfigTlsProtocolsV12,
"TLS_V1_3": PolicyConfigTlsProtocolsV13,
}
var mappingPolicyConfigTlsProtocolsEnumLowerCase = map[string]PolicyConfigTlsProtocolsEnum{
"tls_v1": PolicyConfigTlsProtocolsV1,
"tls_v1_1": PolicyConfigTlsProtocolsV11,
"tls_v1_2": PolicyConfigTlsProtocolsV12,
"tls_v1_3": PolicyConfigTlsProtocolsV13,
}
// GetPolicyConfigTlsProtocolsEnumValues Enumerates the set of values for PolicyConfigTlsProtocolsEnum
func GetPolicyConfigTlsProtocolsEnumValues() []PolicyConfigTlsProtocolsEnum {
values := make([]PolicyConfigTlsProtocolsEnum, 0)
for _, v := range mappingPolicyConfigTlsProtocolsEnum {
values = append(values, v)
}
return values
}
// GetPolicyConfigTlsProtocolsEnumStringValues Enumerates the set of values in String for PolicyConfigTlsProtocolsEnum
func GetPolicyConfigTlsProtocolsEnumStringValues() []string {
return []string{
"TLS_V1",
"TLS_V1_1",
"TLS_V1_2",
"TLS_V1_3",
}
}
// GetMappingPolicyConfigTlsProtocolsEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingPolicyConfigTlsProtocolsEnum(val string) (PolicyConfigTlsProtocolsEnum, bool) {
enum, ok := mappingPolicyConfigTlsProtocolsEnumLowerCase[strings.ToLower(val)]
return enum, ok
}
// PolicyConfigClientAddressHeaderEnum Enum with underlying type: string
type PolicyConfigClientAddressHeaderEnum string
// Set of constants representing the allowable values for PolicyConfigClientAddressHeaderEnum
const (
PolicyConfigClientAddressHeaderXForwardedFor PolicyConfigClientAddressHeaderEnum = "X_FORWARDED_FOR"
PolicyConfigClientAddressHeaderXClientIp PolicyConfigClientAddressHeaderEnum = "X_CLIENT_IP"
PolicyConfigClientAddressHeaderXRealIp PolicyConfigClientAddressHeaderEnum = "X_REAL_IP"
PolicyConfigClientAddressHeaderClientIp PolicyConfigClientAddressHeaderEnum = "CLIENT_IP"
PolicyConfigClientAddressHeaderTrueClientIp PolicyConfigClientAddressHeaderEnum = "TRUE_CLIENT_IP"
)
var mappingPolicyConfigClientAddressHeaderEnum = map[string]PolicyConfigClientAddressHeaderEnum{
"X_FORWARDED_FOR": PolicyConfigClientAddressHeaderXForwardedFor,
"X_CLIENT_IP": PolicyConfigClientAddressHeaderXClientIp,
"X_REAL_IP": PolicyConfigClientAddressHeaderXRealIp,
"CLIENT_IP": PolicyConfigClientAddressHeaderClientIp,
"TRUE_CLIENT_IP": PolicyConfigClientAddressHeaderTrueClientIp,
}
var mappingPolicyConfigClientAddressHeaderEnumLowerCase = map[string]PolicyConfigClientAddressHeaderEnum{
"x_forwarded_for": PolicyConfigClientAddressHeaderXForwardedFor,
"x_client_ip": PolicyConfigClientAddressHeaderXClientIp,
"x_real_ip": PolicyConfigClientAddressHeaderXRealIp,
"client_ip": PolicyConfigClientAddressHeaderClientIp,
"true_client_ip": PolicyConfigClientAddressHeaderTrueClientIp,
}
// GetPolicyConfigClientAddressHeaderEnumValues Enumerates the set of values for PolicyConfigClientAddressHeaderEnum
func GetPolicyConfigClientAddressHeaderEnumValues() []PolicyConfigClientAddressHeaderEnum {
values := make([]PolicyConfigClientAddressHeaderEnum, 0)
for _, v := range mappingPolicyConfigClientAddressHeaderEnum {
values = append(values, v)
}
return values
}
// GetPolicyConfigClientAddressHeaderEnumStringValues Enumerates the set of values in String for PolicyConfigClientAddressHeaderEnum
func GetPolicyConfigClientAddressHeaderEnumStringValues() []string {
return []string{
"X_FORWARDED_FOR",
"X_CLIENT_IP",
"X_REAL_IP",
"CLIENT_IP",
"TRUE_CLIENT_IP",
}
}
// GetMappingPolicyConfigClientAddressHeaderEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingPolicyConfigClientAddressHeaderEnum(val string) (PolicyConfigClientAddressHeaderEnum, bool) {
enum, ok := mappingPolicyConfigClientAddressHeaderEnumLowerCase[strings.ToLower(val)]
return enum, ok
}
// PolicyConfigCipherGroupEnum Enum with underlying type: string
type PolicyConfigCipherGroupEnum string
// Set of constants representing the allowable values for PolicyConfigCipherGroupEnum
const (
PolicyConfigCipherGroupDefault PolicyConfigCipherGroupEnum = "DEFAULT"
)
var mappingPolicyConfigCipherGroupEnum = map[string]PolicyConfigCipherGroupEnum{
"DEFAULT": PolicyConfigCipherGroupDefault,
}
var mappingPolicyConfigCipherGroupEnumLowerCase = map[string]PolicyConfigCipherGroupEnum{
"default": PolicyConfigCipherGroupDefault,
}
// GetPolicyConfigCipherGroupEnumValues Enumerates the set of values for PolicyConfigCipherGroupEnum
func GetPolicyConfigCipherGroupEnumValues() []PolicyConfigCipherGroupEnum {
values := make([]PolicyConfigCipherGroupEnum, 0)
for _, v := range mappingPolicyConfigCipherGroupEnum {
values = append(values, v)
}
return values
}
// GetPolicyConfigCipherGroupEnumStringValues Enumerates the set of values in String for PolicyConfigCipherGroupEnum
func GetPolicyConfigCipherGroupEnumStringValues() []string {
return []string{
"DEFAULT",
}
}
// GetMappingPolicyConfigCipherGroupEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingPolicyConfigCipherGroupEnum(val string) (PolicyConfigCipherGroupEnum, bool) {
enum, ok := mappingPolicyConfigCipherGroupEnumLowerCase[strings.ToLower(val)]
return enum, ok
}