Giter VIP home page Giter VIP logo

nhibernate.aspnet.identity's Introduction

Build status Stories in Ready

NHibernate.AspNet.Identity

ASP.NET Identity provider that uses NHibernate for storage

Throughput Graph

About this

About this

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 NHibernate as the backing store.
  • Based on same schema required by EntityFramework for compatibility model
  • 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

Quick-start guide

These instructions assume you know how to set up NHibernate within an 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 NHibernate Identity:
Uninstall-Package Microsoft.AspNet.Identity.EntityFramework
Uninstall-Package EntityFramework
Install-Package NHibernate.AspNet.Identity
  1. In ~/Models/IdentityModels.cs:

    • Remove the namespace: Microsoft.AspNet.Identity.EntityFramework
    • Add the namespace: NHibernate.AspNet.Identity
    • Remove the ApplicationDbContext class completely.
  2. In ~/Controllers/AccountController.cs

    • Remove the namespace: Microsoft.AspNet.Identity.EntityFramework
    • Add the relevant ISession implementation that will be used by default. This could be from a DI implementation. Note: This isn't mandatory, if you are using a framework that will inject the dependency, you shouldn't need the parameterless constructor.
  3. Setup configuration code

NHibernate

	// this assumes you are using the default Identity model of "ApplicationUser"
	var myEntities = new [] {
		typeof(ApplicationUser)
	};
	
    var configuration = new Configuration();
    configuration.Configure("sqlite-nhibernate-config.xml");
    configuration.AddDeserializedMapping(MappingHelper.GetIdentityMappings(myEntities), null);

    var factory = configuration.BuildSessionFactory();
    var session = factory.OpenSession();

    var userManager = new UserManager<ApplicationUser>(
        new UserStore<ApplicationUser>(session);

FluentNHibernate

	// this assumes you are using the default Identity model of "ApplicationUser"
	var myEntities = new [] {
		typeof(ApplicationUser)
	};
	
	var configuration = Fluently.Configure()
	   .Database(/*.....*/)
	   .ExposeConfiguration(cfg => {
	       cfg.AddDeserializedMapping(MappingHelper.GetIdentityMappings(myEntities), null);
		});
	
    var factory = configuration.BuildSessionFactory();
    var session = factory.OpenSession();

    var userManager = new UserManager<ApplicationUser>(
        new UserStore<ApplicationUser>(session);

Thanks To

Special thanks to David Boike whos RavenDB AspNet Identity project gave me the base for jumpstarting the NHibernate provider

nhibernate.aspnet.identity's People

Contributors

hazzik avatar lnu avatar martinjt avatar milesibastos avatar omainegra avatar romanpohorecki avatar waffle-iron avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.