mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-09 17:44:48 +09:00
Claims identity and principal debugging update (#87742)
* Claims identity and principal debugging update * Comment
This commit is contained in:
parent
eb7149483d
commit
3a76e98086
2 changed files with 22 additions and 8 deletions
|
@ -946,7 +946,21 @@ namespace System.Security.Claims
|
|||
claimsCount++;
|
||||
}
|
||||
|
||||
return $"Identity Name = {Name ?? "(null)"}, IsAuthenticated = {(IsAuthenticated ? "true" : "false")}, Claims Count = {claimsCount}";
|
||||
string debugText = $"IsAuthenticated = {(IsAuthenticated ? "true" : "false")}";
|
||||
if (Name != null)
|
||||
{
|
||||
// The ClaimsIdentity.Name property requires that ClaimsIdentity.NameClaimType is correctly
|
||||
// configured to match the name of the logical name claim type of the identity.
|
||||
// Because of this, only include name if the ClaimsIdentity.Name property has a value.
|
||||
// Not including the name is to avoid developer confusion at seeing "Name = (null)" on an authenticated identity.
|
||||
debugText += $", Name = {Name}";
|
||||
}
|
||||
if (claimsCount > 0)
|
||||
{
|
||||
debugText += $", Claims = {claimsCount}";
|
||||
}
|
||||
|
||||
return debugText;
|
||||
}
|
||||
|
||||
private sealed class ClaimsIdentityDebugProxy
|
||||
|
|
|
@ -580,19 +580,19 @@ namespace System.Security.Claims
|
|||
identitiesCount++;
|
||||
}
|
||||
|
||||
// Return debug string optimized for the case of one identity.
|
||||
if (identitiesCount == 1 && Identity is ClaimsIdentity claimsIdentity)
|
||||
{
|
||||
return claimsIdentity.DebuggerToString();
|
||||
}
|
||||
|
||||
int claimsCount = 0;
|
||||
foreach (Claim item in Claims)
|
||||
{
|
||||
claimsCount++;
|
||||
}
|
||||
|
||||
// Return debug string optimized for the case of one identity.
|
||||
if (identitiesCount == 1 && Identity is ClaimsIdentity claimsIdentity)
|
||||
{
|
||||
return $"Principal {claimsIdentity.DebuggerToString()}";
|
||||
}
|
||||
|
||||
return $"Principal Identities Count: {identitiesCount}, Claims Count: {claimsCount}";
|
||||
return $"Identities = {identitiesCount}, Claims = {claimsCount}";
|
||||
}
|
||||
|
||||
private sealed class ClaimsPrincipalDebugProxy
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue