Coder Social home page Coder Social logo

cerilewis / aspnetcore.identity.mongo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matteofabbri/aspnetcore.identity.mongo

0.0 2.0 0.0 23.85 MB

This is a MongoDB provider for the ASP.NET Core 2 Identity framework

Home Page: https://matteofabbri.org

License: MIT License

C# 100.00%

aspnetcore.identity.mongo's Introduction

AspNetCore.Identity.Mongo NuGet

This is a MongoDB provider for the ASP.NET Core Identity framework. It is completely written from scratch and provides support for all Identity framework interfaces:

  • IUserClaimStore
  • IUserLoginStore
  • IUserRoleStore
  • IUserPasswordStore
  • IUserSecurityStampStore
  • IUserEmailStore
  • IUserPhoneNumberStore
  • IQueryableUserStore
  • IUserTwoFactorStore
  • IUserLockoutStore
  • IUserAuthenticatorKeyStore
  • IUserAuthenticationTokenStore
  • IUserTwoFactorRecoveryCodeStore
  • IProtectedUserStore
  • IRoleStore
  • IRoleClaimStore
  • IQueryableRoleStore

Dot Net Core Versions support

Library supports .Net 5.0, .Net Core 3.1, .Net Core 2.1 simultaneously started from 8.3.0 nuget package.

How to use:

AspNetCore.Identity.Mongo is installed from NuGet:

Install-Package AspNetCore.Identity.Mongo

The simplest way to set up:

using AspNetCore.Identity.Mongo;
using AspNetCore.Identity.Mongo.Model;

// At the ConfigureServices section in Startup.cs
services.AddIdentityMongoDbProvider<MongoUser>();

With Identity and Mongo options:

using AspNetCore.Identity.Mongo;
using AspNetCore.Identity.Mongo.Model;

// At the ConfigureServices section in Startup.cs
services.AddIdentityMongoDbProvider<MongoUser>(identity =>
   {
       identity.Password.RequiredLength = 8;
       // other options
   } ,
   mongo =>
   {
       mongo.ConnectionString = "mongodb://127.0.0.1:27017/identity";
       // other options
   });

Using User and Role models:

using AspNetCore.Identity.Mongo;
using AspNetCore.Identity.Mongo.Model;

// At the ConfigureServices section in Startup.cs
services.AddIdentityMongoDbProvider<MongoUser, MongoRole>(identity =>
    {
        identity.Password.RequiredLength = 8;
        // other options
    },
    mongo =>
    {
        mongo.ConnectionString = "mongodb://127.0.0.1:27017/identity";
        // other options
    });

Using different type of the primary key (default is MongoDB.Bson.ObjectId):

using AspNetCore.Identity.Mongo;
using AspNetCore.Identity.Mongo.Model;

public class ApplicationUser : MongoUser<string>
{
}

public class ApplicationRole : MongoRole<string>
{
}

// At the ConfigureServices section in Startup.cs
services.AddIdentityMongoDbProvider<ApplicationUser, ApplicationRole, string>(identity =>
    {
        identity.Password.RequiredLength = 8;
        // other options
    },
    mongo =>
    {
        mongo.ConnectionString = "mongodb://127.0.0.1:27017/identity";
        // other options
    });

To add the stores only, use:

using AspNetCore.Identity.Mongo;
using AspNetCore.Identity.Mongo.Model;

// At the ConfigureServices section in Startup.cs
services
    .AddIdentityCore<MongoUser>()
    .AddRoles<MongoRole>()
    .AddMongoDbStores<MongoUser, MongoRole, ObjectId>(mongo =>
    {
        mongo.ConnectionString = "mongodb://127.0.0.1:27017/identity";
        // other options
    })
    .AddDefaultTokenProviders();

Migration from lower versions

New releases could/will have the breaking changes.

Folder docs contains migration guides. E.g.:

There you can find information how to migrate from 6.0.0-6.3.5 to 6.7.x version.
There you can find information how to migrate from 3.1.5 to 6.7.x version.

If you have different version of the library and want to update it, please create a new issue. We will try to help you or will create new instruction.

How to Contribute

Before create any issue/PR please look at the CONTRIBUTING

Code of conduct

See CODE_OF_CONDUCT

License

This project is licensed under the MIT license

aspnetcore.identity.mongo's People

Contributors

7kronos avatar artem-kovalev avatar brikibsw avatar cerilewis avatar daviddesmet avatar dnemtsov avatar fadihania avatar haseeb200 avatar ill35t avatar infl3x avatar lenwen avatar malachib avatar matteofabbri avatar vburyy-lionwoood avatar vova3211 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.