/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="options">The CORS options to be applied</param>
        public CorsBasedSecurityMessageHandler(
            CorsOptions options = null)
        {
            options.NotNull(nameof(options));

            Options = options;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="options">The CORS options to be applied</param>
        public CorsBasedSecurityMessageHandler(
            CorsOptions options = null)
        {
            options.NotNull(nameof(options));

            Options = options;
        }
Example #3
0
        public static CorsPolicy GetCorsPolicy(
            this CorsOptions options)
        {
            options.NotNull(nameof(options));

            var corsPolicy = new CorsPolicy
            {
                AllowAnyHeader      = options.AllowAnyHeader,
                AllowAnyMethod      = options.AllowAnyMethod,
                AllowAnyOrigin      = options.AllowAnyOrigin,
                SupportsCredentials = options.SupportsCredentials,
            };

            if (options.PreflightMaxAge.HasValue)
            {
                corsPolicy.PreflightMaxAge = options.PreflightMaxAge;
            }

            options.SetHeadersIfRequired(corsPolicy);
            options.SetMethodsIfRequired(corsPolicy);
            options.SetOriginsIfRequired(corsPolicy);

            return(corsPolicy);
        }