React to identity

This commit is contained in:
Hao Kung 2015-09-02 16:40:27 -07:00
parent d147f259a8
commit 16a9872a55
10 changed files with 13 additions and 15 deletions

View File

@ -59,7 +59,7 @@ namespace MusicStore
// Add Identity services to the services container // Add Identity services to the services container
services.AddIdentity<ApplicationUser, IdentityRole>(options => services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{ {
options.ApplicationCookie.AccessDeniedPath = new PathString("/Home/AccessDenied"); options.Cookies.ApplicationCookie.AccessDeniedPath = new PathString("/Home/AccessDenied");
}) })
.AddEntityFrameworkStores<MusicStoreContext>() .AddEntityFrameworkStores<MusicStoreContext>()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();

View File

@ -73,7 +73,7 @@ namespace MusicStore
.AddEntityFrameworkStores<MusicStoreContext>() .AddEntityFrameworkStores<MusicStoreContext>()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();
services.ConfigureOpenIdConnectAuthentication(options => services.AddOpenIdConnectAuthentication(options =>
{ {
options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com"; options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com";
options.ClientId = "[ClientId]"; options.ClientId = "[ClientId]";

View File

@ -4,7 +4,7 @@
} }
<div class="jumbotron"> <div class="jumbotron">
<h1>@AppSettings.Options.SiteTitle</h1> <h1>@AppSettings.Value.SiteTitle</h1>
<img src="~/Images/home-showcase.png" /> <img src="~/Images/home-showcase.png" />
</div> </div>

View File

@ -4,7 +4,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title @AppSettings.Options.SiteTitle</title> <title>@ViewBag.Title @AppSettings.Value.SiteTitle</title>
<environment names="Development,NtlmAuthentication,OpenIdConnect,SocialTesting"> <environment names="Development,NtlmAuthentication,OpenIdConnect,SocialTesting">
<link rel="stylesheet" href="~/Content/bootstrap.css" /> <link rel="stylesheet" href="~/Content/bootstrap.css" />
@ -33,7 +33,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a asp-controller="Home" asp-action="Index" class="navbar-brand">@AppSettings.Options.SiteTitle</a> <a asp-controller="Home" asp-action="Index" class="navbar-brand">@AppSettings.Value.SiteTitle</a>
</div> </div>
<div class="navbar-collapse collapse"> <div class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">

View File

@ -36,7 +36,7 @@ namespace MusicStore.Mocks.Facebook
internal static async Task OnReturnEndpoint(OAuthReturnEndpointContext context) internal static async Task OnReturnEndpoint(OAuthReturnEndpointContext context)
{ {
if (context.Principal != null && context.SignInScheme == IdentityOptions.ExternalCookieAuthenticationScheme) if (context.Principal != null && context.SignInScheme == IdentityCookieOptions.ExternalCookieAuthenticationScheme)
{ {
//This way we will know all notifications were fired. //This way we will know all notifications were fired.
var identity = context.Principal.Identities.First(); var identity = context.Principal.Identities.First();

View File

@ -35,7 +35,7 @@ namespace MusicStore.Mocks.Google
internal static async Task OnReturnEndpoint(OAuthReturnEndpointContext context) internal static async Task OnReturnEndpoint(OAuthReturnEndpointContext context)
{ {
if (context.Principal != null && context.SignInScheme == IdentityOptions.ExternalCookieAuthenticationScheme) if (context.Principal != null && context.SignInScheme == IdentityCookieOptions.ExternalCookieAuthenticationScheme)
{ {
//This way we will know all notifications were fired. //This way we will know all notifications were fired.
var identity = context.Principal.Identities.First(); var identity = context.Principal.Identities.First();

View File

@ -36,7 +36,7 @@ namespace MusicStore.Mocks.MicrosoftAccount
internal static async Task OnReturnEndpoint(OAuthReturnEndpointContext context) internal static async Task OnReturnEndpoint(OAuthReturnEndpointContext context)
{ {
if (context.Principal != null && context.SignInScheme == IdentityOptions.ExternalCookieAuthenticationScheme) if (context.Principal != null && context.SignInScheme == IdentityCookieOptions.ExternalCookieAuthenticationScheme)
{ {
//This way we will know all notifications were fired. //This way we will know all notifications were fired.
var identity = context.Principal.Identities.First(); var identity = context.Principal.Identities.First();

View File

@ -65,7 +65,7 @@ namespace MusicStore
.AddEntityFrameworkStores<MusicStoreContext>() .AddEntityFrameworkStores<MusicStoreContext>()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();
services.ConfigureOpenIdConnectAuthentication(options => services.AddOpenIdConnectAuthentication(options =>
{ {
options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com"; options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com";
options.ClientId = "c99497aa-3ee2-4707-b8a8-c33f51323fef"; options.ClientId = "c99497aa-3ee2-4707-b8a8-c33f51323fef";

View File

@ -70,13 +70,11 @@ namespace MusicStore
// Add Identity services to the services container // Add Identity services to the services container
services.AddIdentity<ApplicationUser, IdentityRole>(options => services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{ {
options.ApplicationCookie.AccessDeniedPath = new PathString("/Home/AccessDenied"); options.Cookies.ApplicationCookie.AccessDeniedPath = new PathString("/Home/AccessDenied");
}) })
.AddEntityFrameworkStores<MusicStoreContext>() .AddEntityFrameworkStores<MusicStoreContext>()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();
services.AddCookieAuthentication();
services.AddFacebookAuthentication(options => services.AddFacebookAuthentication(options =>
{ {
options.AppId = "[AppId]"; options.AppId = "[AppId]";
@ -109,7 +107,7 @@ namespace MusicStore
options.BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler(); options.BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler();
}); });
services.ConfigureTwitterAuthentication(options => services.AddTwitterAuthentication(options =>
{ {
options.ConsumerKey = "[ConsumerKey]"; options.ConsumerKey = "[ConsumerKey]";
options.ConsumerSecret = "[ConsumerSecret]"; options.ConsumerSecret = "[ConsumerSecret]";
@ -126,7 +124,7 @@ namespace MusicStore
#endif #endif
}); });
services.ConfigureMicrosoftAccountAuthentication(options => services.AddMicrosoftAccountAuthentication(options =>
{ {
options.Caption = "MicrosoftAccount - Requires project changes"; options.Caption = "MicrosoftAccount - Requires project changes";
options.ClientId = "[ClientId]"; options.ClientId = "[ClientId]";

View File

@ -29,7 +29,7 @@ namespace MusicStore.Mocks.Twitter
internal static async Task OnReturnEndpoint(TwitterReturnEndpointContext context) internal static async Task OnReturnEndpoint(TwitterReturnEndpointContext context)
{ {
if (context.Principal != null && context.SignInScheme == IdentityOptions.ExternalCookieAuthenticationScheme) if (context.Principal != null && context.SignInScheme == IdentityCookieOptions.ExternalCookieAuthenticationScheme)
{ {
//This way we will know all notifications were fired. //This way we will know all notifications were fired.
var identity = context.Principal.Identities.First(); var identity = context.Principal.Identities.First();