ASP.NET Identity provider that uses Redis for storage
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.nuget Initial Commit Jan 11, 2014
Redis.AspNet.Identity
.gitattributes Initial Commit Jan 11, 2014
.gitignore
LICENSE Initial commit Jan 11, 2014
README.md bug fix for namepsace Jan 12, 2014
Redis.AspNet.Identity.sln

README.md

Redis.AspNet.Identity

ASP.NET Identity provider that uses Redis for storage and works with VS2013 Default SPA Template

Purpose

ASP.NET MVC 5 shipped with a new Identity system (in the Microsoft.AspNet.Identity.Core package) in order to support both local login and remote logins via OpenID/OAuth, but only ships with an Entity Framework provider (Microsoft.AspNet.Identity.EntityFramework).

Features

  • Drop-in replacement ASP.NET Identity with Redis as the backing store.
  • Requires only 2 key-value types, while EntityFramework requires 5 tables
  • Contains the same IdentityUser class used by the EntityFramework provider in the MVC 5 project template.
  • Supports additional profile properties on your application's user model.
  • Provides UserStore implementation that implements the same interfaces as the EntityFramework version:
    • IUserStore
    • IUserLoginStore
    • IUserRoleStore
    • IUserClaimStore
    • IUserPasswordStore
    • IUserSecurityStampStore

Instructions

These instructions assume you know how to set up Redis within an Web-API/MVC application.

  1. Create a new ASP.NET MVC 5 project, choosing the Individual User Accounts authentication type.
  2. Remove the Entity Framework packages and replace with Redis Identity:
Uninstall-Package Microsoft.AspNet.Identity.EntityFramework
Uninstall-Package EntityFramework
Install-Package Redis.AspNet.Identity
  1. In ~/Providers/ApplicationOAuthProvider.cs ~/Controllers/AccountController.cs ~/App_Start/Startup.Auth.cs

    • Remove the namespace: Microsoft.AspNet.Identity.EntityFramework
    • Add the namespace: Redis.AspNet.Identity
  2. In ~/App_Start/Startup.Auth.cs

    • Replace "IdentityUserLogin" with "UserLoginInfo"
    • Remove the namespace: Microsoft.AspNet.Identity.EntityFramework
    • Add the new RedisClient with proper Connection String to the constructor of the UserStore.
static Startup(){
	...
	UserStore<IdentityUser>.AppNamespace = "urn:app:";
	UserManagerFactory = () => 
		new UserManager<IdentityUser>(
			new UserStore<IdentityUser>(
				new RedisClient("localhost",6379)));
}

Notes: When you have added your IoC, you should replace it here with an instance of IRedisClientsManager More details on using client factories

Thanks To

Special thanks to David Boike for RavenDB AspNet Identity and InspectorIT for MongoDB.AspNet.Identity that gave me the base for starting the Redis provider