コード例 #1
0
 public IdentityUserConfiguration(StoreOptions storeOptions, PersonalDataConverter personalDataConverter, string tableName = UserTableName)
 {
     this.storeOptions          = storeOptions;
     this.tableName             = tableName;
     this.personalDataConverter = personalDataConverter;
 }
コード例 #2
0
 public static void BuildIdentityUser <TEntity, TKey>(this EntityTypeBuilder <TEntity> builder, StoreOptions storeOptions, PersonalDataConverter personalDataConverter, string tableName = UserTableName, string normalizedNameIndex = UserTableNormalizedNameIndex)
     where TKey : IEquatable <TKey>
     where TEntity : class, IIdentityUser <TKey>
 {
     builder.ToTable(tableName);
     builder.HasKey(u => u.Id);
     builder.Property(u => u.NormalizedName).HasMaxLength(256);
     builder.Property(u => u.Name).HasMaxLength(256);
     builder.HasIndex(u => u.NormalizedName).HasDatabaseName(normalizedNameIndex).IsUnique();
     builder.EncryptIdentityPersonalData(storeOptions, personalDataConverter);
 }
コード例 #3
0
        public static void EncryptIdentityPersonalData <T>(this EntityTypeBuilder <T> builder, StoreOptions storeOptions, PersonalDataConverter personalDataConverter) where T : class
        {
            var encryptPersonalData = storeOptions?.ProtectPersonalData ?? false;

            if (encryptPersonalData)
            {
                var personalDataProps = typeof(T).GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(ProtectedPersonalDataAttribute)));
                foreach (var p in personalDataProps)
                {
                    if (p.PropertyType != typeof(string))
                    {
                        throw new InvalidOperationException(Resources.CanOnlyProtectStrings);
                    }
                    builder.Property(typeof(string), p.Name).HasConversion(personalDataConverter);
                }
            }
        }
コード例 #4
0
        public static void BuildIdentityUserToken <TKey>(this EntityTypeBuilder <IIdentityUserToken <TKey> > builder, StoreOptions storeOptions, PersonalDataConverter personalDataConverter, string tableName = UserTokenTableName)
            where TKey : IEquatable <TKey>
        {
            builder.ToTable(tableName);
            builder.HasKey(t => new { t.UserId, t.LoginProvider, t.Name });
            var maxKeyLength = storeOptions?.MaxLengthForKeys ?? 0;

            if (maxKeyLength > 0)
            {
                builder.Property(t => t.LoginProvider).HasMaxLength(maxKeyLength);
                builder.Property(t => t.Name).HasMaxLength(maxKeyLength);
            }
            builder.EncryptIdentityPersonalData(storeOptions, personalDataConverter);
        }
コード例 #5
0
 public static void BuildIdentityUserToken <TKey>(this ModelBuilder builder, StoreOptions storeOptions, PersonalDataConverter personalDataConverter, string tableName = UserTokenTableName)
     where TKey : IEquatable <TKey>
 //=> builder.Entity<IIdentityUserToken<TKey>>().BuildIdentityUserToken(storeOptions, personalDataConverter, tableName);
 => builder.ApplyConfiguration(new IdentityUserTokenConfiguration <TKey>(storeOptions, personalDataConverter, tableName));
コード例 #6
0
 public static void BuildIdentityUser <TKey>(this ModelBuilder builder, StoreOptions storeOptions, PersonalDataConverter personalDataConverter, string tableName = UserTableName)
     where TKey : IEquatable <TKey>
 => builder.Entity <IIdentityUser <TKey> >().BuildIdentityUser <IIdentityUser <TKey>, TKey>(storeOptions, personalDataConverter, tableName);