Changes for retrieving all claims under netcore2

This commit is contained in:
Eduard Tomas 2017-07-12 17:28:04 +02:00
parent d9b9578e48
commit 2e64a97b4c
3 changed files with 10 additions and 5 deletions

View File

@ -96,6 +96,7 @@ namespace Identity.API.Configuration
AllowAccessTokensViaBrowser = false,
RequireConsent = false,
AllowOfflineAccess = true,
AlwaysIncludeUserClaimsInIdToken = true,
RedirectUris = new List<string>
{
$"{clientsUrl["Mvc"]}/signin-oidc"

View File

@ -6,6 +6,8 @@ using Microsoft.eShopOnContainers.WebMVC.Services;
using Microsoft.AspNetCore.Http.Authentication;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authentication.Cookies;
namespace Microsoft.eShopOnContainers.WebMVC.Controllers
{
@ -35,15 +37,16 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
return RedirectToAction(nameof(CatalogController.Index), "Catalog");
}
public IActionResult Signout()
public async Task<IActionResult> Signout()
{
HttpContext.Authentication.SignOutAsync("Cookies");
HttpContext.Authentication.SignOutAsync("oidc");
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
await HttpContext.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme);
// "Catalog" because UrlHelper doesn't support nameof() for controllers
// https://github.com/aspnet/Mvc/issues/5853
var homeUrl = Url.Action(nameof(CatalogController.Index), "Catalog");
return new SignOutResult("oidc", new AspNetCore.Authentication.AuthenticationProperties { RedirectUri = homeUrl });
return new SignOutResult(OpenIdConnectDefaults.AuthenticationScheme,
new AspNetCore.Authentication.AuthenticationProperties { RedirectUri = homeUrl });
}
}
}

View File

@ -100,6 +100,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
options.Scope.Add("orders");
options.Scope.Add("basket");
options.Scope.Add("marketing");
options.Scope.Add("locations");
});
services.AddAuthentication(options => {