diff --git a/.gitignore b/.gitignore
index c99ff6a..827bbf5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -296,4 +296,6 @@ __pycache__/
*.btp.cs
*.btm.cs
*.odx.cs
-*.xsd.cs
\ No newline at end of file
+*.xsd.cs
+sample/MongoIdentitySample.Mvc/appsettings.local.json
+test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.local.json
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..43ad75d
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,34 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (web)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ "program": "${workspaceFolder}/sample/MongoIdentitySample.Mvc/bin/Debug/netcoreapp3.1/MongoIdentitySample.Mvc.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}/sample/MongoIdentitySample.Mvc",
+ "stopAtEntry": false,
+ "serverReadyAction": {
+ "action": "openExternally",
+ "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
+ },
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "sourceFileMap": {
+ "/Views": "${workspaceFolder}/Views"
+ }
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..171633c
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,42 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "${workspaceFolder}/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 0000000..e763091
--- /dev/null
+++ b/azure-pipelines.yml
@@ -0,0 +1,58 @@
+
+trigger:
+- master
+
+pool:
+ vmImage: 'ubuntu-latest'
+
+variables:
+ solution: '**/*.sln'
+ buildPlatform: 'Any CPU'
+ buildConfiguration: 'Release'
+
+steps:
+
+- task: UseDotNet@2
+ displayName: 'Install .net core 3.1'
+ inputs:
+ packageType: 'sdk'
+ version: '3.1.101'
+
+- task: NuGetToolInstaller@1
+
+- task: NuGetCommand@2
+ displayName: 'Restore Library Dependencies'
+ inputs:
+ restoreSolution: '$(solution)'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Build Library'
+ inputs:
+ command: 'build'
+ projects: './src/AspNetCore.Identity.MongoDbCore.csproj'
+ arguments: '--configuration $(buildConfiguration)'
+
+# - task: DotNetCoreCLI@2
+# displayName: 'Test Library'
+# inputs:
+# command: 'test'
+# projects: './test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj'
+# arguments: '--configuration $(buildConfiguration)'
+
+- task: DotNetCoreCLI@2
+ displayName: 'Package Library (nuget)'
+ inputs:
+ command: 'custom'
+ projects: './src/AspNetCore.Identity.MongoDbCore.csproj'
+ custom: 'pack'
+ arguments: '--no-build -p:NuspecFile=AspNetCore.Identity.MongoDbCore.nuspec -o $(build.artifactStagingDirectory)/Nuget'
+ verbosityPack: 'Detailed'
+
+- task: NuGetCommand@2
+ displayName: 'Publish Library'
+ inputs:
+ command: 'push'
+ packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
+ nuGetFeedType: 'internal'
+ publishVstsFeed: '72ef5435-c019-4338-8d35-7c3caec78f2a'
+ verbosityPush: 'Normal'
\ No newline at end of file
diff --git a/package.ps1 b/package.ps1
new file mode 100644
index 0000000..6c6c44e
--- /dev/null
+++ b/package.ps1
@@ -0,0 +1,10 @@
+
+$project="./src/AspNetCore.Identity.MongoDbCore.csproj"
+$testProject="./test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj"
+$configuration="Release"
+$nuspecFile="AspnetCore.Identity.MongoDbCore.nuspec"
+$output="./nuget"
+
+dotnet build
+dotnet test $testProject
+dotnet pack --no-restore --no-build $project --configuration $configuration -p:NuspecFile=$nuspecFile -o $output
\ No newline at end of file
diff --git a/sample/MongoIdentitySample.Mvc/.vscode/launch.json b/sample/MongoIdentitySample.Mvc/.vscode/launch.json
new file mode 100644
index 0000000..4a5fbb6
--- /dev/null
+++ b/sample/MongoIdentitySample.Mvc/.vscode/launch.json
@@ -0,0 +1,36 @@
+{
+ // Use IntelliSense to find out which attributes exist for C# debugging
+ // Use hover for the description of the existing attributes
+ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": ".NET Core Launch (web)",
+ "type": "coreclr",
+ "request": "launch",
+ "preLaunchTask": "build",
+ // If you have changed target frameworks, make sure to update the program path.
+ "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/MongoIdentitySample.Mvc.dll",
+ "args": [],
+ "cwd": "${workspaceFolder}",
+ "stopAtEntry": false,
+ // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
+ "serverReadyAction": {
+ "action": "openExternally",
+ "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
+ },
+ "env": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ },
+ "sourceFileMap": {
+ "/Views": "${workspaceFolder}/Views"
+ }
+ },
+ {
+ "name": ".NET Core Attach",
+ "type": "coreclr",
+ "request": "attach",
+ "processId": "${command:pickProcess}"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/sample/MongoIdentitySample.Mvc/.vscode/tasks.json b/sample/MongoIdentitySample.Mvc/.vscode/tasks.json
new file mode 100644
index 0000000..5a3c47b
--- /dev/null
+++ b/sample/MongoIdentitySample.Mvc/.vscode/tasks.json
@@ -0,0 +1,42 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/MongoIdentitySample.Mvc.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/MongoIdentitySample.Mvc.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "${workspaceFolder}/MongoIdentitySample.Mvc.csproj",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj b/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj
index 9677268..667379a 100644
--- a/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj
+++ b/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj
@@ -9,20 +9,18 @@
-
-
-
+
-
-
+
+
diff --git a/sample/MongoIdentitySample.Mvc/Program.cs b/sample/MongoIdentitySample.Mvc/Program.cs
index 5162e7d..4ba0d11 100644
--- a/sample/MongoIdentitySample.Mvc/Program.cs
+++ b/sample/MongoIdentitySample.Mvc/Program.cs
@@ -1,5 +1,6 @@
using System.IO;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
namespace MongoIdentitySample.Mvc
{
@@ -7,14 +8,14 @@ namespace MongoIdentitySample.Mvc
{
public static void Main(string[] args)
{
- var host = new WebHostBuilder()
- .UseKestrel()
- .UseContentRoot(Directory.GetCurrentDirectory())
- .UseIISIntegration()
- .UseStartup()
- .Build();
-
- host.Run();
+ CreateHostBuilder(args).Build().Run();
}
+
+ protected static IHostBuilder CreateHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup();
+ });
}
}
diff --git a/sample/MongoIdentitySample.Mvc/Startup.cs b/sample/MongoIdentitySample.Mvc/Startup.cs
index 2cb6269..cbf26a8 100644
--- a/sample/MongoIdentitySample.Mvc/Startup.cs
+++ b/sample/MongoIdentitySample.Mvc/Startup.cs
@@ -8,19 +8,23 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using MongoIdentitySample.Mvc.Models;
using MongoIdentitySample.Mvc.Services;
-using System;
using Microsoft.Extensions.Logging;
+using System;
namespace MongoIdentitySample.Mvc
{
public class Startup
{
- const string DevEnvironmentName = "Development";
+ private IWebHostEnvironment _env;
public Startup(IWebHostEnvironment env)
{
+ _env = env;
var builder = new ConfigurationBuilder()
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
+ .SetBasePath(env.ContentRootPath)
+ .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
+ //per user config that is not committed to repo, use this to override settings (e.g. connection string) based on your local environment.
+ .AddJsonFile($"appsettings.local.json", optional: true);
builder.AddEnvironmentVariables();
Configuration = builder.Build();
@@ -36,20 +40,25 @@ namespace MongoIdentitySample.Mvc
var settings = Configuration.GetSection(nameof(MongoDbSettings)).Get();
services.AddSingleton(settings);
+
services.AddIdentity()
.AddMongoDbStores(settings.ConnectionString, settings.DatabaseName)
.AddSignInManager()
.AddDefaultTokenProviders();
+
+ var builder = services.AddRazorPages();
+
+ #if DEBUG
+ if(_env.IsDevelopment())
+ {
+ builder.AddRazorRuntimeCompilation();
+ }
+ #endif
+
services.AddMvc();
- //services.AddAuthentication(o =>
- //{
- // o.DefaultScheme = IdentityConstants.ApplicationScheme;
- // o.DefaultSignInScheme = IdentityConstants.ExternalScheme;
- //})
- //.AddIdentityCookies(o => { });
-
+ services.AddApplicationInsightsTelemetry();
// Add application services.
services.AddTransient();
diff --git a/sample/MongoIdentitySample.Mvc/Views/Shared/_Layout.cshtml b/sample/MongoIdentitySample.Mvc/Views/Shared/_Layout.cshtml
index 15c0be6..8cbfd77 100644
--- a/sample/MongoIdentitySample.Mvc/Views/Shared/_Layout.cshtml
+++ b/sample/MongoIdentitySample.Mvc/Views/Shared/_Layout.cshtml
@@ -31,7 +31,7 @@
@RenderBody()
diff --git a/sample/MongoIdentitySample.Mvc/bundleconfig.json b/sample/MongoIdentitySample.Mvc/bundleconfig.json
index 6d3f9a5..9d8ef2a 100644
--- a/sample/MongoIdentitySample.Mvc/bundleconfig.json
+++ b/sample/MongoIdentitySample.Mvc/bundleconfig.json
@@ -1,9 +1,6 @@
-// Configure bundling and minification for the project.
-// More info at https://go.microsoft.com/fwlink/?LinkId=808241
-[
- {
+[
+{
"outputFileName": "wwwroot/css/site.min.css",
- // An array of relative input file paths. Globbing patterns supported
"inputFiles": [
"wwwroot/css/site.css"
]
@@ -13,12 +10,10 @@
"inputFiles": [
"wwwroot/js/site.js"
],
- // Optionally specify minification options
"minify": {
"enabled": true,
"renameLocals": true
},
- // Optionally generate .map file
"sourceMap": false
}
]
diff --git a/src/AspNetCore.Identity.MongoDbCore.nuspec b/src/AspNetCore.Identity.MongoDbCore.nuspec
index 91c296c..63916fc 100644
--- a/src/AspNetCore.Identity.MongoDbCore.nuspec
+++ b/src/AspNetCore.Identity.MongoDbCore.nuspec
@@ -2,11 +2,11 @@
AspNetCore.Identity.MongoDbCore
- 1.1.1
+ 2.1.0
AspNetCore.Identity.MongoDbCore
Alexandre Spieser
Alexandre Spieser
- http://www.opensource.org/licenses/mit-license.php
+ MIT
https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore
false
A MongoDb UserStore and RoleStore adapter for Microsoft.AspNetCore.Identity 2.0.
@@ -14,13 +14,21 @@
Copyright 2018 (c) Alexandre Spieser. All rights reserved.
aspnetcore mongo mongodb identity membership
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj
index 44f31f6..2ab4ae9 100644
--- a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj
+++ b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj
@@ -33,4 +33,9 @@
+
+
+ Always
+
+
diff --git a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs
index c2e3de0..7ba989d 100644
--- a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs
+++ b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs
@@ -1,5 +1,6 @@
using AspNetCore.Identity.MongoDbCore.Extensions;
using AspNetCore.Identity.MongoDbCore.Infrastructure;
+using Microsoft.Extensions.Configuration;
using System;
namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure
@@ -12,22 +13,47 @@ namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure
public static class Container
{
- public static MongoDbIdentityConfiguration MongoDbIdentityConfiguration = new MongoDbIdentityConfiguration
+ public static IConfiguration Configuration { get; set; }
+
+ static Container()
{
- MongoDbSettings = new MongoDbSettings
+ var builder = new ConfigurationBuilder()
+ .SetBasePath(System.Environment.CurrentDirectory)
+ .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
+ //per user config that is not committed to repo, use this to override settings (e.g. connection string) based on your local environment.
+ .AddJsonFile($"appsettings.local.json", optional: true);
+
+ builder.AddEnvironmentVariables();
+
+ Configuration = builder.Build();
+
+ var databaseSettings = Configuration.Load("MongoDbSettings");
+
+ MongoDbIdentityConfiguration = new MongoDbIdentityConfiguration()
{
- ConnectionString = "mongodb://localhost:27017",
- DatabaseName = "MongoDbTests"
- },
- IdentityOptionsAction = options =>
+ MongoDbSettings = databaseSettings,
+ IdentityOptionsAction = (options) =>
+ {
+ options.Password.RequireDigit = false;
+ options.Password.RequireLowercase = false;
+ options.Password.RequireNonAlphanumeric = false;
+ options.Password.RequireUppercase = false;
+ options.User.AllowedUserNameCharacters = null;
+ }
+ };
+
+ lock (Locks.MongoInitLock)
{
- options.Password.RequireDigit = false;
- options.Password.RequireLowercase = false;
- options.Password.RequireNonAlphanumeric = false;
- options.Password.RequireUppercase = false;
- options.User.AllowedUserNameCharacters = null;
+ _mongoDbRepository = new MongoRepository(
+ databaseSettings.ConnectionString,
+ databaseSettings.DatabaseName);
+ _mongoDbRepository2 = new MongoRepository(
+ databaseSettings.ConnectionString,
+ databaseSettings.DatabaseName);
}
- };
+ }
+
+ public static MongoDbIdentityConfiguration MongoDbIdentityConfiguration { get; set; }
public static IServiceProvider Instance { get; set; }
@@ -36,19 +62,6 @@ namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure
private static readonly IMongoRepository _mongoDbRepository2;
- static Container()
- {
- lock (Locks.MongoInitLock)
- {
- _mongoDbRepository = new MongoRepository(
- MongoDbIdentityConfiguration.MongoDbSettings.ConnectionString,
- MongoDbIdentityConfiguration.MongoDbSettings.DatabaseName);
- _mongoDbRepository2 = new MongoRepository(
- MongoDbIdentityConfiguration.MongoDbSettings.ConnectionString,
- MongoDbIdentityConfiguration.MongoDbSettings.DatabaseName);
- }
- }
-
public static IMongoRepository MongoRepository
{
get
@@ -65,4 +78,20 @@ namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure
}
}
}
+
+ public static class ConfigurationExtensions
+ {
+ public static T Load(this IConfiguration configuration, string key) where T : new()
+ {
+ var instance = new T();
+ configuration.GetSection(key).Bind(instance);
+ return instance;
+ }
+
+ public static T Load(this IConfiguration configuration, string key, T instance) where T : new()
+ {
+ configuration.GetSection(key).Bind(instance);
+ return instance;
+ }
+ }
}
diff --git a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.json b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.json
new file mode 100644
index 0000000..5c53f25
--- /dev/null
+++ b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.json
@@ -0,0 +1,12 @@
+{
+ "MongoDbSettings": {
+ "ConnectionString": "mongodb://localhost:27017",
+ "DatabaseName": "MongoDbTests"
+ },
+ "Logging": {
+ "IncludeScopes": false,
+ "LogLevel": {
+ "Default": "Warning"
+ }
+ }
+}