Browse Source

Changes for retrieving all claims under netcore2

pull/296/head
Eduard Tomas 7 years ago
parent
commit
2e64a97b4c
3 changed files with 10 additions and 5 deletions
  1. +1
    -0
      src/Services/Identity/Identity.API/Configuration/Config.cs
  2. +8
    -5
      src/Web/WebMVC/Controllers/AccountController.cs
  3. +1
    -0
      src/Web/WebMVC/Startup.cs

+ 1
- 0
src/Services/Identity/Identity.API/Configuration/Config.cs 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"


+ 8
- 5
src/Web/WebMVC/Controllers/AccountController.cs 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 });
}
}
}

+ 1
- 0
src/Web/WebMVC/Startup.cs 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 => {


Loading…
Cancel
Save