diff --git a/shared/Mocks/StartupOpenIdConnectTesting.cs b/shared/Mocks/StartupOpenIdConnectTesting.cs index fb64bc15a1..4dca087fd9 100644 --- a/shared/Mocks/StartupOpenIdConnectTesting.cs +++ b/shared/Mocks/StartupOpenIdConnectTesting.cs @@ -120,27 +120,28 @@ namespace MusicStore app.UseIdentity(); // Create an Azure Active directory application and copy paste the following - app.UseOpenIdConnectAuthentication(options => + var options = new OpenIdConnectOptions { - options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com"; - options.ClientId = "c99497aa-3ee2-4707-b8a8-c33f51323fef"; - options.BackchannelHttpHandler = new OpenIdConnectBackChannelHttpHandler(); - options.StringDataFormat = new CustomStringDataFormat(); - options.StateDataFormat = new CustomStateDataFormat(); - options.TokenValidationParameters.ValidateLifetime = false; - options.ProtocolValidator.RequireNonce = true; - options.ProtocolValidator.NonceLifetime = TimeSpan.FromDays(36500); - options.UseTokenLifetime = false; + Authority = "https://login.windows.net/[tenantName].onmicrosoft.com", + ClientId = "c99497aa-3ee2-4707-b8a8-c33f51323fef", + BackchannelHttpHandler = new OpenIdConnectBackChannelHttpHandler(), + StringDataFormat = new CustomStringDataFormat(), + StateDataFormat = new CustomStateDataFormat(), + UseTokenLifetime = false, - options.Events = new OpenIdConnectEvents + Events = new OpenIdConnectEvents { OnMessageReceived = TestOpenIdConnectEvents.MessageReceived, OnAuthorizationCodeReceived = TestOpenIdConnectEvents.AuthorizationCodeReceived, OnRedirectToAuthenticationEndpoint = TestOpenIdConnectEvents.RedirectToAuthenticationEndpoint, OnAuthenticationValidated = TestOpenIdConnectEvents.AuthenticationValidated, OnAuthorizationResponseReceived = TestOpenIdConnectEvents.AuthorizationResponseRecieved - }; - }); + } + }; + options.TokenValidationParameters.ValidateLifetime = false; + options.ProtocolValidator.RequireNonce = true; + options.ProtocolValidator.NonceLifetime = TimeSpan.FromDays(36500); + app.UseOpenIdConnectAuthentication(options); // Add MVC to the request pipeline app.UseMvc(routes => diff --git a/shared/Mocks/StartupSocialTesting.cs b/shared/Mocks/StartupSocialTesting.cs index 068fc11742..3ff7f6c423 100644 --- a/shared/Mocks/StartupSocialTesting.cs +++ b/shared/Mocks/StartupSocialTesting.cs @@ -128,67 +128,64 @@ namespace MusicStore // Add cookie-based authentication to the request pipeline app.UseIdentity(); - app.UseFacebookAuthentication(options => + app.UseFacebookAuthentication(new FacebookOptions { - options.AppId = "[AppId]"; - options.AppSecret = "[AppSecret]"; - options.Events = new OAuthEvents() + AppId = "[AppId]", + AppSecret = "[AppSecret]", + Events = new OAuthEvents() { OnCreatingTicket = TestFacebookEvents.OnCreatingTicket, OnTicketReceived = TestFacebookEvents.OnTicketReceived, OnRedirectToAuthorizationEndpoint = TestFacebookEvents.RedirectToAuthorizationEndpoint - }; - options.BackchannelHttpHandler = new FacebookMockBackChannelHttpHandler(); - options.StateDataFormat = new CustomStateDataFormat(); - options.Scope.Add("email"); - options.Scope.Add("read_friendlists"); - options.Scope.Add("user_checkins"); + }, + BackchannelHttpHandler = new FacebookMockBackChannelHttpHandler(), + StateDataFormat = new CustomStateDataFormat(), + Scope = { "email", "read_friendlists", "user_checkins" } }); - app.UseGoogleAuthentication(options => + app.UseGoogleAuthentication(new GoogleOptions { - options.ClientId = "[ClientId]"; - options.ClientSecret = "[ClientSecret]"; - options.AccessType = "offline"; - options.Events = new OAuthEvents() + ClientId = "[ClientId]", + ClientSecret = "[ClientSecret]", + AccessType = "offline", + Events = new OAuthEvents() { OnCreatingTicket = TestGoogleEvents.OnCreatingTicket, OnTicketReceived = TestGoogleEvents.OnTicketReceived, OnRedirectToAuthorizationEndpoint = TestGoogleEvents.RedirectToAuthorizationEndpoint - }; - options.StateDataFormat = new CustomStateDataFormat(); - options.BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler(); + }, + StateDataFormat = new CustomStateDataFormat(), + BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler() }); - app.UseTwitterAuthentication(options => + app.UseTwitterAuthentication(new TwitterOptions { - options.ConsumerKey = "[ConsumerKey]"; - options.ConsumerSecret = "[ConsumerSecret]"; - options.Events = new TwitterEvents() + ConsumerKey = "[ConsumerKey]", + ConsumerSecret = "[ConsumerSecret]", + Events = new TwitterEvents() { OnCreatingTicket = TestTwitterEvents.OnCreatingTicket, OnTicketReceived = TestTwitterEvents.OnTicketReceived, OnRedirectToAuthorizationEndpoint = TestTwitterEvents.RedirectToAuthorizationEndpoint - }; - options.StateDataFormat = new CustomTwitterStateDataFormat(); - options.BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler(); + }, + StateDataFormat = new CustomTwitterStateDataFormat(), + BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler() }); - app.UseMicrosoftAccountAuthentication(options => + app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions { - options.DisplayName = "MicrosoftAccount - Requires project changes"; - options.ClientId = "[ClientId]"; - options.ClientSecret = "[ClientSecret]"; - options.Events = new OAuthEvents() + DisplayName = "MicrosoftAccount - Requires project changes", + ClientId = "[ClientId]", + ClientSecret = "[ClientSecret]", + Events = new OAuthEvents() { OnCreatingTicket = TestMicrosoftAccountEvents.OnCreatingTicket, OnTicketReceived = TestMicrosoftAccountEvents.OnTicketReceived, OnRedirectToAuthorizationEndpoint = TestMicrosoftAccountEvents.RedirectToAuthorizationEndpoint - }; - options.BackchannelHttpHandler = new MicrosoftAccountMockBackChannelHandler(); - options.StateDataFormat = new CustomStateDataFormat(); - options.Scope.Add("wl.basic"); - options.Scope.Add("wl.signin"); + }, + BackchannelHttpHandler = new MicrosoftAccountMockBackChannelHandler(), + StateDataFormat = new CustomStateDataFormat(), + Scope = { "wl.basic", "wl.signin" } }); // Add MVC to the request pipeline diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index 8244573723..ebe93b7bde 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -158,22 +158,22 @@ namespace MusicStore // Add cookie-based authentication to the request pipeline app.UseIdentity(); - app.UseFacebookAuthentication(options => + app.UseFacebookAuthentication(new FacebookOptions { - options.AppId = "550624398330273"; - options.AppSecret = "10e56a291d6b618da61b1e0dae3a8954"; + AppId = "550624398330273", + AppSecret = "10e56a291d6b618da61b1e0dae3a8954" }); - app.UseGoogleAuthentication(options => + app.UseGoogleAuthentication(new GoogleOptions { - options.ClientId = "995291875932-0rt7417v5baevqrno24kv332b7d6d30a.apps.googleusercontent.com"; - options.ClientSecret = "J_AT57H5KH_ItmMdu0r6PfXm"; + ClientId = "995291875932-0rt7417v5baevqrno24kv332b7d6d30a.apps.googleusercontent.com", + ClientSecret = "J_AT57H5KH_ItmMdu0r6PfXm" }); - app.UseTwitterAuthentication(options => + app.UseTwitterAuthentication(new TwitterOptions { - options.ConsumerKey = "lDSPIu480ocnXYZ9DumGCDw37"; - options.ConsumerSecret = "fpo0oWRNc3vsZKlZSq1PyOSoeXlJd7NnG4Rfc94xbFXsdcc3nH"; + ConsumerKey = "lDSPIu480ocnXYZ9DumGCDw37", + ConsumerSecret = "fpo0oWRNc3vsZKlZSq1PyOSoeXlJd7NnG4Rfc94xbFXsdcc3nH" }); // The MicrosoftAccount service has restrictions that prevent the use of @@ -192,11 +192,11 @@ namespace MusicStore // The sample app can then be run via: // dnx . web - app.UseMicrosoftAccountAuthentication(options => + app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions { - options.DisplayName = "MicrosoftAccount - Requires project changes"; - options.ClientId = "000000004012C08A"; - options.ClientSecret = "GaMQ2hCnqAC6EcDLnXsAeBVIJOLmeutL"; + DisplayName = "MicrosoftAccount - Requires project changes", + ClientId = "000000004012C08A", + ClientSecret = "GaMQ2hCnqAC6EcDLnXsAeBVIJOLmeutL" }); // Add MVC to the request pipeline diff --git a/src/MusicStore/StartupOpenIdConnect.cs b/src/MusicStore/StartupOpenIdConnect.cs index 232d2ce654..211894403a 100644 --- a/src/MusicStore/StartupOpenIdConnect.cs +++ b/src/MusicStore/StartupOpenIdConnect.cs @@ -133,10 +133,10 @@ namespace MusicStore app.UseIdentity(); // Create an Azure Active directory application and copy paste the following - app.UseOpenIdConnectAuthentication(options => + app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions { - options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com"; - options.ClientId = "[ClientId]"; + Authority = "https://login.windows.net/[tenantName].onmicrosoft.com", + ClientId = "[ClientId]" }); // Add MVC to the request pipeline