From 2e64a97b4cddaa9e1d5ce2138c2a53f64a7e06f5 Mon Sep 17 00:00:00 2001 From: Eduard Tomas Date: Wed, 12 Jul 2017 17:28:04 +0200 Subject: [PATCH] Changes for retrieving all claims under netcore2 --- .../Identity/Identity.API/Configuration/Config.cs | 1 + src/Web/WebMVC/Controllers/AccountController.cs | 13 ++++++++----- src/Web/WebMVC/Startup.cs | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index bce62b039..a4f804db6 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -96,6 +96,7 @@ namespace Identity.API.Configuration AllowAccessTokensViaBrowser = false, RequireConsent = false, AllowOfflineAccess = true, + AlwaysIncludeUserClaimsInIdToken = true, RedirectUris = new List { $"{clientsUrl["Mvc"]}/signin-oidc" diff --git a/src/Web/WebMVC/Controllers/AccountController.cs b/src/Web/WebMVC/Controllers/AccountController.cs index c00a94c72..25c42e8d7 100644 --- a/src/Web/WebMVC/Controllers/AccountController.cs +++ b/src/Web/WebMVC/Controllers/AccountController.cs @@ -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 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 }); } } } diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index 3349d9530..90bc98ac1 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -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 => {