Scott Hanselman

Thinktecture.IdentityManager as a replacement for the ASP.NET WebSite Administration tool

June 17, 2014 Comment on this post [13] Posted in ASP.NET | Open Source
Sponsored By

In ASP.NET 2005 (v2 timeframe) there was a web-based tool called ASP.NET Website Administration tool that folks could use the edit users and generally administer the ASP.NET Membership database. This useful tool was removed in 2012 and is still missed.

Since then, ASP.NET has introduced ASP.NET Identity and community member Brock Allen created IdentityReboot with some significant improvements and extensions. Brock Allen and Dominick Baier have gone even further and created Thinktecture IdentityManager. It's the beginnings of a nice bootstrapped replacement for the missing ASP.NET Website Administration Tool. It's nicely factored and supports both ASP.NET Identity and their alternative called MembershipReboot.

I cloned Thinktecture.IdentityManager and ran it under Visual Studio 2013.2. It's nice when projects just clone cleanly and build. You'd be surprised how often that's not the case.

Thinktecture.IdentityManager plugs into the ASP.NET middleware pipeline, so switching the sample host to use ASP.NET Identity rather than their alternative MembershipReboot was as easy as commenting out a line and adding a line as seen below.

public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseIdentityManager(new IdentityManagerConfiguration()
{
//UserManagerFactory = Thinktecture.IdentityManager.MembershipReboot.UserManagerFactory.Create
UserManagerFactory = Thinktecture.IdentityManager.AspNetIdentity.UserManagerFactory.Create
});
}
}

Just run it and you'll get a nice Bootstrapped interface for creating, editing, and deleting users from your Identity database.

Identity Manager

Here you can see those same users in the SQL database that ASP.NET Identity uses.

There's the users created in the identity database

The whole application is written as a Single Page Application with an ASP.NET Web API handling the backend with Angular.js on the frontend.. You could run this application as it's own site and lock it down, of course, or host it within your existing website at something like /admin.

Serving Embedded Assets

Unrelated to the core functionality of Thinktecture.IdentityManager, one cool piece of functionality worth noting is how they are storing the HTML, CSS and other resources as embedded resources inside the Thinktecture.IndeityManager.Core assembly. This is not something you'd necessarily want to do yourself, but considering that they've got a nice embedded "manager" that they'll want to plug into other websites easily without causing issues with file dependencies, it's quite clever.

Here's the static page controller:

public class PageController : ApiController
{
[Route("")]
[HttpGet]
public IHttpActionResult Index()
{
return new EmbeddedHtmlResult(Request, "Thinktecture.IdentityManager.Core.Assets.Templates.index.html");
}
}

Then later in EmbeddedHtmlResult:

public static HttpResponseMessage GetResponseMessage(HttpRequestMessage request, string name)
{
var root = request.GetRequestContext().VirtualPathRoot;
var html = AssetManager.LoadResourceString(name);
return new HttpResponseMessage()
{
Content = new StringContent(html, Encoding.UTF8, "text/html")
};
}

Then later, all the CSS and JS are handled by the ".UseFileServer()" extension from Microsoft.Owin.StaticFiles, and then Microsoft.Owin.FileSystems handles the mapping the whole of the /assets URI space over all the resources

app.UseFileServer(new FileServerOptions
{
RequestPath = new PathString("/assets"),
FileSystem = new EmbeddedResourceFileSystem(typeof(AppBuilderExtensions).Assembly, "Thinktecture.IdentityManager.Core.Assets")
});
app.UseFileServer(new FileServerOptions
{
RequestPath = new PathString("/assets/libs/fonts"),
FileSystem = new EmbeddedResourceFileSystem(typeof(AppBuilderExtensions).Assembly, "Thinktecture.IdentityManager.Core.Assets.Content.fonts")
});

It's nice and clean, and a cool reminder about what you can do with a nicely factored system and a decent middleware pipeline.

A bright future

