2021-11-23 22:56:22 +01:00
|
|
|
using System.Security.Claims;
|
2021-11-19 16:11:12 +01:00
|
|
|
|
2021-11-20 13:52:28 +01:00
|
|
|
namespace zero.Identity;
|
2021-11-19 16:11:12 +01:00
|
|
|
|
|
|
|
|
public class UserClaim
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the claim type for this claim
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Type { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the claim value for this claim
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Value { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert to a claim
|
|
|
|
|
/// </summary>
|
2021-11-23 22:56:22 +01:00
|
|
|
public Claim ToClaim() => new(Type, Value);
|
2021-11-19 16:11:12 +01:00
|
|
|
|
|
|
|
|
public UserClaim() { }
|
|
|
|
|
|
|
|
|
|
public UserClaim(string type, string value)
|
|
|
|
|
{
|
|
|
|
|
Type = type;
|
|
|
|
|
Value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserClaim(string type, string key, string value)
|
|
|
|
|
{
|
|
|
|
|
Type = type;
|
|
|
|
|
Value = key + ":" + value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserClaim(Claim claim)
|
|
|
|
|
{
|
|
|
|
|
Type = claim?.Type;
|
|
|
|
|
Value = claim?.Value;
|
|
|
|
|
}
|
2021-11-23 22:56:22 +01:00
|
|
|
}
|