Class CorsPolicy
Describes the Cross-Origin Resource Sharing (CORS) policy, for a given service. Refer to CORS for further details about cross origin resource sharing. For example, the following rule restricts cross origin requests to those originating from example.com domain using HTTP POST/GET, and sets the Access-Control-Allow-Credentials header to false. In addition, it only exposes X-Foo-bar header and sets an expiry period of 1 day.Describes the CorsPolicy V1VirtualService.
Namespace: Neon.Kube.Resources.Istio
Assembly: Neon.Kube.Resources.dll
Syntax
public class CorsPolicy
Constructors
CorsPolicy()
Initializes a new instance of the CorsPolicy class.
Declaration
public CorsPolicy()
Properties
AllowCredentials
Indicates whether the caller is allowed to send the actual request (not the preflight) using credentials. Serialized as the Access-Control-Allow-Credentials header.
Declaration
[JsonProperty(PropertyName = "allowCredentials", Required = Required.Default, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public bool? AllowCredentials { get; set; }
Property Value
Type | Description |
---|---|
bool? |
AllowHeaders
List of HTTP headers that can be used when requesting the resource. Serialized as the Access-Control-Allow-Headers header.
Declaration
[JsonProperty(PropertyName = "allowHeaders", Required = Required.Default, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public List<string> AllowHeaders { get; set; }
Property Value
Type | Description |
---|---|
List<string> |
AllowMethods
List of HTTP methods allowed to access the resource. The content will be serialized as the Access-Control-Allow-Methods header.
Declaration
[JsonProperty(PropertyName = "allowMethods", Required = Required.Default, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
[JsonConverter(typeof(JsonCollectionItemConverter<HTTPMethod, JsonStringEnumMemberConverter>))]
public IEnumerable<HTTPMethod> AllowMethods { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<HTTPMethod> |
AllowOrigins
String patterns that match allowed origins. An origin is allowed if any of the string matchers match. If a match is found, then the outgoing Access-Control-Allow-Origin would be set to the origin as provided by the client.
Declaration
[JsonProperty(PropertyName = "allowOrigins", Required = Required.Default, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public List<StringMatch> AllowOrigins { get; set; }
Property Value
Type | Description |
---|---|
List<StringMatch> |
ExposeHeaders
A list of HTTP headers that the browsers are allowed to access. Serialized as the Access-Control-Expose-Headers header.
Declaration
[JsonProperty(PropertyName = "exposeHeaders", Required = Required.Default, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public List<string> ExposeHeaders { get; set; }
Property Value
Type | Description |
---|---|
List<string> |
MaxAge
Specifies how long the results of a preflight request can be cached. Serializes as the Access-Control-Max-Age header.
Declaration
[JsonProperty(PropertyName = "maxAge", Required = Required.Default, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public string MaxAge { get; set; }
Property Value
Type | Description |
---|---|
string |
Methods
Validate()
Validate the object.
Declaration
public virtual void Validate()
Exceptions
Type | Condition |
---|---|
ValidationException | Thrown if validation fails. |