If you've got a ASP.NET system and are looking for a flexible and simple web-based administration tool for your Identity system, you should totally check out Thinktecture.IdentityManager. It looks like the team is gearing up for the possible release of this project as NuGet, so may have that to look forward to as well!

Remember that when people create cool projects like this, they are often doing this as volunteers out of the kindness of their hearts. They are often looking for feedback and comments, sure, but also validation of their idea as well as help. Open source help can come in the form of Pull Requests, Bugs and Issues, Documentation, Build Servers, and more. Head over and "star" the GitHub Thinktecture.IdentityManager project, and check it out!

Related Links


Sponsor: A big thank you to my friends at Octopus Deploy. They are sponsoring the blog feed this week. Using NuGet and powerful conventions, Octopus Deploy makes it easy to automate releases of ASP.NET applications and Windows Services. Say goodbye to remote desktop and start automating today!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
June 17, 2014 11:05
Hi Scott, I did not want to touch any of my formauthentication stuff and did not want to downgrade to vs 2012 or 2010. Here is how you can manually start iis express for the administration tool:

iisexpress.exe /path:C:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles /vpath:"/webadmin" /port:12345 /clr:4.0 /ntlm

and then in your browser:
http://localhost:12345/webadmin/default.aspx?applicationPhysicalPath=C:\Path\to\your\webformapplication\&applicationUrl=/

I blogged about it here http://www.jphellemons.nl/post/missing-aspnet-webadmin-configuration-option-in-visual-studio-2013
June 17, 2014 11:06
Can't edit my post, but I wanted to give you thumbs up for the new identitymanager. Just wanted to give some info for people with old code like me. I really like the new asp.net identity.
June 17, 2014 11:11
ASP.NET middleware pipeline


*cough* owin middleware pipeline :)

Nice stuff from the ThinkTecture folks as usual.
June 18, 2014 10:47
Scott, What is the best way to keep track of all these wonderful open source stuff? So that we can use them as the need arises... How do you do it?
June 18, 2014 22:42
Hi Scott, I'm creating very similar project but not only for identity managing, but for all entities, something like django admin or active admin for rails.
Ilaro.Admin has more complex configuration, but thanks that is also more flexible, more info about it you can find on github.
Unfortunately there is a lot of stuff to do and probably there are many of bugs so Thinktecture.IdentityManager for now is better solution for identity management, but for everything else you can use Ilaro.Admin.

My project it's also open source, so I would be very happy for any advise and help in creating it.

I'm sorry for this little advertisement, but I believe that my comment is valuable and can help someone.
June 19, 2014 7:39
Thank you! It has been about 2 years since I have written an ASP.NET application and it was very eye-opening how much has changed in that period. I had to relearn so much and get rid of a few bad habits, and I am still putting all the pieces together with some aspects of ASP.NET, ESPECIALLY Identity. There still seems to be an almost complete lack of documentation regarding Identity implementation or migration of Forms authentication to Identity :( Any recommendations?
June 19, 2014 19:47
@Scott Simontis,

Please check out the following section for migrating to ASP.NET Identity from Sql Membership http://www.asp.net/identity/overview/migrations

Also http://www.asp.net/identity/overview/getting-started has some good tutorials which give you an overview of Identity and how to get started with Identity in an Empty Application.
June 21, 2014 11:09
MembershipReboot is awesome. I'm using it in the project I am working on right now. Absolutely kills ASP Identity.
June 25, 2014 3:19
@Scott Thanks for the post.

@Dave Thanks for the kind words.
June 27, 2014 19:31
How can I integrate this in a WebMatrix application?
July 26, 2014 1:04
Hi dear Scott.
This is an awesome solution for people who love old security tool:
ASP.NET Website Administrator Tool in VS 2013
Regards.
September 08, 2014 17:51
As an update, beta 1 of IdentityManager has been released:

http://brockallen.com/2014/09/08/thinktectre-identitymanager-beta-1/
September 09, 2014 18:13
Hi Scott

We are stuck on .Net 4.0 for the moment any suggestions on how we can integrate the new tools in .Net 4.5.

Thanks

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.