DotNetOpenAuth: Debugging and Tracing OpenID and OAuth on ASP.NET (or MVC) using Glimpse

11 July 2011 Off By David

Synopsis: Understanding exactly what is happening under the hood when it comes to working with OpenID and OAuth can be challenging even for the seasoned IDM developer. What I have found to help, is being able to see the communications between all the parties involved. Fortunately the DotNetOpenAuth library can be told to expose a plethora of information to the developer via integrated logging. In this post I will talk about a project called Glimpse that exposes a whole host of information to you, the developer, directly within the browser and then I will introduce a Glimpse plugin I have written that exposes all that lovely juicy information directly from DotNetOpenAuth.

In Short

  1. Get DNOA4Glimpse:
    NuGet Command: PM> Install-Package DCCreative.DNOA4Glimpse

What is Glimpse?
(http://getglimpse.com/About)

WhatIsGlimpseGlimpse is a very cool set of utilities that provide developers with a massive array of how requests go about being served, as well as a host of other information about the server itself.

At its core, Glimpse allows you to debug your web site or web service right in the browser. Glimpse allows you to “Glimpse” into what’s going on in your web server. In other words what Firebug is to debugging your client side code, Glimpse is to debugging your server within the client.

Glimpse is available via NuGet at http://nuget.org/List/Packages/Glimpse.

Exposing DotNetOpenAuth to Glimpse

CropperCapture[2]

Writing a plugin for Glimpse is childsplay. Glimpse exposes a friendly Plugin interface

public interface IGlimpsePlugin
{
	string Name { get; }
	object GetData(HttpContextBase context);
	void SetupInit();
}

Simply inherit from IGlimpsePlugin then implement the members in your plugin.

[GlimpsePlugin]
public class DotNetOpenAuthPlugin : IGlimpsePlugin {
	public void SetupInit() {
	//...
	}
	public string Name {
		get { return "DotNetOpenAuth"; }
	}
}

After adding a reference to the assembly containing your plugin, Glimpse will automatically pick up your plugin (thanks to the wonderful powers of MEF).

Demo

I quickly threw together a sample application to test the plugin.

  1. Create a new ASP.NET MVC site based on the DNOA MVC relying party sample.
  2. Add the DNOA4Glimpse package (Install-Package DCCreative.DNOA4Glimpse)
  3. Done (Get the source here)

CropperCapture[2]

Glimpse has been turned on (by visiting //yourwebsiteurl.example.com/glimpse.axd) which results in a panel being displayed at the bottom of your screen. As you can see, there is a DotNetOpenAuth tab. Awesome!

Right, now – let’s do an OpenID Authentication

CropperCapture[4]

What’s really cool is the Glimpse’s handling of complex objects.

CropperCapture[5]

The presentation of complex objects such as the YADIS services detailed above will improve in a version I am currently working on, thanks for some new presentation features coming to Glimpse soon. Watch this space.

So the plugin is still in beta but hopefully you will find it useful.

DNOA4Glimpse and Demo Source is available at https://github.com/DavidChristiansen/DNOA4Glimpse