public static RaygunRequestMessage Build(OwinEnvironment environment) { var request = new OwinRequest(environment); // ToDo: limit querystring, form, and header values to 256 characters var message = new RaygunRequestMessage(); message.HostName = request.Host.Value; message.Url = request.Uri.AbsolutePath; message.HttpMethod = request.Method; message.IPAddress = request.RemoteIpAddress; // ToDo: bring this up to par with the official client // ToDo: filter querystring values message.QueryString = request.Query.ToDictionary(_ => _.Key, _ => string.Join(", ", _.Value)); // ToDo: filter form values (add 'password' by default?) message.Form = request.ReadForm().ToDictionary(_ => _.Key, _ => string.Join(", ", _.Value)); // ToDo: filter headers message.Headers = request.Headers.ToDictionary(_ => _.Key, _ => string.Join(", ", _.Value)); message.Headers.Remove("Cookie"); message.Cookies = GetCookies(request.Cookies); if (request.ContentType != "text/html" && request.ContentType != "application/x-www-form-urlencoded" && request.Method != "GET") { var text = request.BodyAsString(); message.RawData = text.Substring(0, Math.Min(4096, text.Length)); } message.Data = GetData(request).Where(_ => _.Value != null).ToDictionary(_ => _.Key, _ => _.Value); return(message); }
/// <summary> /// Inspects the environment and checks to see if this is a POST containing the HTML form fields in the login.html page. /// </summary> /// <param name="environment"></param> /// <param name="formsAuthenticationProvider"></param> public LoginContext(IDictionary <string, object> environment, FormsAuthenticationProvider formsAuthenticationProvider) { _environment = environment; Request = new OwinRequest(environment); Response = new OwinResponse(environment); _formsAuthenticationProvider = formsAuthenticationProvider; _responseStream = Response.Body; var requestContentType = Request.GetHeader("Content-Type"); _isFormUrlEncodedPost = Request.Method == "POST" && !string.IsNullOrEmpty(requestContentType) && requestContentType.StartsWith("application/x-www-form-urlencoded"); if (_isFormUrlEncodedPost && Request.Body != null) { _formData = Request.ReadForm().Result; var username = _formData["login_username"]; var password = _formData["login_password"]; var rememberMe = _formData["remember_me"] != null && _formData["remember_me"] == "yes"; if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { environment["formsauthn.username"] = username; environment["formsauthn.password"] = password; environment["formsauthn.remember"] = rememberMe; } } }