1# coding: utf-8 2# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. 3# 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. 4 5 6from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel # noqa: F401 7from oci.decorators import init_model_state_from_kwargs 8 9 10@init_model_state_from_kwargs 11class JsChallenge(object): 12 """ 13 The JavaScript challenge settings. JavaScript Challenge is the function to filter abnormal or malicious bots and allow access to real clients. 14 """ 15 16 #: A constant which can be used with the action property of a JsChallenge. 17 #: This constant has a value of "DETECT" 18 ACTION_DETECT = "DETECT" 19 20 #: A constant which can be used with the action property of a JsChallenge. 21 #: This constant has a value of "BLOCK" 22 ACTION_BLOCK = "BLOCK" 23 24 def __init__(self, **kwargs): 25 """ 26 Initializes a new JsChallenge object with values from keyword arguments. 27 The following keyword arguments are supported (corresponding to the getters/setters of this class): 28 29 :param is_enabled: 30 The value to assign to the is_enabled property of this JsChallenge. 31 :type is_enabled: bool 32 33 :param action: 34 The value to assign to the action property of this JsChallenge. 35 Allowed values for this property are: "DETECT", "BLOCK", 'UNKNOWN_ENUM_VALUE'. 36 Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. 37 :type action: str 38 39 :param failure_threshold: 40 The value to assign to the failure_threshold property of this JsChallenge. 41 :type failure_threshold: int 42 43 :param action_expiration_in_seconds: 44 The value to assign to the action_expiration_in_seconds property of this JsChallenge. 45 :type action_expiration_in_seconds: int 46 47 :param set_http_header: 48 The value to assign to the set_http_header property of this JsChallenge. 49 :type set_http_header: oci.waas.models.Header 50 51 :param challenge_settings: 52 The value to assign to the challenge_settings property of this JsChallenge. 53 :type challenge_settings: oci.waas.models.BlockChallengeSettings 54 55 :param are_redirects_challenged: 56 The value to assign to the are_redirects_challenged property of this JsChallenge. 57 :type are_redirects_challenged: bool 58 59 :param criteria: 60 The value to assign to the criteria property of this JsChallenge. 61 :type criteria: list[oci.waas.models.AccessRuleCriteria] 62 63 :param is_nat_enabled: 64 The value to assign to the is_nat_enabled property of this JsChallenge. 65 :type is_nat_enabled: bool 66 67 """ 68 self.swagger_types = { 69 'is_enabled': 'bool', 70 'action': 'str', 71 'failure_threshold': 'int', 72 'action_expiration_in_seconds': 'int', 73 'set_http_header': 'Header', 74 'challenge_settings': 'BlockChallengeSettings', 75 'are_redirects_challenged': 'bool', 76 'criteria': 'list[AccessRuleCriteria]', 77 'is_nat_enabled': 'bool' 78 } 79 80 self.attribute_map = { 81 'is_enabled': 'isEnabled', 82 'action': 'action', 83 'failure_threshold': 'failureThreshold', 84 'action_expiration_in_seconds': 'actionExpirationInSeconds', 85 'set_http_header': 'setHttpHeader', 86 'challenge_settings': 'challengeSettings', 87 'are_redirects_challenged': 'areRedirectsChallenged', 88 'criteria': 'criteria', 89 'is_nat_enabled': 'isNatEnabled' 90 } 91 92 self._is_enabled = None 93 self._action = None 94 self._failure_threshold = None 95 self._action_expiration_in_seconds = None 96 self._set_http_header = None 97 self._challenge_settings = None 98 self._are_redirects_challenged = None 99 self._criteria = None 100 self._is_nat_enabled = None 101 102 @property 103 def is_enabled(self): 104 """ 105 **[Required]** Gets the is_enabled of this JsChallenge. 106 Enables or disables the JavaScript challenge Web Application Firewall feature. 107 108 109 :return: The is_enabled of this JsChallenge. 110 :rtype: bool 111 """ 112 return self._is_enabled 113 114 @is_enabled.setter 115 def is_enabled(self, is_enabled): 116 """ 117 Sets the is_enabled of this JsChallenge. 118 Enables or disables the JavaScript challenge Web Application Firewall feature. 119 120 121 :param is_enabled: The is_enabled of this JsChallenge. 122 :type: bool 123 """ 124 self._is_enabled = is_enabled 125 126 @property 127 def action(self): 128 """ 129 Gets the action of this JsChallenge. 130 The action to take against requests from detected bots. If unspecified, defaults to `DETECT`. 131 132 Allowed values for this property are: "DETECT", "BLOCK", 'UNKNOWN_ENUM_VALUE'. 133 Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'. 134 135 136 :return: The action of this JsChallenge. 137 :rtype: str 138 """ 139 return self._action 140 141 @action.setter 142 def action(self, action): 143 """ 144 Sets the action of this JsChallenge. 145 The action to take against requests from detected bots. If unspecified, defaults to `DETECT`. 146 147 148 :param action: The action of this JsChallenge. 149 :type: str 150 """ 151 allowed_values = ["DETECT", "BLOCK"] 152 if not value_allowed_none_or_none_sentinel(action, allowed_values): 153 action = 'UNKNOWN_ENUM_VALUE' 154 self._action = action 155 156 @property 157 def failure_threshold(self): 158 """ 159 Gets the failure_threshold of this JsChallenge. 160 The number of failed requests before taking action. If unspecified, defaults to `10`. 161 162 163 :return: The failure_threshold of this JsChallenge. 164 :rtype: int 165 """ 166 return self._failure_threshold 167 168 @failure_threshold.setter 169 def failure_threshold(self, failure_threshold): 170 """ 171 Sets the failure_threshold of this JsChallenge. 172 The number of failed requests before taking action. If unspecified, defaults to `10`. 173 174 175 :param failure_threshold: The failure_threshold of this JsChallenge. 176 :type: int 177 """ 178 self._failure_threshold = failure_threshold 179 180 @property 181 def action_expiration_in_seconds(self): 182 """ 183 Gets the action_expiration_in_seconds of this JsChallenge. 184 The number of seconds between challenges from the same IP address. If unspecified, defaults to `60`. 185 186 187 :return: The action_expiration_in_seconds of this JsChallenge. 188 :rtype: int 189 """ 190 return self._action_expiration_in_seconds 191 192 @action_expiration_in_seconds.setter 193 def action_expiration_in_seconds(self, action_expiration_in_seconds): 194 """ 195 Sets the action_expiration_in_seconds of this JsChallenge. 196 The number of seconds between challenges from the same IP address. If unspecified, defaults to `60`. 197 198 199 :param action_expiration_in_seconds: The action_expiration_in_seconds of this JsChallenge. 200 :type: int 201 """ 202 self._action_expiration_in_seconds = action_expiration_in_seconds 203 204 @property 205 def set_http_header(self): 206 """ 207 Gets the set_http_header of this JsChallenge. 208 Adds an additional HTTP header to requests that fail the challenge before being passed to the origin. Only applicable when the `action` is set to `DETECT`. 209 210 211 :return: The set_http_header of this JsChallenge. 212 :rtype: oci.waas.models.Header 213 """ 214 return self._set_http_header 215 216 @set_http_header.setter 217 def set_http_header(self, set_http_header): 218 """ 219 Sets the set_http_header of this JsChallenge. 220 Adds an additional HTTP header to requests that fail the challenge before being passed to the origin. Only applicable when the `action` is set to `DETECT`. 221 222 223 :param set_http_header: The set_http_header of this JsChallenge. 224 :type: oci.waas.models.Header 225 """ 226 self._set_http_header = set_http_header 227 228 @property 229 def challenge_settings(self): 230 """ 231 Gets the challenge_settings of this JsChallenge. 232 233 :return: The challenge_settings of this JsChallenge. 234 :rtype: oci.waas.models.BlockChallengeSettings 235 """ 236 return self._challenge_settings 237 238 @challenge_settings.setter 239 def challenge_settings(self, challenge_settings): 240 """ 241 Sets the challenge_settings of this JsChallenge. 242 243 :param challenge_settings: The challenge_settings of this JsChallenge. 244 :type: oci.waas.models.BlockChallengeSettings 245 """ 246 self._challenge_settings = challenge_settings 247 248 @property 249 def are_redirects_challenged(self): 250 """ 251 Gets the are_redirects_challenged of this JsChallenge. 252 When enabled, redirect responses from the origin will also be challenged. This will change HTTP 301/302 responses from origin to HTTP 200 with an HTML body containing JavaScript page redirection. 253 254 255 :return: The are_redirects_challenged of this JsChallenge. 256 :rtype: bool 257 """ 258 return self._are_redirects_challenged 259 260 @are_redirects_challenged.setter 261 def are_redirects_challenged(self, are_redirects_challenged): 262 """ 263 Sets the are_redirects_challenged of this JsChallenge. 264 When enabled, redirect responses from the origin will also be challenged. This will change HTTP 301/302 responses from origin to HTTP 200 with an HTML body containing JavaScript page redirection. 265 266 267 :param are_redirects_challenged: The are_redirects_challenged of this JsChallenge. 268 :type: bool 269 """ 270 self._are_redirects_challenged = are_redirects_challenged 271 272 @property 273 def criteria(self): 274 """ 275 Gets the criteria of this JsChallenge. 276 When defined, the JavaScript Challenge would be applied only for the requests that matched all the listed conditions. 277 278 279 :return: The criteria of this JsChallenge. 280 :rtype: list[oci.waas.models.AccessRuleCriteria] 281 """ 282 return self._criteria 283 284 @criteria.setter 285 def criteria(self, criteria): 286 """ 287 Sets the criteria of this JsChallenge. 288 When defined, the JavaScript Challenge would be applied only for the requests that matched all the listed conditions. 289 290 291 :param criteria: The criteria of this JsChallenge. 292 :type: list[oci.waas.models.AccessRuleCriteria] 293 """ 294 self._criteria = criteria 295 296 @property 297 def is_nat_enabled(self): 298 """ 299 Gets the is_nat_enabled of this JsChallenge. 300 When enabled, the user is identified not only by the IP address but also by an unique additional hash, which prevents blocking visitors with shared IP addresses. 301 302 303 :return: The is_nat_enabled of this JsChallenge. 304 :rtype: bool 305 """ 306 return self._is_nat_enabled 307 308 @is_nat_enabled.setter 309 def is_nat_enabled(self, is_nat_enabled): 310 """ 311 Sets the is_nat_enabled of this JsChallenge. 312 When enabled, the user is identified not only by the IP address but also by an unique additional hash, which prevents blocking visitors with shared IP addresses. 313 314 315 :param is_nat_enabled: The is_nat_enabled of this JsChallenge. 316 :type: bool 317 """ 318 self._is_nat_enabled = is_nat_enabled 319 320 def __repr__(self): 321 return formatted_flat_dict(self) 322 323 def __eq__(self, other): 324 if other is None: 325 return False 326 327 return self.__dict__ == other.__dict__ 328 329 def __ne__(self, other): 330 return not self == other 331