コード例 #1
0
ファイル: ChangesPushContent.cs プロジェクト: cocytus/ravendb
        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
ファイル: LogPushContent.cs プロジェクト: GorelH/ravendb
        public LogsPushContent(RavenBaseApiController controller)
		{
			Connected = true;
			Id = controller.GetQueryStringValue("id");
            
			if (string.IsNullOrEmpty(Id))
				throw new ArgumentException("Id is mandatory");
		}
コード例 #5
0
ファイル: LogPushContent.cs プロジェクト: xinix00/ravendb
        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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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();
		}