From 96c9eb7dc62063df81a169fc7f5492a26f10eae1 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 6 Jan 2016 15:36:19 -0800 Subject: [PATCH] Updating to new options pattern --- samples/IdentitySample.Mvc/Startup.cs | 18 +++++++++--------- .../IdentityBuilder.cs | 1 + .../IdentityCookieOptions.cs | 1 + .../IdentityOptions.cs | 3 ++- .../IdentityServiceCollectionExtensions.cs | 2 +- .../SecurityStampValidator.cs | 2 +- src/Microsoft.AspNet.Identity/SignInManager.cs | 1 + .../UserClaimsPrincipalFactory.cs | 3 +-- src/Microsoft.AspNet.Identity/UserManager.cs | 1 + .../ApiConsistencyTest.cs | 1 + .../IdentityBuilderTest.cs | 1 + .../IdentityOptionsTest.cs | 2 +- .../SecurityStampValidatorTest.cs | 2 +- .../SignInManagerTest.cs | 2 +- .../UserClaimsPrincipalFactoryTest.cs | 1 + test/Shared/MockHelpers.cs | 3 ++- test/Shared/UserManagerTestBase.cs | 9 +++++---- 17 files changed, 31 insertions(+), 22 deletions(-) diff --git a/samples/IdentitySample.Mvc/Startup.cs b/samples/IdentitySample.Mvc/Startup.cs index 7542316fbb..aee9c1ec7e 100644 --- a/samples/IdentitySample.Mvc/Startup.cs +++ b/samples/IdentitySample.Mvc/Startup.cs @@ -74,20 +74,20 @@ namespace IdentitySamples app.UseDeveloperExceptionPage() .UseStaticFiles() .UseIdentity() - .UseFacebookAuthentication(options => + .UseFacebookAuthentication(new FacebookOptions { - options.AppId = "901611409868059"; - options.AppSecret = "4aa3c530297b1dcebc8860334b39668b"; + AppId = "901611409868059", + AppSecret = "4aa3c530297b1dcebc8860334b39668b" }) - .UseGoogleAuthentication(options => + .UseGoogleAuthentication(new GoogleOptions { - options.ClientId = "514485782433-fr3ml6sq0imvhi8a7qir0nb46oumtgn9.apps.googleusercontent.com"; - options.ClientSecret = "V2nDD9SkFbvLTqAUBWBBxYAL"; + ClientId = "514485782433-fr3ml6sq0imvhi8a7qir0nb46oumtgn9.apps.googleusercontent.com", + ClientSecret = "V2nDD9SkFbvLTqAUBWBBxYAL" }) - .UseTwitterAuthentication(options => + .UseTwitterAuthentication(new TwitterOptions { - options.ConsumerKey = "BSdJJ0CrDuvEhpkchnukXZBUv"; - options.ConsumerSecret = "xKUNuKhsRdHD03eLn67xhPAyE1wFFEndFo1X2UJaK2m1jdAxf4"; + ConsumerKey = "BSdJJ0CrDuvEhpkchnukXZBUv", + ConsumerSecret = "xKUNuKhsRdHD03eLn67xhPAyE1wFFEndFo1X2UJaK2m1jdAxf4" }) .UseMvc(routes => { diff --git a/src/Microsoft.AspNet.Identity/IdentityBuilder.cs b/src/Microsoft.AspNet.Identity/IdentityBuilder.cs index 8de799249d..50f74e5ed9 100644 --- a/src/Microsoft.AspNet.Identity/IdentityBuilder.cs +++ b/src/Microsoft.AspNet.Identity/IdentityBuilder.cs @@ -3,6 +3,7 @@ using System; using System.Reflection; +using Microsoft.AspNet.Builder; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNet.Identity diff --git a/src/Microsoft.AspNet.Identity/IdentityCookieOptions.cs b/src/Microsoft.AspNet.Identity/IdentityCookieOptions.cs index 01cae9efe2..cb9b253424 100644 --- a/src/Microsoft.AspNet.Identity/IdentityCookieOptions.cs +++ b/src/Microsoft.AspNet.Identity/IdentityCookieOptions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Authentication.Cookies; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Identity diff --git a/src/Microsoft.AspNet.Identity/IdentityOptions.cs b/src/Microsoft.AspNet.Identity/IdentityOptions.cs index 24f716c42a..1349aff90f 100644 --- a/src/Microsoft.AspNet.Identity/IdentityOptions.cs +++ b/src/Microsoft.AspNet.Identity/IdentityOptions.cs @@ -2,8 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Identity; -namespace Microsoft.AspNet.Identity +namespace Microsoft.AspNet.Builder { /// /// Represents all the options you can use to configure the identity system. diff --git a/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs index 5f8b467116..25ccc45cea 100644 --- a/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Identity/IdentityServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Identity; @@ -44,7 +45,6 @@ namespace Microsoft.Extensions.DependencyInjection where TRole : class { // Services used by identity - services.AddOptions(); services.AddAuthentication(options => { // This is the Default value for ExternalCookieAuthenticationScheme diff --git a/src/Microsoft.AspNet.Identity/SecurityStampValidator.cs b/src/Microsoft.AspNet.Identity/SecurityStampValidator.cs index d97326f97a..937eddce0c 100644 --- a/src/Microsoft.AspNet.Identity/SecurityStampValidator.cs +++ b/src/Microsoft.AspNet.Identity/SecurityStampValidator.cs @@ -5,7 +5,7 @@ using System; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Http.Authentication; +using Microsoft.AspNet.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; diff --git a/src/Microsoft.AspNet.Identity/SignInManager.cs b/src/Microsoft.AspNet.Identity/SignInManager.cs index aa65b8d1e0..e97ff0c2f8 100644 --- a/src/Microsoft.AspNet.Identity/SignInManager.cs +++ b/src/Microsoft.AspNet.Identity/SignInManager.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; diff --git a/src/Microsoft.AspNet.Identity/UserClaimsPrincipalFactory.cs b/src/Microsoft.AspNet.Identity/UserClaimsPrincipalFactory.cs index b7ecc6cf2f..2b64496b97 100644 --- a/src/Microsoft.AspNet.Identity/UserClaimsPrincipalFactory.cs +++ b/src/Microsoft.AspNet.Identity/UserClaimsPrincipalFactory.cs @@ -3,9 +3,8 @@ using System; using System.Security.Claims; -using System.Threading; using System.Threading.Tasks; - +using Microsoft.AspNet.Builder; using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Identity diff --git a/src/Microsoft.AspNet.Identity/UserManager.cs b/src/Microsoft.AspNet.Identity/UserManager.cs index ece46126ab..ab786e62b3 100644 --- a/src/Microsoft.AspNet.Identity/UserManager.cs +++ b/src/Microsoft.AspNet.Identity/UserManager.cs @@ -9,6 +9,7 @@ using System.Security.Claims; using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/test/Microsoft.AspNet.Identity.Test/ApiConsistencyTest.cs b/test/Microsoft.AspNet.Identity.Test/ApiConsistencyTest.cs index 85c4d292db..e69b34273f 100644 --- a/test/Microsoft.AspNet.Identity.Test/ApiConsistencyTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/ApiConsistencyTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; +using Microsoft.AspNet.Builder; namespace Microsoft.AspNet.Identity.Test { diff --git a/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs b/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs index b39053624c..d85fcae11b 100644 --- a/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Xunit; diff --git a/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs b/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs index 7dfaa72d35..c0734c96a6 100644 --- a/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/IdentityOptionsTest.cs @@ -4,8 +4,8 @@ using System; using System.Collections.Generic; using System.Security.Claims; +using Microsoft.AspNet.Builder; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Configuration.Memory; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Xunit; diff --git a/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs b/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs index df19a6ac75..75311be395 100644 --- a/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs @@ -6,7 +6,7 @@ using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Authentication.Cookies; -using Microsoft.AspNet.Hosting; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.Extensions.DependencyInjection; diff --git a/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs b/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs index b86e04bb41..d21db0c986 100644 --- a/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Security.Claims; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNet.Hosting; +using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; using Microsoft.AspNet.Http.Features.Authentication; diff --git a/test/Microsoft.AspNet.Identity.Test/UserClaimsPrincipalFactoryTest.cs b/test/Microsoft.AspNet.Identity.Test/UserClaimsPrincipalFactoryTest.cs index ca0adc560d..955c443a96 100644 --- a/test/Microsoft.AspNet.Identity.Test/UserClaimsPrincipalFactoryTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/UserClaimsPrincipalFactoryTest.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; using Microsoft.Extensions.Options; using Moq; using Xunit; diff --git a/test/Shared/MockHelpers.cs b/test/Shared/MockHelpers.cs index 543087af6c..cebc5a1523 100644 --- a/test/Shared/MockHelpers.cs +++ b/test/Shared/MockHelpers.cs @@ -5,9 +5,10 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Text; +using Microsoft.AspNet.Builder; using Microsoft.Extensions.Logging; -using Moq; using Microsoft.Extensions.Options; +using Moq; namespace Microsoft.AspNet.Identity.Test { diff --git a/test/Shared/UserManagerTestBase.cs b/test/Shared/UserManagerTestBase.cs index 705ac6c68f..766f232ac5 100644 --- a/test/Shared/UserManagerTestBase.cs +++ b/test/Shared/UserManagerTestBase.cs @@ -4,16 +4,17 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Xunit; -using System.Linq.Expressions; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Internal; -using Microsoft.AspNet.Testing.xunit; namespace Microsoft.AspNet.Identity.Test {