• Stars
    star
    196
  • Rank 198,553 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 11 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A mongodb provider for the new ASP.NET Identity framework.

Microsoft.AspNetCore.Identity.MongoDB

This is a MongoDB provider for the ASP.NET Core Identity framework. This was ported from the v2 Identity framework that was a part of ASP.NET (AspNet.Identity.Mongo NuGet package)

I've released a new package for the ASP.NET Core Identity framework for the following reasons:

  • Discoverability - named AspNetCore.
  • ASP.NET Core is a rewrite of ASP.NET, this Core Identity framework won't run on traditional ASP.NET.
  • Migrating isn't a matter of updating dependencies.

This project has extensive test coverage.

If you want something easy to setup, this adapter is for you. I do not intend to cover every possible desirable configuration, if you don't like my decisions, write your own adapter. Use this as a learning tool to make your own adapter. These adapters are not complicated, but trying to make them configurable would become a complicated mess. And would confuse the majority of people that want something simple to use. So I'm favoring simplicity over making every last person happy.

Usage

  • Reference this package in project.json: Microsoft.AspNetCore.Identity.MongoDB
  • Then, in ConfigureServices--or wherever you are registering services--include the following to register both the Identity services and MongoDB stores:
services.AddIdentityWithMongoStores("mongodb://localhost/myDB");
  • If you want to customize what is registered, refer to the tests for further options (CoreTests/MongoIdentityBuilderExtensionsTests.cs)
  • Remember with the Identity framework, the whole point is that both a UserManager and RoleManager are provided for you to use, here's how you can resolve instances manually. Of course, constructor injection is also available.
var userManager = provider.GetService<UserManager<IdentityUser>>();
var roleManager = provider.GetService<RoleManager<IdentityRole>>();
  • The following methods help create indexes that will boost lookups by UserName, Email and role Name. These have changed since Identity v2 to refer to Normalized fields. I dislike this aspect of Core Identity, but it is what it is. Basically these three fields are stored in uppercase format for case insensitive searches.
	IndexChecks.EnsureUniqueIndexOnNormalizedUserName(users);
	IndexChecks.EnsureUniqueIndexOnNormalizedEmail(users);
	IndexChecks.EnsureUniqueIndexOnNormalizedRoleName(roles);
  • Here is a sample project, review the commit log for the steps taken to port the default template from EntityFramework MSSQL to MongoDB. aspnet-identity-mongo-sample.

What frameworks are targeted, with rationale:

  • Microsoft.AspNetCore.Identity - supports net451 and netstandard1.3
  • MongoDB.Driver v2.3 - supports net45 and netstandard1.5
  • Thus, the lowest common denominators are net451 (of net45 and net451) and netstandard1.5 (of netstandard1.3 and netstandard1.5)
  • FYI net451 supports netstandard1.2, that's obviously too low for a single target

Building instructions

run commands in

Migrating from ASP.NET Identity 2.0

  • Roles names need to be normalized as follows
    • On IdentityRole documents, create a NormalizedName field = uppercase(Name). Leave Name as is.
    • On IdentityUser documents, convert the values in the Roles array to uppercase
  • User names need to be normalized as follows
    • On IdentityUser documents, create a NormalizedUserName field = uppercase(UserName) and create a NormalizedEmail field = uppercase(Email). Leave UserName and Email as is.

More Repositories

1

consul-getting-started

This is a sample repo of examples for getting started with Consul. It even includes a multi datacenter example with 14 VMs to allow you to simulate failures in a multi DC environment!
Shell
80
star
2

optimizing-web-apps-webpack

Code samples for my webpack course series
JavaScript
78
star
3

aspnetcore-generator-api

Sample ASP.NET Core API that generates random data, has swagger UI too
C#
73
star
4

course-ansible-getting-started

Files for my course on Getting Started with Ansible
Python
66
star
5

course-jenkins-getting-started

Jenkins Getting Started (jgsu) Course Materials - An update to my initial version of the course
Groovy
65
star
6

Rx-FileSystemWatcher

A set of reactive/observable wrappers around the FileSystemWatcher.
C#
57
star
7

aspnet-identity-mongo-sample

A sample of the identity provider, transformed for MongoDB instead of EntityFramework
C#
53
star
8

docker-swarm-mode-getting-started

Repository for my Pluralsight course Getting Started with Docker Swarm Mode
Shell
39
star
9

solitaire-systemjs-course

Starting sample project for my Pluralsight course on SystemJS/jspm
JavaScript
39
star
10

pluralsight-modern-async-js

This is the starting point and the step by step commits that correspond to my course: Modern Asynchronous JavaScript
JavaScript
37
star
11

webpack-stats-graph

Generate a graph to visualize modules and bundles from webpack via stats.json
JavaScript
32
star
12

es6-in-motion

JavaScript
30
star
13

jgsu-spring-petclinic

WIP update of spring-petclinic example used in my Jenkins Getting Started course on Pluralsight
Java
25
star
14

course-implementing-self-hosted-docker-registry

Shell
17
star
15

course-managing-docker-linux-servers

Shell
16
star
16

course3-jenkins-gs

