Esempio n. 1
0
        private async Task <bool> IsOriginAllowed(CorsPolicy policy, StringValues origin)
        {
            if (StringValues.IsNullOrEmpty(origin))
            {
                return(false);
            }

            return(policy.AllowAnyOrigin ||
                   policy.IsOriginAllowed(origin) ||
                   await _dynamicCorsPolicyResolver.ResolveForOrigin(origin));
        }
Esempio n. 2
0
        private bool IsOriginAllowed(CorsPolicy policy, StringValues origin)
        {
            if (StringValues.IsNullOrEmpty(origin))
            {
                return(false);
            }


            if (policy.AllowAnyOrigin || policy.IsOriginAllowed(origin))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        private static bool IsOriginAllowed(CorsPolicy policy, string origin)
        {
            if (string.IsNullOrEmpty(origin))
            {
                //does not have origin header
                return(false);
            }

            if (policy.AllowAnyOrigin || policy.IsOriginAllowed(origin))
            {
                return(true);
            }

            //policy failure
            //origin not allowed
            return(false);
        }
Esempio n. 4
0
    private bool IsOriginAllowed(CorsPolicy policy, StringValues origin)
    {
        if (StringValues.IsNullOrEmpty(origin))
        {
            _logger.RequestDoesNotHaveOriginHeader();
            return(false);
        }

        var originString = origin.ToString();

        _logger.RequestHasOriginHeader(originString);
        if (policy.AllowAnyOrigin || policy.IsOriginAllowed(originString))
        {
            _logger.PolicySuccess();
            return(true);
        }
        _logger.PolicyFailure();
        _logger.OriginNotAllowed(originString);
        return(false);
    }
Esempio n. 5
0
 private static void AddOriginToResult(string origin, CorsPolicy policy, CorsResult result)
 {
     if (policy.AllowAnyOrigin)
     {
         if (policy.SupportCredentials)
         {
             result.AllowedOrigin = origin;
             result.VaryByOrigin  = true;
         }
         else
         {
             result.AllowedOrigin = CorsConstants.AnyOrigin;
         }
     }
     else if (policy.IsOriginAllowed(origin))
     {
         result.AllowedOrigin = origin;
         if (policy.Origins.Count > 1)
         {
             result.VaryByOrigin = true;
         }
     }
 }