Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 10804

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

$
0
0

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!



© 2014 Scott Hanselman. All rights reserved.
     

Viewing all articles
Browse latest Browse all 10804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>