Getting Started with Jenkins (3rd Edition) course @Pluralsight
8
star
17

pluralsight-dotnet-core-xplat-apps

Files for my Pluralsight course dotnet-core-building-cross-platform-applications
C#
7
star
18

course2-swarm-gs

Getting Started with Docker Swarm (Mode) - 2nd Edition as of 2021
Shell
7
star
19

course2-ansible-gs

Getting Started with Ansible (refresh/2nd edition)
Jinja
7
star
20

pluralsight-dotnet-core-windows

Examples from my course Getting Started with .NET Core for Windows Developers
C#
6
star
21

docker-mongo-sample-datasets

Shell
6
star
22

pluralsight-aspdotnet-core-msbuild-tooling

C#
6
star
23

course2-consul-gs

Getting Started with (Hashicorp) Consul - 2nd Edition - 2022
JavaScript
5
star
24

teamcity-course-aspnet-identity-mongo

Repository for my TeamCity Getting Started Course
C#
5
star
25

docker-static-binary

An example of baking a static linked linux binary into a container alone with nothing else
Shell
5
star
26

docker-dotnet-email-example

C#
4
star
27

tsqlmigrations

C#
4
star
28

course3-jenkins-gs-spring-petclinic

For Course3 Jenkins Getting Started - fork of https://github.com/spring-projects/spring-petclinic
CSS
4
star
29

ExpectEx

Better test messages through use of Expressions..
C#
4
star
30

pluralsight-deploying-aspdotnet-core-apps-docker

Course files.
C#
4
star
31

vagrant-try-web-starter-kit

An environment to give the Google Web Starter Kit a spin without worrying about how to set it up within your own environment.
Shell
3
star
32

course2-vagrant-gs

Getting Started with Vagrant (refresh/2nd edition)
Shell
3
star
33

QuickFix.Log4Net

Log4Net logging adapters for QuickFix
C#
3
star
34

homebrew-tap

Custom tap of formulas
Ruby
3
star
35

course3-docker-win-gs

3
star
36

term-chat-ollama

Hack Term Chat to use ollama+codellama, OpenAI, groq.com, etc (any OpenAI compat completions API)
C#
3
star
37

Presentations

My presentations
C#
2
star
38

jenkins-bootstrapped

A docker image with jenkins pre-configured for learning/testing/development purposes, NOT PRODUCTION
Groovy
2
star
39

teamcity-course-spring-petclinic

Repository for my TeamCity Getting Started Course
Java
2
star
40

g0t4

Profile Repo
2
star
41

course2-docker-windows-gs

Files for Docker Getting Started on Windows Course!
PowerShell
2
star
42

docker-windows-sysinternals

Docker images with sysinternals baked in for spelunking what's going on inside windows containers.
PowerShell
2
star
43

netstandard-with-native-interop

Example of using native interop with .NET Standard
C#
2
star
44

docker-manifest-tool

Docker image for https://github.com/estesp/manifest-tool
2
star
45

pwsh-abbr

Expanding abbreviations for powershell - like fish shell
PowerShell
2
star
46

course2-mdls

Shell
2
star
47

Settings

1
star
48

microsoft-extensions-caching-mongodb

A MongoDB distributed cache for .NET
C#
1
star
49

GotFour.Windsor

My extensions to windsor, enjoy
C#
1
star
50

OlyCalculator

Oly lifting calculator
JavaScript
1
star
51

teamcity-branches

A repo to demonstrate branching features of builds in team city
JavaScript
1
star
52

ruby-learnings

A place to put my experiments with ruby and to help me refer back to common features I use
PowerShell
1
star
53

docker-ffmpeg

1
star
54

consistent-code

A sample code base to demonstrate consistent formatting of code and tools that can help.
C#
1
star
55

docker-angular2-todomvc

1
star
56

PivotalAllProjectSearchPlugin

Show your own stories and search across pivotal projects
JavaScript
1
star
57

docker-workshop

Makefile
1
star
58

docker-registry-reproduce-2094

Shell
1
star
59

oreilly-nodejs-mongodb

The starting point for my course explaining how to use mongodb with nodejs and express.
JavaScript
1
star
60

blog-samples

Samples for blog posts
C#
1
star
61

docker-consul

Images for tools used in concert with consul
1
star
62

solitaire-site

JavaScript
1
star
63

js-tc-demo

JavaScript
1
star
64

vagrant-teamcity

Shell
1
star
65

javascript-aesthetics

This is a repository of code samples that I use in my course on the aesthetics of JavaScript.
1
star
66

teamcity-course-cards

A javascript example for my TeamCity Getting Started course
JavaScript
1
star
67

MonitoringTests

A set of sample code for creating simple monitoring tests in an application to let the application tell you when your assumptions are violated or when run time assertions that are significant are not met.
C#
1
star
68

course-jenkins-k8s

Groovy
1
star
69

course-nginx-gs

Dockerfile
1
star
70

course-gh-actions

HCL
1
star
71

dotfiles

migrating my dotfiles (esp zsh) here
Shell
1
star
72

docker-cheat

docker image for cheat: https://github.com/chrisallenlane/cheat
1
star