diff --git a/src/Microsoft.AspNet.Identity/ClaimTypeOptions.cs b/src/Microsoft.AspNet.Identity/ClaimTypeOptions.cs
index f84e4f18af..3216bae432 100644
--- a/src/Microsoft.AspNet.Identity/ClaimTypeOptions.cs
+++ b/src/Microsoft.AspNet.Identity/ClaimTypeOptions.cs
@@ -20,11 +20,6 @@ namespace Microsoft.AspNet.Identity
UserName = ClaimTypes.Name;
}
- public ClaimTypeOptions(IConfiguration config) : this()
- {
- IdentityOptions.Read(this, config);
- }
-
///
/// Claim type used for role claims
///
diff --git a/src/Microsoft.AspNet.Identity/IdentityOptions.cs b/src/Microsoft.AspNet.Identity/IdentityOptions.cs
index aeb4a9b4e4..d1063755ac 100644
--- a/src/Microsoft.AspNet.Identity/IdentityOptions.cs
+++ b/src/Microsoft.AspNet.Identity/IdentityOptions.cs
@@ -18,53 +18,6 @@ namespace Microsoft.AspNet.Identity
Lockout = new LockoutOptions();
}
- public IdentityOptions(IConfiguration config)
- {
- ClaimType = new ClaimTypeOptions(config.GetSubKey("identity:claimtype"));
- User = new UserOptions(config.GetSubKey("identity:user"));
- Password = new PasswordOptions(config.GetSubKey("identity:password"));
- //Lockout = new LockoutOptions(config.GetSubKey("identity:lockout"));
- }
-
- public static void Read(object obj, IConfiguration config)
- {
- var type = obj.GetType();
- var props = type.GetTypeInfo().DeclaredProperties;
- foreach (var prop in props)
- {
- // TODO: handle non string types?
- if (!prop.CanWrite)
- {
- continue;
- }
- var configValue = config.Get(prop.Name);
- if (configValue == null)
- {
- continue;
- }
- if (prop.PropertyType == typeof(string))
- {
- prop.SetValue(obj, configValue);
- }
- else if (prop.PropertyType == typeof(int))
- {
- // todo: TryParse/ errors?
- prop.SetValue(obj, int.Parse(configValue));
- }
- else if (prop.PropertyType == typeof(bool))
- {
- // todo: TryParse/ errors?
- prop.SetValue(obj, bool.Parse(configValue));
- }
- //else if (prop.PropertyType == typeof(TimeSpan))
- //{
- // // todo: TryParse/ errors?
- // prop.SetValue(obj, TimeSpan.Parse(configValue));
- //}
- }
- }
-
-
public ClaimTypeOptions ClaimType { get; set; }
public UserOptions User { get; set; }
diff --git a/src/Microsoft.AspNet.Identity/IdentityOptionsSetup.cs b/src/Microsoft.AspNet.Identity/IdentityOptionsSetup.cs
new file mode 100644
index 0000000000..6e87eb1a71
--- /dev/null
+++ b/src/Microsoft.AspNet.Identity/IdentityOptionsSetup.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Reflection;
+using Microsoft.Framework.ConfigurationModel;
+using Microsoft.Framework.DependencyInjection;
+
+namespace Microsoft.AspNet.Identity
+{
+ public class IdentityOptionsSetup : IOptionsSetup
+ {
+ private readonly IConfiguration _config;
+
+ public IdentityOptionsSetup(IConfiguration config)
+ {
+ _config = config;
+ }
+
+ public int Order { get; set; }
+
+ public void Setup(IdentityOptions options)
+ {
+ if (_config != null)
+ {
+ ReadProperties(options.ClaimType, _config.GetSubKey("identity:claimtype"));
+ ReadProperties(options.User, _config.GetSubKey("identity:user"));
+ ReadProperties(options.Password, _config.GetSubKey("identity:password"));
+ ReadProperties(options.Lockout, _config.GetSubKey("identity:lockout"));
+ }
+ }
+
+ // TODO: Move this somewhere common (Config?) or at least the config.Get conversion
+ public static void ReadProperties(object obj, IConfiguration config)
+ {
+ if (obj == null || config == null)
+ {
+ return;
+ }
+ var props = obj.GetType().GetTypeInfo().DeclaredProperties;
+ foreach (var prop in props)
+ {
+ if (!prop.CanWrite)
+ {
+ continue;
+ }
+ var configValue = config.Get(prop.Name);
+ if (configValue == null)
+ {
+ continue;
+ }
+
+ try
+ {
+// No convert on portable
+#if NET45 || K10
+ prop.SetValue(obj, Convert.ChangeType(configValue, prop.PropertyType));
+#endif
+ }
+ catch
+ {
+ // TODO: what do we do about errors?
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs
index 2b27706bc4..e41f552a47 100644
--- a/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs
+++ b/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs
@@ -28,6 +28,7 @@ namespace Microsoft.Framework.DependencyInjection
{
services.Add(IdentityServices.GetDefaultUserServices());
services.Add(IdentityServices.GetDefaultRoleServices());
+ services.AddTransient, IdentityOptionsSetup>();
services.AddSingleton, OptionsAccessor>();
actionBuilder(new IdentityBuilder(services));
return services;
diff --git a/src/Microsoft.AspNet.Identity/LockoutPolicy.cs b/src/Microsoft.AspNet.Identity/LockoutPolicy.cs
deleted file mode 100644
index 98fdae5d17..0000000000
--- a/src/Microsoft.AspNet.Identity/LockoutPolicy.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc.
-// All Rights Reserved
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR
-// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
-// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
-// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR
-// NON-INFRINGEMENT.
-// See the Apache 2 License for the specific language governing
-// permissions and limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Microsoft.AspNet.Identity
-{
- ///
- /// Configuration for lockout
- ///
- public class LockoutPolicy
- {
- ///
- /// If true, will enable user lockout when users are created
- ///
- public bool UserLockoutEnabledByDefault { get; set; }
-
- ///
- /// Number of access attempts allowed for a user before lockout (if enabled)
- ///
- public int MaxFailedAccessAttemptsBeforeLockout { get; set; }
-
- ///
- /// Default amount of time an user is locked out for after MaxFailedAccessAttempsBeforeLockout is reached
- ///
- public TimeSpan DefaultAccountLockoutTimeSpan { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/PasswordOptions.cs b/src/Microsoft.AspNet.Identity/PasswordOptions.cs
index 3ba1bb77a1..63750523ec 100644
--- a/src/Microsoft.AspNet.Identity/PasswordOptions.cs
+++ b/src/Microsoft.AspNet.Identity/PasswordOptions.cs
@@ -13,11 +13,6 @@ namespace Microsoft.AspNet.Identity
RequiredLength = 6;
}
- public PasswordOptions(IConfiguration config) : this()
- {
- IdentityOptions.Read(this, config);
- }
-
///
/// Minimum required length
///
diff --git a/src/Microsoft.AspNet.Identity/UserOptions.cs b/src/Microsoft.AspNet.Identity/UserOptions.cs
index 0f3fef9280..75735645cc 100644
--- a/src/Microsoft.AspNet.Identity/UserOptions.cs
+++ b/src/Microsoft.AspNet.Identity/UserOptions.cs
@@ -10,11 +10,6 @@ namespace Microsoft.AspNet.Identity
//User.RequireUniqueEmail = true; // TODO: app decision?
}
- public UserOptions(IConfiguration config) : this()
- {
- IdentityOptions.Read(this, config);
- }
-
///
/// Only allow [A-Za-z0-9@_] in UserNames
///
diff --git a/temp/Identity45.sln b/temp/Identity45.sln
index f6601bd62b..df2329c837 100644
--- a/temp/Identity45.sln
+++ b/temp/Identity45.sln
@@ -3,25 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30408.0
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.net45", "..\src\Microsoft.AspNet.Identity\Microsoft.AspNet.Identity.net45.csproj", "{4D061067-3FE9-442D-81D3-29658DA2FF8F}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.net45", "..\src\Microsoft.AspNet.Identity\Microsoft.AspNet.Identity.net45.csproj", "{FF3ECD18-9F70-4C8F-A052-2CC36E92496F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{31019886-9CDA-4072-B3D9-E513122CECD0}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Entity.net45", "..\src\Microsoft.AspNet.Identity.Entity\Microsoft.AspNet.Identity.Entity.net45.csproj", "{1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Entity.net45", "..\src\Microsoft.AspNet.Identity.Entity\Microsoft.AspNet.Identity.Entity.net45.csproj", "{B8C12CE9-F3DA-450D-AE52-40014B8F8B53}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.InMemory.net45", "..\src\Microsoft.AspNet.Identity.InMemory\Microsoft.AspNet.Identity.InMemory.net45.csproj", "{173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.InMemory.net45", "..\src\Microsoft.AspNet.Identity.InMemory\Microsoft.AspNet.Identity.InMemory.net45.csproj", "{2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Security.net45", "..\src\Microsoft.AspNet.Identity.Security\Microsoft.AspNet.Identity.Security.net45.csproj", "{720B2280-085C-441D-98CD-B241145A1C12}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Security.net45", "..\src\Microsoft.AspNet.Identity.Security\Microsoft.AspNet.Identity.Security.net45.csproj", "{0C5F4428-383D-4D8F-B99D-5E9686390DB9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{394C0E59-7E24-453E-993C-7B914C62110A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Test.net45", "..\test\Microsoft.AspNet.Identity.Test\Microsoft.AspNet.Identity.Test.net45.csproj", "{B3A5D740-2C31-4EBC-AADB-356263965C1F}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Test.net45", "..\test\Microsoft.AspNet.Identity.Test\Microsoft.AspNet.Identity.Test.net45.csproj", "{2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Security.Test.net45", "..\test\Microsoft.AspNet.Identity.Security.Test\Microsoft.AspNet.Identity.Security.Test.net45.csproj", "{9F67914A-1F35-4068-A21A-F279C4053ADD}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Security.Test.net45", "..\test\Microsoft.AspNet.Identity.Security.Test\Microsoft.AspNet.Identity.Security.Test.net45.csproj", "{7922374C-77B6-4A64-A50C-50F6E31A29A6}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.InMemory.Test.net45", "..\test\Microsoft.AspNet.Identity.InMemory.Test\Microsoft.AspNet.Identity.InMemory.Test.net45.csproj", "{E2154446-8A68-478B-927F-FD05251C8452}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.InMemory.Test.net45", "..\test\Microsoft.AspNet.Identity.InMemory.Test\Microsoft.AspNet.Identity.InMemory.Test.net45.csproj", "{F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Entity.Test.net45", "..\test\Microsoft.AspNet.Identity.Entity.Test\Microsoft.AspNet.Identity.Entity.Test.net45.csproj", "{CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Identity.Entity.Test.net45", "..\test\Microsoft.AspNet.Identity.Entity.Test\Microsoft.AspNet.Identity.Entity.Test.net45.csproj", "{B646BB82-C0C9-46F3-9836-6AB456D9ADF9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -33,98 +33,98 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Debug|x86.ActiveCfg = Debug|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Release|Any CPU.Build.0 = Release|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {4D061067-3FE9-442D-81D3-29658DA2FF8F}.Release|x86.ActiveCfg = Release|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Debug|x86.ActiveCfg = Debug|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Release|Any CPU.Build.0 = Release|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7}.Release|x86.ActiveCfg = Release|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Debug|x86.ActiveCfg = Debug|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Release|Any CPU.Build.0 = Release|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56}.Release|x86.ActiveCfg = Release|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Debug|x86.ActiveCfg = Debug|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Release|Any CPU.Build.0 = Release|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {720B2280-085C-441D-98CD-B241145A1C12}.Release|x86.ActiveCfg = Release|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Debug|x86.ActiveCfg = Debug|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Release|Any CPU.Build.0 = Release|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {B3A5D740-2C31-4EBC-AADB-356263965C1F}.Release|x86.ActiveCfg = Release|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Debug|x86.ActiveCfg = Debug|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Release|Any CPU.Build.0 = Release|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {9F67914A-1F35-4068-A21A-F279C4053ADD}.Release|x86.ActiveCfg = Release|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Debug|x86.ActiveCfg = Debug|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Release|Any CPU.Build.0 = Release|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {E2154446-8A68-478B-927F-FD05251C8452}.Release|x86.ActiveCfg = Release|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Debug|x86.ActiveCfg = Debug|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Release|Any CPU.Build.0 = Release|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F}.Release|x86.ActiveCfg = Release|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F}.Release|x86.ActiveCfg = Release|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53}.Release|x86.ActiveCfg = Release|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43}.Release|x86.ActiveCfg = Release|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9}.Release|x86.ActiveCfg = Release|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3}.Release|x86.ActiveCfg = Release|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6}.Release|x86.ActiveCfg = Release|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9}.Release|x86.ActiveCfg = Release|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {4D061067-3FE9-442D-81D3-29658DA2FF8F} = {31019886-9CDA-4072-B3D9-E513122CECD0}
- {1832A433-ABB4-4D87-B7CE-E80E9A3E8CA7} = {31019886-9CDA-4072-B3D9-E513122CECD0}
- {173CABE9-9FDF-43A0-AF9B-409F8AA2BE56} = {31019886-9CDA-4072-B3D9-E513122CECD0}
- {720B2280-085C-441D-98CD-B241145A1C12} = {31019886-9CDA-4072-B3D9-E513122CECD0}
- {B3A5D740-2C31-4EBC-AADB-356263965C1F} = {394C0E59-7E24-453E-993C-7B914C62110A}
- {9F67914A-1F35-4068-A21A-F279C4053ADD} = {394C0E59-7E24-453E-993C-7B914C62110A}
- {E2154446-8A68-478B-927F-FD05251C8452} = {394C0E59-7E24-453E-993C-7B914C62110A}
- {CFCEFA4C-548D-459A-A051-1DBE3F2FF91F} = {394C0E59-7E24-453E-993C-7B914C62110A}
+ {FF3ECD18-9F70-4C8F-A052-2CC36E92496F} = {31019886-9CDA-4072-B3D9-E513122CECD0}
+ {B8C12CE9-F3DA-450D-AE52-40014B8F8B53} = {31019886-9CDA-4072-B3D9-E513122CECD0}
+ {2CBC40BC-15EC-45CC-BD23-7FA8FE7F5D43} = {31019886-9CDA-4072-B3D9-E513122CECD0}
+ {0C5F4428-383D-4D8F-B99D-5E9686390DB9} = {31019886-9CDA-4072-B3D9-E513122CECD0}
+ {2F5247A3-BB35-4A0B-BDA7-E5A6630B13A3} = {394C0E59-7E24-453E-993C-7B914C62110A}
+ {7922374C-77B6-4A64-A50C-50F6E31A29A6} = {394C0E59-7E24-453E-993C-7B914C62110A}
+ {F5A4A5FC-9D4C-492E-9A1C-4F94255A42C9} = {394C0E59-7E24-453E-993C-7B914C62110A}
+ {B646BB82-C0C9-46F3-9836-6AB456D9ADF9} = {394C0E59-7E24-453E-993C-7B914C62110A}
EndGlobalSection
EndGlobal
diff --git a/test/Microsoft.AspNet.Identity.Entity.Test/project.json b/test/Microsoft.AspNet.Identity.Entity.Test/project.json
index d5eba33819..b0bab20483 100644
--- a/test/Microsoft.AspNet.Identity.Entity.Test/project.json
+++ b/test/Microsoft.AspNet.Identity.Entity.Test/project.json
@@ -8,11 +8,12 @@
"Microsoft.AspNet.RequestContainer": "0.1-alpha-*",
"Microsoft.AspNet.Security.DataProtection": "0.1-alpha-*",
"Microsoft.AspNet.Testing": "0.1-alpha-*",
- "Microsoft.Data.Common": "0.1-alpha-*",
"Microsoft.Data.Entity": "0.1-alpha-*",
+ "Microsoft.Data.Entity.InMemory": "0.1-alpha-*",
+ "Microsoft.Data.Entity.Migrations": "0.1-alpha-*",
"Microsoft.Data.Entity.Relational": "0.1-alpha-*",
"Microsoft.Data.Entity.SqlServer": "0.1-alpha-*",
- "Microsoft.Data.Entity.InMemory": "0.1-alpha-*",
+ "Remotion.Linq": "1.15.13.0",
"Microsoft.Framework.ConfigurationModel": "0.1-alpha-*",
"Microsoft.Framework.DependencyInjection": "0.1-alpha-*",
"Microsoft.Framework.Logging": "0.1-alpha-*",
@@ -23,6 +24,7 @@
"xunit.core": "2.0.0-aspnet-*",
"xunit.execution": "2.0.0-aspnet-*"
},
+ "code": "**\\*.cs;..\\Shared\\*.cs",
"configurations": {
"net45": {
"dependencies": {
diff --git a/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs b/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs
index c5f75f0eb4..55487c6d74 100644
--- a/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs
+++ b/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs
@@ -2,6 +2,8 @@ using System;
using System.Collections.Generic;
using System.Security.Claims;
using Microsoft.Framework.ConfigurationModel;
+using Microsoft.Framework.DependencyInjection;
+using Microsoft.Framework.DependencyInjection.Fallback;
using Xunit;
namespace Microsoft.AspNet.Identity.Test
@@ -57,11 +59,21 @@ namespace Microsoft.AspNet.Identity.Test
{"identity:password:RequireNonLetterOrDigit", "false"},
{"identity:password:RequireUpperCase", "false"},
{"identity:password:RequireDigit", "false"},
- {"identity:password:RequireLowerCase", "false"}
+ {"identity:password:RequireLowerCase", "false"},
+ {"identity:lockout:EnabledByDefault", "TRUe"},
+ {"identity:lockout:MaxFailedAccessAttempts", "1000"}
};
var config = new Configuration { new MemoryConfigurationSource(dic) };
Assert.Equal(roleClaimType, config.Get("identity:claimtype:role"));
- var options = new IdentityOptions(config);
+
+ var setup = new IdentityOptionsSetup(config);
+ var services = new ServiceCollection();
+ services.AddInstance(config);
+ services.AddTransient, IdentityOptionsSetup>();
+ services.AddTransient, OptionsAccessor>();
+ var accessor = services.BuildServiceProvider().GetService>();
+ Assert.NotNull(accessor);
+ var options = accessor.Options;
Assert.Equal(roleClaimType, options.ClaimType.Role);
Assert.Equal(useridClaimType, options.ClaimType.UserId);
Assert.Equal(usernameClaimType, options.ClaimType.UserName);
@@ -74,51 +86,51 @@ namespace Microsoft.AspNet.Identity.Test
Assert.False(options.Password.RequireNonLetterOrDigit);
Assert.False(options.Password.RequireUppercase);
Assert.Equal(10, options.Password.RequiredLength);
+ Assert.True(options.Lockout.EnabledByDefault);
+ Assert.Equal(1000, options.Lockout.MaxFailedAccessAttempts);
}
- [Fact]
- public void ClaimTypeOptionsFromConfig()
- {
- const string roleClaimType = "rolez";
- const string usernameClaimType = "namez";
- const string useridClaimType = "idz";
- const string securityStampClaimType = "stampz";
-
- var dic = new Dictionary
- {
- {"role", roleClaimType},
- {"username", usernameClaimType},
- {"userid", useridClaimType},
- {"securitystamp", securityStampClaimType}
- };
- var config = new Configuration {new MemoryConfigurationSource(dic)};
- Assert.Equal(roleClaimType, config.Get("role"));
- var options = new ClaimTypeOptions(config);
- Assert.Equal(roleClaimType, options.Role);
- Assert.Equal(useridClaimType, options.UserId);
- Assert.Equal(usernameClaimType, options.UserName);
- Assert.Equal(securityStampClaimType, options.SecurityStamp);
- }
-
- [Fact]
- public void PasswordOptionsFromConfig()
- {
- var dic = new Dictionary
- {
- {"RequiredLength", "10"},
- {"RequireNonLetterOrDigit", "false"},
- {"RequireUpperCase", "false"},
- {"RequireDigit", "false"},
- {"RequireLowerCase", "false"}
- };
- var config = new Configuration { new MemoryConfigurationSource(dic) };
- var options = new PasswordOptions(config);
- Assert.False(options.RequireDigit);
- Assert.False(options.RequireLowercase);
- Assert.False(options.RequireNonLetterOrDigit);
- Assert.False(options.RequireUppercase);
- Assert.Equal(10, options.RequiredLength);
- }
+ //[Fact]
+ //public void ClaimTypeOptionsFromConfig()
+ //{
+ // const string roleClaimType = "rolez";
+ // const string usernameClaimType = "namez";
+ // const string useridClaimType = "idz";
+ // const string securityStampClaimType = "stampz";
+ // var dic = new Dictionary
+ // {
+ // {"role", roleClaimType},
+ // {"username", usernameClaimType},
+ // {"userid", useridClaimType},
+ // {"securitystamp", securityStampClaimType}
+ // };
+ // var config = new ConfigurationModel.Configuration {new MemoryConfigurationSource(dic)};
+ // Assert.Equal(roleClaimType, config.Get("role"));
+ // var options = new ClaimTypeOptions(config);
+ // Assert.Equal(roleClaimType, options.Role);
+ // Assert.Equal(useridClaimType, options.UserId);
+ // Assert.Equal(usernameClaimType, options.UserName);
+ // Assert.Equal(securityStampClaimType, options.SecurityStamp);
+ //}
+ //[Fact]
+ //public void PasswordOptionsFromConfig()
+ //{
+ // var dic = new Dictionary
+ // {
+ // {"RequiredLength", "10"},
+ // {"RequireNonLetterOrDigit", "false"},
+ // {"RequireUpperCase", "false"},
+ // {"RequireDigit", "false"},
+ // {"RequireLowerCase", "false"}
+ // };
+ // var config = new ConfigurationModel.Configuration { new MemoryConfigurationSource(dic) };
+ // var options = new PasswordOptions(config);
+ // Assert.False(options.RequireDigit);
+ // Assert.False(options.RequireLowercase);
+ // Assert.False(options.RequireNonLetterOrDigit);
+ // Assert.False(options.RequireUppercase);
+ // Assert.Equal(10, options.RequiredLength);
+ //}
}
}
\ No newline at end of file