React to identity/options/security changes
This commit is contained in:
parent
f332bf6800
commit
95c7a659c2
|
|
@ -282,7 +282,7 @@ namespace MusicStore.Controllers
|
||||||
{
|
{
|
||||||
// Request a redirect to the external login provider
|
// Request a redirect to the external login provider
|
||||||
var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl });
|
var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl });
|
||||||
var properties = Context.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
|
var properties = SignInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
|
||||||
return new ChallengeResult(provider, properties);
|
return new ChallengeResult(provider, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,7 +328,7 @@ namespace MusicStore.Controllers
|
||||||
public async Task<ActionResult> ExternalLoginCallback(string returnUrl = null)
|
public async Task<ActionResult> ExternalLoginCallback(string returnUrl = null)
|
||||||
{
|
{
|
||||||
//https://github.com/aspnet/Identity/issues/216
|
//https://github.com/aspnet/Identity/issues/216
|
||||||
var loginInfo = await Context.GetExternalLoginInfo();
|
var loginInfo = await SignInManager.GetExternalLoginInfoAsync();
|
||||||
if (loginInfo == null)
|
if (loginInfo == null)
|
||||||
{
|
{
|
||||||
return RedirectToAction("Login");
|
return RedirectToAction("Login");
|
||||||
|
|
@ -371,7 +371,7 @@ namespace MusicStore.Controllers
|
||||||
{
|
{
|
||||||
// Get the information about the user from the external login provider
|
// Get the information about the user from the external login provider
|
||||||
//https://github.com/aspnet/Identity/issues/216
|
//https://github.com/aspnet/Identity/issues/216
|
||||||
var info = await Context.GetExternalLoginInfo();
|
var info = await SignInManager.GetExternalLoginInfoAsync();
|
||||||
if (info == null)
|
if (info == null)
|
||||||
{
|
{
|
||||||
return View("ExternalLoginFailure");
|
return View("ExternalLoginFailure");
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ namespace MusicStore.Controllers
|
||||||
return View("Error");
|
return View("Error");
|
||||||
}
|
}
|
||||||
var userLogins = await UserManager.GetLoginsAsync(user, cancellationToken: Context.RequestAborted);
|
var userLogins = await UserManager.GetLoginsAsync(user, cancellationToken: Context.RequestAborted);
|
||||||
var otherLogins = Context.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => auth.AuthenticationType != ul.LoginProvider)).ToList();
|
var otherLogins = SignInManager.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => auth.AuthenticationType != ul.LoginProvider)).ToList();
|
||||||
ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count > 1;
|
ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count > 1;
|
||||||
return View(new ManageLoginsViewModel
|
return View(new ManageLoginsViewModel
|
||||||
{
|
{
|
||||||
|
|
@ -311,7 +311,7 @@ namespace MusicStore.Controllers
|
||||||
{
|
{
|
||||||
// Request a redirect to the external login provider to link a login for the current user
|
// Request a redirect to the external login provider to link a login for the current user
|
||||||
var redirectUrl = Url.Action("LinkLoginCallback", "Manage");
|
var redirectUrl = Url.Action("LinkLoginCallback", "Manage");
|
||||||
var properties = Context.ConfigureExternalAuthenticationProperties(provider, redirectUrl, User.Identity.GetUserId());
|
var properties = SignInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, User.Identity.GetUserId());
|
||||||
return new ChallengeResult(provider, properties);
|
return new ChallengeResult(provider, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -325,7 +325,7 @@ namespace MusicStore.Controllers
|
||||||
return View("Error");
|
return View("Error");
|
||||||
}
|
}
|
||||||
//https://github.com/aspnet/Identity/issues/216
|
//https://github.com/aspnet/Identity/issues/216
|
||||||
var loginInfo = await Context.GetExternalLoginInfo(User.Identity.GetUserId());
|
var loginInfo = await SignInManager.GetExternalLoginInfoAsync(User.Identity.GetUserId());
|
||||||
if (loginInfo == null)
|
if (loginInfo == null)
|
||||||
{
|
{
|
||||||
return RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error });
|
return RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error });
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,6 @@ namespace MusicStore
|
||||||
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
||||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||||
|
|
||||||
app.SetDefaultSignInAsAuthenticationType("External");
|
|
||||||
|
|
||||||
app.UseServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
//If this type is present - we're on mono
|
//If this type is present - we're on mono
|
||||||
|
|
@ -62,23 +60,40 @@ namespace MusicStore
|
||||||
services.AddScoped<MusicStoreContext>();
|
services.AddScoped<MusicStoreContext>();
|
||||||
|
|
||||||
// Configure DbContext
|
// Configure DbContext
|
||||||
services.SetupOptions<MusicStoreDbContextOptions>(options =>
|
services.ConfigureOptions<MusicStoreDbContextOptions>(options =>
|
||||||
{
|
{
|
||||||
options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername");
|
options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername");
|
||||||
options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword");
|
options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword");
|
||||||
if (runningOnMono)
|
if (runningOnMono)
|
||||||
{
|
{
|
||||||
options.UseInMemoryStore();
|
options.UseInMemoryStore();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
|
options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add Identity services to the services container
|
// Add Identity services to the services container
|
||||||
services.AddDefaultIdentity<MusicStoreContext, ApplicationUser, IdentityRole>(configuration);
|
services.AddDefaultIdentity<MusicStoreContext, ApplicationUser, IdentityRole>(configuration);
|
||||||
|
|
||||||
|
services.ConfigureFacebookAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.AppId = "[AppId]";
|
||||||
|
options.AppSecret = "[AppSecret]";
|
||||||
|
options.Notifications = new FacebookAuthenticationNotifications()
|
||||||
|
{
|
||||||
|
OnAuthenticated = FacebookNotifications.OnAuthenticated,
|
||||||
|
OnReturnEndpoint = FacebookNotifications.OnReturnEndpoint,
|
||||||
|
OnApplyRedirect = FacebookNotifications.OnApplyRedirect
|
||||||
|
};
|
||||||
|
options.BackchannelHttpHandler = new FacebookMockBackChannelHttpHandler();
|
||||||
|
options.StateDataFormat = new CustomStateDataFormat();
|
||||||
|
options.Scope.Add("email");
|
||||||
|
options.Scope.Add("read_friendlists");
|
||||||
|
options.Scope.Add("user_checkins");
|
||||||
|
});
|
||||||
|
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
|
|
||||||
|
|
@ -119,76 +134,56 @@ namespace MusicStore
|
||||||
// Add cookie-based authentication to the request pipeline
|
// Add cookie-based authentication to the request pipeline
|
||||||
app.UseIdentity();
|
app.UseIdentity();
|
||||||
|
|
||||||
var facebookOptions = new FacebookAuthenticationOptions()
|
app.UseFacebookAuthentication();
|
||||||
|
|
||||||
|
app.UseGoogleAuthentication(options =>
|
||||||
{
|
{
|
||||||
AppId = "[AppId]",
|
options.ClientId = "[ClientId]";
|
||||||
AppSecret = "[AppSecret]",
|
options.ClientSecret = "[ClientSecret]";
|
||||||
Notifications = new FacebookAuthenticationNotifications()
|
options.AccessType = "offline";
|
||||||
{
|
options.Notifications = new GoogleAuthenticationNotifications()
|
||||||
OnAuthenticated = FacebookNotifications.OnAuthenticated,
|
|
||||||
OnReturnEndpoint = FacebookNotifications.OnReturnEndpoint,
|
|
||||||
OnApplyRedirect = FacebookNotifications.OnApplyRedirect
|
|
||||||
},
|
|
||||||
BackchannelHttpHandler = new FacebookMockBackChannelHttpHandler(),
|
|
||||||
StateDataFormat = new CustomStateDataFormat()
|
|
||||||
};
|
|
||||||
|
|
||||||
facebookOptions.Scope.Add("email");
|
|
||||||
facebookOptions.Scope.Add("read_friendlists");
|
|
||||||
facebookOptions.Scope.Add("user_checkins");
|
|
||||||
|
|
||||||
app.UseFacebookAuthentication(facebookOptions);
|
|
||||||
|
|
||||||
app.UseGoogleAuthentication(new GoogleAuthenticationOptions()
|
|
||||||
{
|
|
||||||
ClientId = "[ClientId]",
|
|
||||||
ClientSecret = "[ClientSecret]",
|
|
||||||
AccessType = "offline",
|
|
||||||
Notifications = new GoogleAuthenticationNotifications()
|
|
||||||
{
|
{
|
||||||
OnAuthenticated = GoogleNotifications.OnAuthenticated,
|
OnAuthenticated = GoogleNotifications.OnAuthenticated,
|
||||||
OnReturnEndpoint = GoogleNotifications.OnReturnEndpoint,
|
OnReturnEndpoint = GoogleNotifications.OnReturnEndpoint,
|
||||||
OnApplyRedirect = GoogleNotifications.OnApplyRedirect
|
OnApplyRedirect = GoogleNotifications.OnApplyRedirect
|
||||||
},
|
};
|
||||||
StateDataFormat = new CustomStateDataFormat(),
|
options.StateDataFormat = new CustomStateDataFormat();
|
||||||
BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler()
|
options.BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseTwitterAuthentication(new TwitterAuthenticationOptions()
|
app.UseTwitterAuthentication(options =>
|
||||||
{
|
{
|
||||||
ConsumerKey = "[ConsumerKey]",
|
options.ConsumerKey = "[ConsumerKey]";
|
||||||
ConsumerSecret = "[ConsumerSecret]",
|
options.ConsumerSecret = "[ConsumerSecret]";
|
||||||
Notifications = new TwitterAuthenticationNotifications()
|
options.Notifications = new TwitterAuthenticationNotifications()
|
||||||
{
|
{
|
||||||
OnAuthenticated = TwitterNotifications.OnAuthenticated,
|
OnAuthenticated = TwitterNotifications.OnAuthenticated,
|
||||||
OnReturnEndpoint = TwitterNotifications.OnReturnEndpoint,
|
OnReturnEndpoint = TwitterNotifications.OnReturnEndpoint,
|
||||||
OnApplyRedirect = TwitterNotifications.OnApplyRedirect
|
OnApplyRedirect = TwitterNotifications.OnApplyRedirect
|
||||||
},
|
};
|
||||||
StateDataFormat = new CustomTwitterStateDataFormat(),
|
options.StateDataFormat = new CustomTwitterStateDataFormat();
|
||||||
BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler(),
|
options.BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler();
|
||||||
#if ASPNET50
|
#if ASPNET50
|
||||||
BackchannelCertificateValidator = null
|
options.BackchannelCertificateValidator = null;
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
var microsoftAccountOptions = new MicrosoftAccountAuthenticationOptions()
|
app.UseMicrosoftAccountAuthentication(options =>
|
||||||
{
|
{
|
||||||
Caption = "MicrosoftAccount - Requires project changes",
|
options.Caption = "MicrosoftAccount - Requires project changes";
|
||||||
ClientId = "[ClientId]",
|
options.ClientId = "[ClientId]";
|
||||||
ClientSecret = "[ClientSecret]",
|
options.ClientSecret = "[ClientSecret]";
|
||||||
Notifications = new MicrosoftAccountAuthenticationNotifications()
|
options.Notifications = new MicrosoftAccountAuthenticationNotifications()
|
||||||
{
|
{
|
||||||
OnAuthenticated = MicrosoftAccountNotifications.OnAuthenticated,
|
OnAuthenticated = MicrosoftAccountNotifications.OnAuthenticated,
|
||||||
OnReturnEndpoint = MicrosoftAccountNotifications.OnReturnEndpoint,
|
OnReturnEndpoint = MicrosoftAccountNotifications.OnReturnEndpoint,
|
||||||
OnApplyRedirect = MicrosoftAccountNotifications.OnApplyRedirect
|
OnApplyRedirect = MicrosoftAccountNotifications.OnApplyRedirect
|
||||||
},
|
};
|
||||||
BackchannelHttpHandler = new MicrosoftAccountMockBackChannelHandler(),
|
options.BackchannelHttpHandler = new MicrosoftAccountMockBackChannelHandler();
|
||||||
StateDataFormat = new CustomStateDataFormat()
|
options.StateDataFormat = new CustomStateDataFormat();
|
||||||
};
|
options.Scope.Add("wl.basic");
|
||||||
|
options.Scope.Add("wl.signin");
|
||||||
microsoftAccountOptions.Scope.Add("wl.basic");
|
});
|
||||||
microsoftAccountOptions.Scope.Add("wl.signin");
|
|
||||||
app.UseMicrosoftAccountAuthentication(microsoftAccountOptions);
|
|
||||||
|
|
||||||
// Add MVC to the request pipeline
|
// Add MVC to the request pipeline
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
|
|
|
||||||
|
|
@ -17,65 +17,98 @@ namespace MusicStore
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public void Configure(IApplicationBuilder app)
|
public Startup()
|
||||||
{
|
{
|
||||||
//Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
|
//Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
|
||||||
//then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
|
//then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
|
||||||
var configuration = new Configuration()
|
Configuration = new Configuration()
|
||||||
.AddJsonFile("config.json")
|
.AddJsonFile("config.json")
|
||||||
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
|
||||||
|
}
|
||||||
|
|
||||||
|
public IConfiguration Configuration { get; private set; }
|
||||||
|
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
//If this type is present - we're on mono
|
||||||
|
var runningOnMono = Type.GetType("Mono.Runtime") != null;
|
||||||
|
|
||||||
|
// Add EF services to the services container
|
||||||
|
if (runningOnMono)
|
||||||
|
{
|
||||||
|
services.AddEntityFramework()
|
||||||
|
.AddInMemoryStore();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
services.AddEntityFramework()
|
||||||
|
.AddSqlServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
services.AddScoped<MusicStoreContext>();
|
||||||
|
|
||||||
|
// Configure DbContext
|
||||||
|
services.ConfigureOptions<MusicStoreDbContextOptions>(options =>
|
||||||
|
{
|
||||||
|
options.DefaultAdminUserName = Configuration.Get("DefaultAdminUsername");
|
||||||
|
options.DefaultAdminPassword = Configuration.Get("DefaultAdminPassword");
|
||||||
|
if (runningOnMono)
|
||||||
|
{
|
||||||
|
options.UseInMemoryStore();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options.UseSqlServer(Configuration.Get("Data:DefaultConnection:ConnectionString"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add Identity services to the services container
|
||||||
|
services.AddDefaultIdentity<MusicStoreContext, ApplicationUser, IdentityRole>(Configuration);
|
||||||
|
|
||||||
|
services.ConfigureFacebookAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.AppId = "550624398330273";
|
||||||
|
options.AppSecret = "10e56a291d6b618da61b1e0dae3a8954";
|
||||||
|
});
|
||||||
|
|
||||||
|
services.ConfigureGoogleAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.ClientId = "977382855444.apps.googleusercontent.com";
|
||||||
|
options.ClientSecret = "NafT482F70Vjj_9q1PU4B0pN";
|
||||||
|
});
|
||||||
|
|
||||||
|
services.ConfigureTwitterAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.ConsumerKey = "9J3j3pSwgbWkgPFH7nAf0Spam";
|
||||||
|
options.ConsumerSecret = "jUBYkQuBFyqp7G3CUB9SW3AfflFr9z3oQBiNvumYy87Al0W4h8";
|
||||||
|
});
|
||||||
|
|
||||||
|
services.ConfigureMicrosoftAccountAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.Caption = "MicrosoftAccount - Requires project changes";
|
||||||
|
options.ClientId = "000000004012C08A";
|
||||||
|
options.ClientSecret = "GaMQ2hCnqAC6EcDLnXsAeBVIJOLmeutL";
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add MVC services to the services container
|
||||||
|
services.AddMvc();
|
||||||
|
|
||||||
|
//Add all SignalR related services to IoC.
|
||||||
|
services.AddSignalR();
|
||||||
|
|
||||||
|
//Add InMemoryCache
|
||||||
|
//Currently not able to AddSingleTon
|
||||||
|
services.AddInstance<IMemoryCache>(new MemoryCache());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Configure(IApplicationBuilder app)
|
||||||
|
{
|
||||||
//Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
|
//Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
|
||||||
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
||||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||||
|
|
||||||
app.UseServices(services =>
|
// Add services from ConfigureServices
|
||||||
{
|
app.UseServices();
|
||||||
//If this type is present - we're on mono
|
|
||||||
var runningOnMono = Type.GetType("Mono.Runtime") != null;
|
|
||||||
|
|
||||||
// Add EF services to the services container
|
|
||||||
if (runningOnMono)
|
|
||||||
{
|
|
||||||
services.AddEntityFramework()
|
|
||||||
.AddInMemoryStore();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
services.AddEntityFramework()
|
|
||||||
.AddSqlServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
services.AddScoped<MusicStoreContext>();
|
|
||||||
|
|
||||||
// Configure DbContext
|
|
||||||
services.SetupOptions<MusicStoreDbContextOptions>(options =>
|
|
||||||
{
|
|
||||||
options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername");
|
|
||||||
options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword");
|
|
||||||
if (runningOnMono)
|
|
||||||
{
|
|
||||||
options.UseInMemoryStore();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add Identity services to the services container
|
|
||||||
services.AddDefaultIdentity<MusicStoreContext, ApplicationUser, IdentityRole>(configuration);
|
|
||||||
|
|
||||||
// Add MVC services to the services container
|
|
||||||
services.AddMvc();
|
|
||||||
|
|
||||||
//Add all SignalR related services to IoC.
|
|
||||||
services.AddSignalR();
|
|
||||||
|
|
||||||
//Add InMemoryCache
|
|
||||||
//Currently not able to AddSingleTon
|
|
||||||
services.AddInstance<IMemoryCache>(new MemoryCache());
|
|
||||||
});
|
|
||||||
|
|
||||||
//Configure SignalR
|
//Configure SignalR
|
||||||
app.UseSignalR();
|
app.UseSignalR();
|
||||||
|
|
@ -86,23 +119,11 @@ namespace MusicStore
|
||||||
// Add cookie-based authentication to the request pipeline
|
// Add cookie-based authentication to the request pipeline
|
||||||
app.UseIdentity();
|
app.UseIdentity();
|
||||||
|
|
||||||
app.UseFacebookAuthentication(new FacebookAuthenticationOptions()
|
app.UseFacebookAuthentication();
|
||||||
{
|
|
||||||
AppId = "550624398330273",
|
|
||||||
AppSecret = "10e56a291d6b618da61b1e0dae3a8954",
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseGoogleAuthentication(new GoogleAuthenticationOptions()
|
app.UseGoogleAuthentication();
|
||||||
{
|
|
||||||
ClientId = "977382855444.apps.googleusercontent.com",
|
|
||||||
ClientSecret = "NafT482F70Vjj_9q1PU4B0pN",
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseTwitterAuthentication(new TwitterAuthenticationOptions()
|
app.UseTwitterAuthentication();
|
||||||
{
|
|
||||||
ConsumerKey = "9J3j3pSwgbWkgPFH7nAf0Spam",
|
|
||||||
ConsumerSecret = "jUBYkQuBFyqp7G3CUB9SW3AfflFr9z3oQBiNvumYy87Al0W4h8",
|
|
||||||
});
|
|
||||||
|
|
||||||
//The MicrosoftAccount service has restrictions that prevent the use of http://localhost:5001/ for test applications.
|
//The MicrosoftAccount service has restrictions that prevent the use of http://localhost:5001/ for test applications.
|
||||||
//As such, here is how to change this sample to uses http://ktesting.com:5001/ instead.
|
//As such, here is how to change this sample to uses http://ktesting.com:5001/ instead.
|
||||||
|
|
@ -119,12 +140,7 @@ namespace MusicStore
|
||||||
|
|
||||||
//The sample app can then be run via:
|
//The sample app can then be run via:
|
||||||
// k web
|
// k web
|
||||||
app.UseMicrosoftAccountAuthentication(new MicrosoftAccountAuthenticationOptions()
|
app.UseMicrosoftAccountAuthentication();
|
||||||
{
|
|
||||||
Caption = "MicrosoftAccount - Requires project changes",
|
|
||||||
ClientId = "000000004012C08A",
|
|
||||||
ClientSecret = "GaMQ2hCnqAC6EcDLnXsAeBVIJOLmeutL",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add MVC to the request pipeline
|
// Add MVC to the request pipeline
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ namespace MusicStore
|
||||||
services.AddScoped<MusicStoreContext>();
|
services.AddScoped<MusicStoreContext>();
|
||||||
|
|
||||||
// Configure DbContext
|
// Configure DbContext
|
||||||
services.SetupOptions<MusicStoreDbContextOptions>(options =>
|
services.ConfigureOptions<MusicStoreDbContextOptions>(options =>
|
||||||
{
|
{
|
||||||
options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername");
|
options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername");
|
||||||
options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword");
|
options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword");
|
||||||
options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
|
options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add Identity services to the services container
|
// Add Identity services to the services container
|
||||||
services.AddDefaultIdentity<MusicStoreContext, ApplicationUser, IdentityRole>(configuration);
|
services.AddDefaultIdentity<MusicStoreContext, ApplicationUser, IdentityRole>(configuration);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue