示例#1
0
        public ChangesPushContent(RavenBaseApiController controller)
		{
			Connected = true;
            ResourceName = controller.TenantName;
			Id = controller.GetQueryStringValue("id");
            
			if (string.IsNullOrEmpty(Id))
				throw new ArgumentException("Id is mandatory");

            long coolDownWithDataLossInMiliseconds = 0;
			long.TryParse(controller.GetQueryStringValue("coolDownWithDataLoss"), out coolDownWithDataLossInMiliseconds);
            CoolDownWithDataLossInMiliseconds = coolDownWithDataLossInMiliseconds;
		}
示例#2
0
        public ChangesPushContent(RavenBaseApiController controller)
        {
            Connected = true;
            Id        = controller.GetQueryStringValue("id");

            if (string.IsNullOrEmpty(Id))
            {
                throw new ArgumentException("Id is mandatory");
            }

            long coolDownWithDataLossInMilisecods = 0;

            long.TryParse(controller.GetQueryStringValue("coolDownWithDataLoss"), out coolDownWithDataLossInMilisecods);
            CoolDownWithDataLossInMilisecods = coolDownWithDataLossInMilisecods;
        }
示例#3
0
        public ChangesPushContent(RavenBaseApiController controller)
        {
            Connected    = true;
            ResourceName = controller.TenantName;
            Id           = controller.GetQueryStringValue("id");

            if (string.IsNullOrEmpty(Id))
            {
                throw new ArgumentException("Id is mandatory");
            }
            cancellationTokenSource = WebSocketTransportFactory.RavenGcCancellation;
            long coolDownWithDataLossInMiliseconds = 0;

            long.TryParse(controller.GetQueryStringValue("coolDownWithDataLoss"), out coolDownWithDataLossInMiliseconds);
            CoolDownWithDataLossInMiliseconds = coolDownWithDataLossInMiliseconds;
        }
示例#4
0
        public LogsPushContent(RavenBaseApiController controller)
		{
			Connected = true;
			Id = controller.GetQueryStringValue("id");
            
			if (string.IsNullOrEmpty(Id))
				throw new ArgumentException("Id is mandatory");
		}
示例#5
0
        public LogsPushContent(RavenBaseApiController controller)
        {
            Connected = true;
            Id        = controller.GetQueryStringValue("id");

            if (string.IsNullOrEmpty(Id))
            {
                throw new ArgumentException("Id is mandatory");
            }
        }
示例#6
0
        private static HttpResponseMessage ProvideDebugAuthInfo(RavenBaseApiController controller, object msg)
        {
            string debugAuth = controller.GetQueryStringValue("debug-auth");

            if (debugAuth == null)
            {
                return(controller.GetEmptyMessage());
            }

            bool shouldProvideDebugAuthInformation;

            if (bool.TryParse(debugAuth, out shouldProvideDebugAuthInformation) && shouldProvideDebugAuthInformation)
            {
                return(controller.GetMessageWithObject(msg));
            }

            return(controller.GetEmptyMessage());
        }
