|
| 1 | +// --------------------------------------------------------------------------------------------------------------------- |
| 2 | +// Imports |
| 3 | +// --------------------------------------------------------------------------------------------------------------------- |
| 4 | +using System.Security.Claims; |
| 5 | + |
| 6 | +namespace CodeOfChaos.Extensions; |
| 7 | + |
| 8 | +// --------------------------------------------------------------------------------------------------------------------- |
| 9 | +// Code |
| 10 | +// --------------------------------------------------------------------------------------------------------------------- |
| 11 | +public static class ClaimsIdentityExtensions { |
| 12 | + public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value) { |
| 13 | + identity.AddClaim(new Claim(type, value)); |
| 14 | + return identity; |
| 15 | + } |
| 16 | + |
| 17 | + public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, string? valueType) { |
| 18 | + identity.AddClaim(new Claim(type, value, valueType)); |
| 19 | + return identity; |
| 20 | + } |
| 21 | + |
| 22 | + public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, string? valueType, string? issuer) { |
| 23 | + identity.AddClaim(new Claim(type, value, valueType, issuer)); |
| 24 | + return identity; |
| 25 | + } |
| 26 | + |
| 27 | + public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, string? valueType, string? issuer, string? originalIssuer) { |
| 28 | + identity.AddClaim(new Claim(type, value, valueType, issuer, originalIssuer)); |
| 29 | + return identity; |
| 30 | + } |
| 31 | + |
| 32 | + public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, string? valueType, string? issuer, string? originalIssuer, ClaimsIdentity? subject) { |
| 33 | + identity.AddClaim(new Claim(type, value, valueType, issuer, originalIssuer, subject)); |
| 34 | + return identity; |
| 35 | + } |
| 36 | +} |
0 commit comments