mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-10 01:50:53 +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++;
|
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
|
private sealed class ClaimsIdentityDebugProxy
|
||||||
|
|
|
@ -580,19 +580,19 @@ namespace System.Security.Claims
|
||||||
identitiesCount++;
|
identitiesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return debug string optimized for the case of one identity.
|
||||||
|
if (identitiesCount == 1 && Identity is ClaimsIdentity claimsIdentity)
|
||||||
|
{
|
||||||
|
return claimsIdentity.DebuggerToString();
|
||||||
|
}
|
||||||
|
|
||||||
int claimsCount = 0;
|
int claimsCount = 0;
|
||||||
foreach (Claim item in Claims)
|
foreach (Claim item in Claims)
|
||||||
{
|
{
|
||||||
claimsCount++;
|
claimsCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return debug string optimized for the case of one identity.
|
return $"Identities = {identitiesCount}, Claims = {claimsCount}";
|
||||||
if (identitiesCount == 1 && Identity is ClaimsIdentity claimsIdentity)
|
|
||||||
{
|
|
||||||
return $"Principal {claimsIdentity.DebuggerToString()}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $"Principal Identities Count: {identitiesCount}, Claims Count: {claimsCount}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class ClaimsPrincipalDebugProxy
|
private sealed class ClaimsPrincipalDebugProxy
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue