From 4c69e5e83459e6ac060701bd943c26e8ee8d1098 Mon Sep 17 00:00:00 2001 From: Alexandre SPIESER Date: Sun, 22 Oct 2017 00:56:23 +0100 Subject: [PATCH 1/5] Update README.md --- README.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d5c0b26..935a9ea 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,16 @@ # AspNetCore.Identity.MongoDbCore A MongoDb UserStore and RoleStore adapter for Microsoft.AspNetCore.Identity 2.0. Allows you to use MongoDb instead of SQL server with Microsoft.AspNetCore.Identity 2.0. + Covered by 737 integration tests and unit tests from the modified [Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test](https://github.com/aspnet/Identity/tree/b865d5878623077eeb715e600d75fa9c24dbb5a1/test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test) test suite. # Usage examples -Your user and role entities must inherit from MongoIdentityUser and MongoIdentityRole in a way similar to the IdentityUser and the IdentityRole in Microsoft.AspNetCore.Identity. +Your user and role entities must inherit from MongoIdentityUser and MongoIdentityRole in a way similar to the IdentityUser and the IdentityRole in Microsoft.AspNetCore.Identity. Here is an example: ```csharp - public class ApplicationRole : MongoIdentityRole - { - public ApplicationRole() : base() - { - } - - public ApplicationRole(string roleName) : base(roleName) - { - } - } - public class ApplicationUser : MongoIdentityUser { public ApplicationUser() : base() @@ -31,7 +21,20 @@ Here is an example: { } } + + public class ApplicationRole : MongoIdentityRole + { + public ApplicationRole() : base() + { + } + + public ApplicationRole(string roleName) : base(roleName) + { + } + } ``` +The Id field is automatically set at instanciation, this also applies to users inheriting from MongoIdentityUser, where a random integer is assigned to the Id. It is however not advised to rely on such random mechanism to set the primary key of your document. Using documents inheriting from `MongoIdentityRole` is recommended. + The configuration is done by populating a `MongoDbIdentityConfiguration` object, which can have an `IdentityOptionsAction` property set to an action you want to perform against the `IdentityOptions` (`Action`). The `MongoDbSettings` object is used to set MongoDb Settings using the `ConnectionString` and the `DatabaseName` properties. From 0ebee24219eecfc48b3f16c08912f3fb569c01c4 Mon Sep 17 00:00:00 2001 From: Alexandre SPIESER Date: Sun, 22 Oct 2017 00:57:04 +0100 Subject: [PATCH 2/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 935a9ea..d4cf780 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Here is an example: The Id field is automatically set at instanciation, this also applies to users inheriting from MongoIdentityUser, where a random integer is assigned to the Id. It is however not advised to rely on such random mechanism to set the primary key of your document. Using documents inheriting from `MongoIdentityRole` is recommended. The configuration is done by populating a `MongoDbIdentityConfiguration` object, which can have an `IdentityOptionsAction` property set to an action you want to perform against the `IdentityOptions` (`Action`). + The `MongoDbSettings` object is used to set MongoDb Settings using the `ConnectionString` and the `DatabaseName` properties. The MongoDb connection is managed using the [mongodb-generic-repository](https://github.com/alexandre-spieser/mongodb-generic-repository), where a repository inheriting `IBaseMongoRepository` is registered as a singleton. Look at the [ServiceCollectionExtension.cs](https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore/blob/master/src/Extensions/ServiceCollectionExtension.cs) file for more details. From 5ed5778e4fda4afd1e8860f216424e1beb1ee1da Mon Sep 17 00:00:00 2001 From: Alexandre SPIESER Date: Sun, 22 Oct 2017 00:59:42 +0100 Subject: [PATCH 3/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d4cf780..e25dd1d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Here is an example: } } ``` -The Id field is automatically set at instanciation, this also applies to users inheriting from MongoIdentityUser, where a random integer is assigned to the Id. It is however not advised to rely on such random mechanism to set the primary key of your document. Using documents inheriting from `MongoIdentityRole` is recommended. +The `Id` field is automatically set at instanciation, this also applies to users inheriting from `MongoIdentityUser`, where a random integer is assigned to the `Id`. It is however not advised to rely on such random mechanism to set the primary key of your document. Using documents inheriting from `MongoIdentityRole` is recommended. The configuration is done by populating a `MongoDbIdentityConfiguration` object, which can have an `IdentityOptionsAction` property set to an action you want to perform against the `IdentityOptions` (`Action`). @@ -60,6 +60,7 @@ The MongoDb connection is managed using the [mongodb-generic-repository](https:/ // add a global config object services.AddSingleton(Configuration); + // get the MongoDb settings from the Configuration object. var settings = Configuration.GetSection(nameof(MongoDbSettings)).Get(); var mongoDbIdentityConfiguration = new MongoDbIdentityConfiguration { @@ -76,7 +77,6 @@ The MongoDb connection is managed using the [mongodb-generic-repository](https:/ options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(30); options.Lockout.MaxFailedAccessAttempts = 10; - // ApplicationUser settings options.User.RequireUniqueEmail = true; options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.-_"; From 307c31ec311b0b3632a1c76d109f771f561e5c73 Mon Sep 17 00:00:00 2001 From: Alexandre SPIESER Date: Sun, 22 Oct 2017 01:02:20 +0100 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e25dd1d..b12d567 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ BTC Donations: 1Qc5ZpNA7g66KEEMcz7MXxwNyyoRyKJJZ *Thank you for your support and generosity!* ## License -mongodb-generic-repository is under MIT license - http://www.opensource.org/licenses/mit-license.php +AspNetCore.Identity.MongoDbCore is under MIT license - http://www.opensource.org/licenses/mit-license.php The MIT License (MIT) From c5bbcd8594a2f197c2244eb5f4247d6b2389016f Mon Sep 17 00:00:00 2001 From: Alexandre SPIESER Date: Sun, 22 Oct 2017 01:06:03 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b12d567..528ba31 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ The MongoDb connection is managed using the [mongodb-generic-repository](https:/ ## Donations Feeling like my work is worth a coffee? Donations are welcome and will go towards further development of this project as well as other MongoDb related projects. Use the wallet address below to donate. -BTC Donations: 1Qc5ZpNA7g66KEEMcz7MXxwNyyoRyKJJZ +BTC Donations: 1FDMWqSK8SHXDGKKp7gyZc4rknynWJ7qbj *Thank you for your support and generosity!*