/// <summary> /// Configures the ArangoDb Identity store adapters for the types of TUser and TRole. /// </summary> /// <typeparam name="TUser">The type representing a user.</typeparam> /// <typeparam name="TRole">The type representing a role.</typeparam> /// <typeparam name="TKey">The type of the primary key of the identity document.</typeparam> /// <param name="services">The collection of service descriptors.</param> /// <param name="arangoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.ArangoDbCore package.</param> /// <param name="arangoDbContext">An object representing a ArangoDb connection.</param> public static void ConfigureArangoDbIdentity <TUser, TRole, TKey>( this IServiceCollection services, ArangoDbIdentityConfiguration arangoDbIdentityConfiguration, IArangoDbContext arangoDbContext = null) where TUser : ArangoIdentityUser, new() where TRole : ArangoIdentityRole, new() where TKey : IEquatable <TKey> { ValidateArangoDbSettings(arangoDbIdentityConfiguration.ArangoDbSettings); if (arangoDbContext == null) { services.AddIdentity <TUser, TRole>().AddArangoDbStores <TUser, TRole, TKey>( arangoDbIdentityConfiguration.ArangoDbSettings.UserId, arangoDbIdentityConfiguration.ArangoDbSettings.Database, arangoDbIdentityConfiguration.ArangoDbSettings.UserId, arangoDbIdentityConfiguration.ArangoDbSettings.Password).AddDefaultTokenProviders(); } else { services.AddIdentity <TUser, TRole>().AddArangoDbStores <IArangoDbContext>(arangoDbContext).AddDefaultTokenProviders(); } if (arangoDbIdentityConfiguration.IdentityOptionsAction == null) { return; } services.Configure <IdentityOptions>(arangoDbIdentityConfiguration.IdentityOptionsAction); }
/// <summary> /// Adds an ArangoDb implementation of identity information stores. /// </summary> /// <typeparam name="TContext">The ArangoDb database context to use.</typeparam> /// <param name="builder">The <see cref="T:Microsoft.AspNetCore.Identity.IdentityBuilder" /> instance this method extends.</param> /// <param name="arangoDbContext">A ArangoDbContext</param> /// <returns>The <see cref="T:Microsoft.AspNetCore.Identity.IdentityBuilder" /> instance this method extends.</returns> public static IdentityBuilder AddArangoDbStores <TContext>( this IdentityBuilder builder, IArangoDbContext arangoDbContext) where TContext : IArangoDbContext { if (arangoDbContext == null) { throw new ArgumentNullException(nameof(arangoDbContext)); } builder.Services.TryAddSingleton <IArangoDbContext>(arangoDbContext); builder.Services.TryAddSingleton <IArangoDbRepository>((IArangoDbRepository) new ArangoRepository(arangoDbContext)); return(builder); }
/// <summary> /// Adds an ArangoDb implementation of identity information stores. /// </summary> /// <typeparam name="TUser">The type representing a user.</typeparam> /// <typeparam name="TRole">The type representing a role.</typeparam> /// <typeparam name="TKey">The type of the primary key of the identity document.</typeparam> /// <param name="builder">The <see cref="T:Microsoft.AspNetCore.Identity.IdentityBuilder" /> instance this method extends.</param> /// <param name="arangoDbContext"></param> public static IdentityBuilder AddArangoDbStores <TUser, TRole, TKey>( this IdentityBuilder builder, IArangoDbContext arangoDbContext) where TUser : ArangoIdentityUser, new() where TRole : ArangoIdentityRole, new() where TKey : IEquatable <TKey> { if (arangoDbContext == null) { throw new ArgumentNullException(nameof(arangoDbContext)); } builder.Services.TryAddSingleton(arangoDbContext); builder.Services.TryAddSingleton((IArangoDbRepository) new ArangoRepository(arangoDbContext)); builder.Services.TryAddScoped(provider => (IUserStore <TUser>) new ArangoUserStore <TUser, TRole, IArangoDbContext>(provider.GetService <IArangoDbContext>())); builder.Services.TryAddScoped(provider => (IRoleStore <TRole>) new ArangoRoleStore <TRole, IArangoDbContext>(provider.GetService <IArangoDbContext>())); return(builder); }
public ArangoRepository(IArangoDbContext context) { Context = context; }
public ArangoDatabaseFixture() { Context = new ArangoDbContext(Container.Settings); UsersToDelete = new ConcurrentBag <TUser>(); }
/// <summary> /// Constructs a new instance of <see cref="ArangoRoleStore{TRole}"/>. /// </summary> /// <param name="context">The <see cref="IArangoDbContext"/>.</param> /// <param name="describer">The <see cref="IdentityErrorDescriber"/>.</param> public ArangoRoleStore(IArangoDbContext context, IdentityErrorDescriber describer = null) : base(context, describer) { }