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; }
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; }
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; }
public LogsPushContent(RavenBaseApiController controller) { Connected = true; Id = controller.GetQueryStringValue("id"); if (string.IsNullOrEmpty(Id)) throw new ArgumentException("Id is mandatory"); }
public LogsPushContent(RavenBaseApiController controller) { Connected = true; Id = controller.GetQueryStringValue("id"); if (string.IsNullOrEmpty(Id)) { throw new ArgumentException("Id is mandatory"); } }
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()); }
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); }
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(); }