コード例 #1
0
 /// <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);
 }
コード例 #2
0
        static Container()
        {
            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();

            Settings = Configuration.Load <ArangoDbSettings>("ArangoDbSettings");

            ArangoDbIdentityConfiguration = new ArangoDbIdentityConfiguration()
            {
                ArangoDbSettings      = Settings,
                IdentityOptionsAction = (options) =>
                {
                    options.Password.RequireDigit           = false;
                    options.Password.RequireLowercase       = false;
                    options.Password.RequireNonAlphanumeric = false;
                    options.Password.RequireUppercase       = false;
                    options.User.AllowedUserNameCharacters  = null;
                }
            };

            ArangoRepository = new ArangoRepository(Settings);
        }
コード例 #3
0
 /// <summary>
 /// Configures the ArangoDb Identity store adapters for the types of TUser only inheriting from <see cref="T:AspNetCore.Identity.ArangoDbCore.Models.ArangoIdentityUser" />.
 /// </summary>
 /// <typeparam name="TUser">The type representing a user.</typeparam>
 /// <param name="services">The collection of service descriptors.</param>
 /// <param name="arangoDbIdentityConfiguration">A configuration object of the AspNetCore.Identity.ArangoDbCore package.</param>
 public static void ConfigureArangoDbIdentity <TUser>(
     this IServiceCollection services,
     ArangoDbIdentityConfiguration arangoDbIdentityConfiguration)
     where TUser : ArangoIdentityUser, new()
 {
     ValidateArangoDbSettings(arangoDbIdentityConfiguration.ArangoDbSettings);
     services.CommonArangoDbSetup <TUser, ArangoIdentityRole, Guid>(arangoDbIdentityConfiguration);
 }
コード例 #4
0
 /// <summary>
 /// Configures the ArangoDb Identity store adapters for the types of TUser only from <see cref="T:AspNetCore.Identity.ArangoDbCore.Models.ArangoIdentityUser`1" />.
 /// </summary>
 /// <typeparam name="TUser">The type representing a user.</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>
 public static void ConfigureArangoDbIdentityUserOnly <TUser, TKey>(
     this IServiceCollection services,
     ArangoDbIdentityConfiguration arangoDbIdentityConfiguration)
     where TUser : ArangoIdentityUser, new()
     where TKey : IEquatable <TKey>
 {
     ValidateArangoDbSettings(arangoDbIdentityConfiguration.ArangoDbSettings);
     services.CommonArangoDbSetup <TUser, ArangoIdentityRole, TKey>(arangoDbIdentityConfiguration);
 }
コード例 #5
0
 private static void CommonArangoDbSetup <TUser, TRole, TKey>(
     this IServiceCollection services,
     ArangoDbIdentityConfiguration arangoDbIdentityConfiguration)
     where TUser : ArangoIdentityUser, new()
     where TRole : ArangoIdentityRole, new()
     where TKey : IEquatable <TKey>
 {
     services.AddIdentity <TUser, TRole>().AddArangoDbStores <TUser, TRole, TKey>(
         arangoDbIdentityConfiguration.ArangoDbSettings.Uri,
         arangoDbIdentityConfiguration.ArangoDbSettings.Database,
         arangoDbIdentityConfiguration.ArangoDbSettings.UserId,
         arangoDbIdentityConfiguration.ArangoDbSettings.Password).AddDefaultTokenProviders();
     if (arangoDbIdentityConfiguration.IdentityOptionsAction == null)
     {
         return;
     }
     services.Configure <IdentityOptions>(arangoDbIdentityConfiguration.IdentityOptionsAction);
 }