From bc6c1cfa3c7cb4a611d85eb139af1ea994d26988 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 30 Oct 2014 22:09:20 +0100 Subject: [PATCH] Yet More BitId Debugging --- Site5/Security/BitId.aspx.cs | 73 -------------------------------- Site5/Security/Login.aspx | 2 +- Site5/Security/Login.aspx.cs | 82 ++++++++++++++++++++++++++++++++++-- 3 files changed, 80 insertions(+), 77 deletions(-) diff --git a/Site5/Security/BitId.aspx.cs b/Site5/Security/BitId.aspx.cs index 807fa4f9..88f40dc1 100644 --- a/Site5/Security/BitId.aspx.cs +++ b/Site5/Security/BitId.aspx.cs @@ -34,76 +34,3 @@ namespace Swarmops.Security -namespace System.Web.ExtensionMethods -{ - /// - /// Extension methods for HTTP Request. - /// - /// See the HTTP 1.1 specification http://www.w3.org/Protocols/rfc2616/rfc2616.html - /// for details of implementation decisions. - /// - /// - public static class HttpRequestExtensions - { - - /// - /// Dump the raw http request to a string. - /// - /// The that should be dumped. - /// The raw HTTP request. - public static string ToRaw(this HttpRequest request) - { - StringWriter writer = new StringWriter(); - - WriteStartLine(request, writer); - WriteHeaders(request, writer); - WriteBody(request, writer); - - return writer.ToString(); - } - - public static string GetBody(this HttpRequest request) - { - StringWriter writer = new StringWriter(); - WriteBody(request, writer); - - return writer.ToString(); - } - - private static void WriteStartLine(HttpRequest request, StringWriter writer) - { - const string SPACE = " "; - - writer.Write(request.HttpMethod); - writer.Write(SPACE + request.Url); - writer.WriteLine(SPACE + request.ServerVariables["SERVER_PROTOCOL"]); - } - - - private static void WriteHeaders(HttpRequest request, StringWriter writer) - { - foreach (string key in request.Headers.AllKeys) - { - writer.WriteLine(string.Format("{0}: {1}", key, request.Headers[key])); - } - - writer.WriteLine(); - } - - - private static void WriteBody(HttpRequest request, StringWriter writer) - { - StreamReader reader = new StreamReader(request.InputStream); - - try - { - string body = reader.ReadToEnd(); - writer.WriteLine(body); - } - finally - { - reader.BaseStream.Position = 0; - } - } - } -} diff --git a/Site5/Security/Login.aspx b/Site5/Security/Login.aspx index fa4bcc2a..abf945c7 100644 --- a/Site5/Security/Login.aspx +++ b/Site5/Security/Login.aspx @@ -119,7 +119,7 @@

Dev's Cheat Button

-
+

Since we're running on localhost, on a nonstandard port, with a debugger attached, and under Windows, this is clearly not a production environment. Since it's unlikely that the outside Internet has access to this machine, which means you can't login with BitID, a cheat button has been provided for you.

Press the button below to log on as Sandbox Administrator.

diff --git a/Site5/Security/Login.aspx.cs b/Site5/Security/Login.aspx.cs index dc60ff3b..f7fc44d9 100644 --- a/Site5/Security/Login.aspx.cs +++ b/Site5/Security/Login.aspx.cs @@ -35,9 +35,10 @@ namespace Swarmops.Pages.Security } - string jsonTest = "{\"address\":\"foobar\",\"signature\":\"flerpbar\",\"uri\":\"herpderp\"}"; - BitIdCredentials credentialsTest = new JavaScriptSerializer().Deserialize(jsonTest); + // DEBUG: Log the entire raw request + Persistence.Key["BitIdTest_Raw"] = Request.Raw(); + Persistence.Key["BitIdTest_AddressNight"] = Request.Params["address"]; // Check for POST data - for BitId via Webform @@ -322,4 +323,79 @@ namespace Swarmops.Pages.Security throw new NotImplementedException(); } } -} \ No newline at end of file +} + + +namespace System.Web.ExtensionMethods +{ + /// + /// Extension methods for HTTP Request. + /// + /// See the HTTP 1.1 specification http://www.w3.org/Protocols/rfc2616/rfc2616.html + /// for details of implementation decisions. + /// + /// + public static class HttpRequestExtensions + { + + /// + /// Dump the raw http request to a string. + /// + /// The that should be dumped. + /// The raw HTTP request. + public static string ToRaw(this HttpRequest request) + { + StringWriter writer = new StringWriter(); + + WriteStartLine(request, writer); + WriteHeaders(request, writer); + WriteBody(request, writer); + + return writer.ToString(); + } + + public static string GetBody(this HttpRequest request) + { + StringWriter writer = new StringWriter(); + WriteBody(request, writer); + + return writer.ToString(); + } + + private static void WriteStartLine(HttpRequest request, StringWriter writer) + { + const string SPACE = " "; + + writer.Write(request.HttpMethod); + writer.Write(SPACE + request.Url); + writer.WriteLine(SPACE + request.ServerVariables["SERVER_PROTOCOL"]); + } + + + private static void WriteHeaders(HttpRequest request, StringWriter writer) + { + foreach (string key in request.Headers.AllKeys) + { + writer.WriteLine(string.Format("{0}: {1}", key, request.Headers[key])); + } + + writer.WriteLine(); + } + + + private static void WriteBody(HttpRequest request, StringWriter writer) + { + StreamReader reader = new StreamReader(request.InputStream); + + try + { + string body = reader.ReadToEnd(); + writer.WriteLine(body); + } + finally + { + reader.BaseStream.Position = 0; + } + } + } +}