示例#7
0
        public IPrincipal GetUser(RavenBaseApiController controller)
        {
            if (controller.WasAlreadyAuthorizedUsingSingleAuthToken)
            {
                return(controller.User);
            }

            var hasApiKey             = "True".Equals(controller.GetQueryStringValue("Has-Api-Key"), StringComparison.CurrentCultureIgnoreCase);
            var authHeader            = controller.GetHeader("Authorization");
            var hasOAuthTokenInCookie = controller.HasCookie("OAuth-Token");

            if (hasApiKey || hasOAuthTokenInCookie ||
                string.IsNullOrEmpty(authHeader) == false && authHeader.StartsWith("Bearer "))
            {
                return(oAuthRequestAuthorizer.GetUser(controller, hasApiKey));
            }
            return(windowsRequestAuthorizer.GetUser(controller));
        }
        public bool TryAuthorize(RavenBaseApiController controller, out HttpResponseMessage msg)
        {
            var requestUrl = controller.GetRequestUrl();

            if (NeverSecret.IsNeverSecretUrl(requestUrl))
            {
                msg = controller.GetEmptyMessage();
                return(true);
            }

            //CORS pre-flight (ignore creds if using cors).
            if (Settings.AccessControlAllowOrigin.Count > 0 && controller.InnerRequest.Method.Method == "OPTIONS")
            {
                msg = controller.GetEmptyMessage();
                return(true);
            }

            var oneTimeToken = controller.GetHeader("Single-Use-Auth-Token");

            if (string.IsNullOrEmpty(oneTimeToken))
            {
                oneTimeToken = controller.GetQueryStringValue("singleUseAuthToken");
            }

            if (string.IsNullOrEmpty(oneTimeToken) == false)
            {
                return(TryAuthorizeSingleUseAuthToken(controller, oneTimeToken, out msg));
            }

            var authHeader            = controller.GetHeader("Authorization");
            var hasApiKey             = "True".Equals(controller.GetHeader("Has-Api-Key"), StringComparison.CurrentCultureIgnoreCase);
            var hasOAuthTokenInCookie = controller.HasCookie("OAuth-Token");

            if (hasApiKey || hasOAuthTokenInCookie ||
                string.IsNullOrEmpty(authHeader) == false && authHeader.StartsWith("Bearer "))
            {
                return(oAuthRequestAuthorizer.TryAuthorize(controller, hasApiKey, IgnoreDb.Urls.Contains(requestUrl), out msg));
            }
            return(windowsRequestAuthorizer.TryAuthorize(controller, IgnoreDb.Urls.Contains(requestUrl), out msg));
        }
        public bool TryAuthorize(RavenBaseApiController controller, out HttpResponseMessage msg)
        {
            var requestUrl = controller.GetRequestUrl();
            if (NeverSecret.IsNeverSecretUrl(requestUrl))
            {
                msg = controller.GetEmptyMessage();
                return true;
            }

            //CORS pre-flight (ignore creds if using cors).
            if (Settings.AccessControlAllowOrigin.Count > 0 && controller.InnerRequest.Method.Method == "OPTIONS")
            {
                msg = controller.GetEmptyMessage();
                return true;
            }

            var oneTimeToken = controller.GetHeader("Single-Use-Auth-Token");
            if (string.IsNullOrEmpty(oneTimeToken))
            {
                oneTimeToken = controller.GetQueryStringValue("singleUseAuthToken");
            }

            if (string.IsNullOrEmpty(oneTimeToken) == false)
            {
                return TryAuthorizeSingleUseAuthToken(controller, oneTimeToken, out msg);
            }

            var authHeader = controller.GetHeader("Authorization");
            var hasApiKey = "True".Equals(controller.GetHeader("Has-Api-Key"), StringComparison.CurrentCultureIgnoreCase);
            var hasOAuthTokenInCookie = controller.HasCookie("OAuth-Token");
            if (hasApiKey || hasOAuthTokenInCookie ||
                string.IsNullOrEmpty(authHeader) == false && authHeader.StartsWith("Bearer "))
            {
                return oAuthRequestAuthorizer.TryAuthorize(controller, hasApiKey, IgnoreDb.Urls.Contains(requestUrl), out msg);
            }
            return windowsRequestAuthorizer.TryAuthorize(controller, IgnoreDb.Urls.Contains(requestUrl), out msg);
        }
示例#10
0
        private static HttpResponseMessage ProvideDebugAuthInfo(RavenBaseApiController controller, object msg)
		{
			string debugAuth = controller.GetQueryStringValue("debug-auth");
			if (debugAuth == null)
				return controller.GetEmptyMessage();

			bool shouldProvideDebugAuthInformation;
			if (bool.TryParse(debugAuth, out shouldProvideDebugAuthInformation) && shouldProvideDebugAuthInformation)
			{
				return controller.GetMessageWithObject(msg);
			}

			return controller.GetEmptyMessage();
		}