Big cleanup and adding IdentityBuilder extensions the same way as the EF IdentityBuilder extensions do, allowing customer Identity setup.

This commit is contained in:
alexandre-spieser
2017-10-29 15:09:57 +00:00
parent 7a1558a48b
commit d99ce293f0
32 changed files with 697 additions and 521 deletions
@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Identity;
using System;
namespace AspNetCore.Identity.MongoDbCore.Infrastructure
{
/// <summary>
/// A class used to perform a full configuration of the AspNetCore.Identity.MongoDbCore package.
/// </summary>
public class MongoDbIdentityConfiguration
{
/// <summary>
/// The settings for the MongoDb server.
/// </summary>
public MongoDbSettings MongoDbSettings { get; set; }
/// <summary>
/// An action against an <see cref="IdentityOptions"/> to change the default identity settings.
/// </summary>
public Action<IdentityOptions> IdentityOptionsAction { get; set; }
}
}
+17
View File
@@ -0,0 +1,17 @@
namespace AspNetCore.Identity.MongoDbCore.Infrastructure
{
/// <summary>
/// A class representing the settings for the MongoDb server.
/// </summary>
public class MongoDbSettings
{
/// <summary>
/// The connection string for the MongoDb server.
/// </summary>
public string ConnectionString { get; set; }
/// <summary>
/// The name of the MongoDb database where the identity data will be stored.
/// </summary>
public string DatabaseName { get; set; }
}
}
+41 -1
View File
@@ -2,34 +2,74 @@
namespace AspNetCore.Identity.MongoDbCore.Infrastructure
{
/// <summary>
/// The repository used in the MongoDb identity stores.
/// </summary>
public interface IMongoRepository : IBaseMongoRepository
{
/// <summary>
/// Drops a collections.
/// </summary>
/// <typeparam name="TDocument">The type of the document used to define the collection name.</typeparam>
void DropCollection<TDocument>();
/// <summary>
/// Drops a partitioned collection.
/// </summary>
/// <typeparam name="TDocument">The type of the document used to define the collection name.</typeparam>
/// <param name="partitionKey">The partition key of the collection.</param>
void DropCollection<TDocument>(string partitionKey);
/// <summary>
/// The MongoDb context.
/// </summary>
IMongoDbContext Context { get; }
}
/// <summary>
/// The repository used in the MongoDb identity stores.
/// </summary>
public class MongoRepository : BaseMongoRepository, IMongoRepository
{
/// <summary>
/// The constructor for <see cref="MongoRepository"/> requiring a connection string and a database name.
/// </summary>
/// <param name="connectionString">The connection string.</param>
/// <param name="databaseName">The database name.</param>
public MongoRepository(string connectionString, string databaseName) : base(connectionString, databaseName)
{
}
/// <summary>
/// The constructor for <see cref="MongoRepository"/> requiring a <see cref="IMongoDbContext"/>.
/// </summary>
/// <param name="mongoDbContext">A <see cref="IMongoDbContext"/>.</param>
public MongoRepository(IMongoDbContext mongoDbContext) : base(mongoDbContext)
{
}
/// <summary>
/// Drops a collections.
/// </summary>
/// <typeparam name="TDocument">The type of the document used to define the collection name.</typeparam>
public void DropCollection<TDocument>()
{
MongoDbContext.DropCollection<TDocument>();
}
/// <summary>
/// Drops a partitioned collection.
/// </summary>
/// <typeparam name="TDocument">The type of the document used to define the collection name.</typeparam>
/// <param name="partitionKey">The partition key of the collection.</param>
public void DropCollection<TDocument>(string partitionKey)
{
MongoDbContext.DropCollection<TDocument>(partitionKey);
}
/// <summary>
/// The MongoDb context.
/// </summary>
public IMongoDbContext Context => MongoDbContext;
}
}