From fa9cba8a7afb5316c98df949b7f524fc9e29454f Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 23 Sep 2015 13:48:31 -0700 Subject: [PATCH] React to security --- .../Mocks/Facebook/TestFacebookEvents.cs | 7 +++--- .../shared/Mocks/Google/TestGoogleEvents.cs | 9 +++---- .../TestMicrosoftAccountEvents.cs | 7 +++--- .../shared/Mocks/StartupSocialTesting.cs | 24 +++++++++---------- .../shared/Mocks/Twitter/TestTwitterEvents.cs | 7 +++--- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/test/E2ETests/compiler/shared/Mocks/Facebook/TestFacebookEvents.cs b/test/E2ETests/compiler/shared/Mocks/Facebook/TestFacebookEvents.cs index 65ae417810..52586af751 100644 --- a/test/E2ETests/compiler/shared/Mocks/Facebook/TestFacebookEvents.cs +++ b/test/E2ETests/compiler/shared/Mocks/Facebook/TestFacebookEvents.cs @@ -3,6 +3,7 @@ using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Authentication.Facebook; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Identity; @@ -12,7 +13,7 @@ namespace MusicStore.Mocks.Facebook { internal class TestFacebookEvents { - internal static Task OnAuthenticated(OAuthAuthenticatedContext context) + internal static Task OnCreatingTicket(OAuthCreatingTicketContext context) { if (context.Principal != null) { @@ -31,7 +32,7 @@ namespace MusicStore.Mocks.Facebook return Task.FromResult(0); } - internal static Task OnReturnEndpoint(OAuthReturnEndpointContext context) + internal static Task OnSigningIn(SigningInContext context) { if (context.Principal != null && context.SignInScheme == new IdentityCookieOptions().ExternalCookieAuthenticationScheme) { @@ -48,7 +49,7 @@ namespace MusicStore.Mocks.Facebook return Task.FromResult(0); } - internal static Task OnApplyRedirect(OAuthApplyRedirectContext context) + internal static Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) { context.Response.Redirect(context.RedirectUri + "&custom_redirect_uri=custom"); return Task.FromResult(0); diff --git a/test/E2ETests/compiler/shared/Mocks/Google/TestGoogleEvents.cs b/test/E2ETests/compiler/shared/Mocks/Google/TestGoogleEvents.cs index 420aba6f45..46f7222d92 100644 --- a/test/E2ETests/compiler/shared/Mocks/Google/TestGoogleEvents.cs +++ b/test/E2ETests/compiler/shared/Mocks/Google/TestGoogleEvents.cs @@ -3,6 +3,7 @@ using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Authentication.Google; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Identity; @@ -12,7 +13,7 @@ namespace MusicStore.Mocks.Google { internal class TestGoogleEvents { - internal static Task OnAuthenticated(OAuthAuthenticatedContext context) + internal static Task OnCreatingTicket(OAuthCreatingTicketContext context) { if (context.Principal != null) { @@ -30,7 +31,7 @@ namespace MusicStore.Mocks.Google return Task.FromResult(0); } - internal static async Task OnReturnEndpoint(OAuthReturnEndpointContext context) + internal static Task OnSigningIn(SigningInContext context) { if (context.Principal != null && context.SignInScheme == new IdentityCookieOptions().ExternalCookieAuthenticationScheme) { @@ -44,10 +45,10 @@ namespace MusicStore.Mocks.Google } } - await Task.FromResult(0); + return Task.FromResult(0); } - internal static Task OnApplyRedirect(OAuthApplyRedirectContext context) + internal static Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) { context.Response.Redirect(context.RedirectUri + "&custom_redirect_uri=custom"); return Task.FromResult(0); diff --git a/test/E2ETests/compiler/shared/Mocks/MicrosoftAccount/TestMicrosoftAccountEvents.cs b/test/E2ETests/compiler/shared/Mocks/MicrosoftAccount/TestMicrosoftAccountEvents.cs index a5322ca2d1..5d4c531bd1 100644 --- a/test/E2ETests/compiler/shared/Mocks/MicrosoftAccount/TestMicrosoftAccountEvents.cs +++ b/test/E2ETests/compiler/shared/Mocks/MicrosoftAccount/TestMicrosoftAccountEvents.cs @@ -3,6 +3,7 @@ using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Authentication.MicrosoftAccount; using Microsoft.AspNet.Authentication.OAuth; using Microsoft.AspNet.Identity; @@ -12,7 +13,7 @@ namespace MusicStore.Mocks.MicrosoftAccount { internal class TestMicrosoftAccountEvents { - internal static Task OnAuthenticated(OAuthAuthenticatedContext context) + internal static Task OnCreatingTicket(OAuthCreatingTicketContext context) { if (context.Principal != null) { @@ -31,7 +32,7 @@ namespace MusicStore.Mocks.MicrosoftAccount return Task.FromResult(0); } - internal static Task OnReturnEndpoint(OAuthReturnEndpointContext context) + internal static Task OnSigningIn(SigningInContext context) { if (context.Principal != null && context.SignInScheme == new IdentityCookieOptions().ExternalCookieAuthenticationScheme) { @@ -48,7 +49,7 @@ namespace MusicStore.Mocks.MicrosoftAccount return Task.FromResult(0); } - internal static Task OnApplyRedirect(OAuthApplyRedirectContext context) + internal static Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) { context.Response.Redirect(context.RedirectUri + "&custom_redirect_uri=custom"); return Task.FromResult(0); diff --git a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs index 6b7dc48f24..e8413eb686 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs @@ -135,9 +135,9 @@ namespace MusicStore options.AppSecret = "[AppSecret]"; options.Events = new OAuthEvents() { - OnAuthenticated = TestFacebookEvents.OnAuthenticated, - OnReturnEndpoint = TestFacebookEvents.OnReturnEndpoint, - OnApplyRedirect = TestFacebookEvents.OnApplyRedirect + OnCreatingTicket = TestFacebookEvents.OnCreatingTicket, + OnSigningIn = TestFacebookEvents.OnSigningIn, + OnRedirectToAuthorizationEndpoint = TestFacebookEvents.RedirectToAuthorizationEndpoint }; options.BackchannelHttpHandler = new FacebookMockBackChannelHttpHandler(); options.StateDataFormat = new CustomStateDataFormat(); @@ -153,9 +153,9 @@ namespace MusicStore options.AccessType = "offline"; options.Events = new OAuthEvents() { - OnAuthenticated = TestGoogleEvents.OnAuthenticated, - OnReturnEndpoint = TestGoogleEvents.OnReturnEndpoint, - OnApplyRedirect = TestGoogleEvents.OnApplyRedirect + OnCreatingTicket = TestGoogleEvents.OnCreatingTicket, + OnSigningIn = TestGoogleEvents.OnSigningIn, + OnRedirectToAuthorizationEndpoint = TestGoogleEvents.RedirectToAuthorizationEndpoint }; options.StateDataFormat = new CustomStateDataFormat(); options.BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler(); @@ -167,9 +167,9 @@ namespace MusicStore options.ConsumerSecret = "[ConsumerSecret]"; options.Events = new TwitterEvents() { - OnAuthenticated = TestTwitterEvents.OnAuthenticated, - OnReturnEndpoint = TestTwitterEvents.OnReturnEndpoint, - OnApplyRedirect = TestTwitterEvents.OnApplyRedirect + OnCreatingTicket = TestTwitterEvents.OnCreatingTicket, + OnSigningIn = TestTwitterEvents.OnSigningIn, + OnRedirectToAuthorizationEndpoint = TestTwitterEvents.RedirectToAuthorizationEndpoint }; options.StateDataFormat = new CustomTwitterStateDataFormat(); options.BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler(); @@ -182,9 +182,9 @@ namespace MusicStore options.ClientSecret = "[ClientSecret]"; options.Events = new OAuthEvents() { - OnAuthenticated = TestMicrosoftAccountEvents.OnAuthenticated, - OnReturnEndpoint = TestMicrosoftAccountEvents.OnReturnEndpoint, - OnApplyRedirect = TestMicrosoftAccountEvents.OnApplyRedirect + OnCreatingTicket = TestMicrosoftAccountEvents.OnCreatingTicket, + OnSigningIn = TestMicrosoftAccountEvents.OnSigningIn, + OnRedirectToAuthorizationEndpoint = TestMicrosoftAccountEvents.RedirectToAuthorizationEndpoint }; options.BackchannelHttpHandler = new MicrosoftAccountMockBackChannelHandler(); options.StateDataFormat = new CustomStateDataFormat(); diff --git a/test/E2ETests/compiler/shared/Mocks/Twitter/TestTwitterEvents.cs b/test/E2ETests/compiler/shared/Mocks/Twitter/TestTwitterEvents.cs index 94a7eb7fcc..573e5ca51f 100644 --- a/test/E2ETests/compiler/shared/Mocks/Twitter/TestTwitterEvents.cs +++ b/test/E2ETests/compiler/shared/Mocks/Twitter/TestTwitterEvents.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Security.Claims; using System.Threading.Tasks; +using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Authentication.Twitter; using Microsoft.AspNet.Identity; using MusicStore.Mocks.Common; @@ -10,7 +11,7 @@ namespace MusicStore.Mocks.Twitter { internal class TestTwitterEvents { - internal static Task OnAuthenticated(TwitterAuthenticatedContext context) + internal static Task OnCreatingTicket(TwitterCreatingTicketContext context) { if (context.Principal != null) { @@ -24,7 +25,7 @@ namespace MusicStore.Mocks.Twitter return Task.FromResult(0); } - internal static Task OnReturnEndpoint(TwitterReturnEndpointContext context) + internal static Task OnSigningIn(SigningInContext context) { if (context.Principal != null && context.SignInScheme == new IdentityCookieOptions().ExternalCookieAuthenticationScheme) { @@ -41,7 +42,7 @@ namespace MusicStore.Mocks.Twitter return Task.FromResult(0); } - internal static Task OnApplyRedirect(TwitterApplyRedirectContext context) + internal static Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context) { context.Response.Redirect(context.RedirectUri + "&custom_redirect_uri=custom"); return Task.FromResult(0);