diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Client/Controllers/AuthenticationController.cs b/sandbox/OpenIddict.Sandbox.AspNet.Client/Controllers/AuthenticationController.cs index 4a9c61e8..bdfbecc4 100644 --- a/sandbox/OpenIddict.Sandbox.AspNet.Client/Controllers/AuthenticationController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNet.Client/Controllers/AuthenticationController.cs @@ -175,9 +175,9 @@ namespace OpenIddict.Sandbox.AspNet.Client.Controllers // in the cookie can be filtered out or mapped to different names depending the claim name or its issuer. var claims = result.Identity.Claims.Where(claim => claim.Type is ClaimTypes.NameIdentifier or ClaimTypes.Name // - // Preserve the registration identifier to be able to resolve it later. + // Preserve the registration details to be able to resolve them later. // - or Claims.Private.RegistrationId + or Claims.Private.RegistrationId or Claims.Private.ProviderName // // The ASP.NET 4.x antiforgery module requires preserving the "identityprovider" claim. // diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Client/Views/Home/Index.cshtml b/sandbox/OpenIddict.Sandbox.AspNet.Client/Views/Home/Index.cshtml index 1f344fe1..5eb4f587 100644 --- a/sandbox/OpenIddict.Sandbox.AspNet.Client/Views/Home/Index.cshtml +++ b/sandbox/OpenIddict.Sandbox.AspNet.Client/Views/Home/Index.cshtml @@ -2,6 +2,7 @@ @using Microsoft.Owin @using Microsoft.Owin.Security @using Microsoft.Owin.Security.Cookies +@using OpenIddict.Abstractions @using OpenIddict.Client.Owin @model string @@ -22,8 +23,7 @@

Payload returned by the controller: @Model

} - if (User is ClaimsPrincipal principal && - principal.FindFirst(ClaimTypes.NameIdentifier)?.Issuer is "https://localhost:44349/") + if (User is ClaimsPrincipal principal && principal.FindFirst(OpenIddictConstants.Claims.Private.ProviderName)?.Value is "Local") {
@Html.AntiForgeryToken() diff --git a/sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthenticationController.cs b/sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthenticationController.cs index 68d1b481..ce5bf496 100644 --- a/sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthenticationController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthenticationController.cs @@ -62,9 +62,9 @@ namespace OpenIddict.Sandbox.AspNet.Server.Controllers // in the cookie can be filtered out or mapped to different names depending the claim name or its issuer. var claims = result.Identity.Claims.Where(claim => claim.Type is ClaimTypes.NameIdentifier or ClaimTypes.Name // - // Preserve the registration identifier to be able to resolve it later. + // Preserve the registration details to be able to resolve them later. // - or Claims.Private.RegistrationId + or Claims.Private.RegistrationId or Claims.Private.ProviderName // // The ASP.NET 4.x antiforgery module requires preserving the "identityprovider" claim. // diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/AuthenticationController.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/AuthenticationController.cs index d8633a9c..8f81ecd9 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/AuthenticationController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Controllers/AuthenticationController.cs @@ -172,9 +172,10 @@ public class AuthenticationController : Controller identity.SetClaim(ClaimTypes.Email, result.Principal.GetClaim(ClaimTypes.Email)) .SetClaim(ClaimTypes.Name, result.Principal.GetClaim(ClaimTypes.Name)) .SetClaim(ClaimTypes.NameIdentifier, result.Principal.GetClaim(ClaimTypes.NameIdentifier)); - - // Preserve the registration identifier to be able to resolve it later. - identity.SetClaim(Claims.Private.RegistrationId, result.Principal.GetClaim(Claims.Private.RegistrationId)); + + // Preserve the registration details to be able to resolve them later. + identity.SetClaim(Claims.Private.RegistrationId, result.Principal.GetClaim(Claims.Private.RegistrationId)) + .SetClaim(Claims.Private.ProviderName, result.Principal.GetClaim(Claims.Private.ProviderName)); // Build the authentication properties based on the properties that were added when the challenge was triggered. var properties = new AuthenticationProperties(result.Properties.Items) diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Views/Home/Index.cshtml b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Views/Home/Index.cshtml index f6f2643b..b60645d0 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Views/Home/Index.cshtml +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Client/Views/Home/Index.cshtml @@ -1,6 +1,7 @@ @using System.Security.Claims @using Microsoft.AspNetCore.Authentication; @using OpenIddict.Client.AspNetCore; +@using static OpenIddict.Abstractions.OpenIddictConstants; @model string
@@ -20,7 +21,7 @@

Payload returned by the controller: @Model

} - if (User.FindFirst(ClaimTypes.NameIdentifier)?.Issuer is "https://localhost:44395/") + if (User.FindFirst(Claims.Private.ProviderName)?.Value is "Local") { diff --git a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthenticationController.cs b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthenticationController.cs index 404a5285..13997f63 100644 --- a/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthenticationController.cs +++ b/sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthenticationController.cs @@ -60,8 +60,9 @@ public class AuthenticationController : Controller .SetClaim(ClaimTypes.Name, result.Principal.GetClaim(ClaimTypes.Name)) .SetClaim(ClaimTypes.NameIdentifier, result.Principal.GetClaim(ClaimTypes.NameIdentifier)); - // Preserve the registration identifier to be able to resolve it later. - identity.SetClaim(Claims.Private.RegistrationId, result.Principal.GetClaim(Claims.Private.RegistrationId)); + // Preserve the registration details to be able to resolve them later. + identity.SetClaim(Claims.Private.RegistrationId, result.Principal.GetClaim(Claims.Private.RegistrationId)) + .SetClaim(Claims.Private.ProviderName, result.Principal.GetClaim(Claims.Private.ProviderName)); // Build the authentication properties based on the properties that were added when the challenge was triggered. var properties = new AuthenticationProperties(result.Properties.Items)