| | | 1 | | using ArturRios.Util.WebApi.Security.Constants; |
| | | 2 | | using ArturRios.Util.WebApi.Security.Records; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Util.WebApi.Security.Extensions; |
| | | 5 | | |
| | | 6 | | /// <summary>Extension methods for converting authentication-related types.</summary> |
| | | 7 | | public static class AuthenticationExtensions |
| | | 8 | | { |
| | | 9 | | /// <summary>Converts an <see cref="AuthenticatedUser"/> into the claim dictionary (keyed by <see cref="TokenClaimKe |
| | | 10 | | /// <param name="authenticatedUser">The authenticated user to convert.</param> |
| | | 11 | | /// <returns>A dictionary containing the user's id and role claims.</returns> |
| | | 12 | | public static Dictionary<string, string> ToTokenClaims(this AuthenticatedUser authenticatedUser) => |
| | 7 | 13 | | new() |
| | 7 | 14 | | { |
| | 7 | 15 | | { TokenClaimKeys.Id, authenticatedUser.Id.ToString() }, |
| | 7 | 16 | | { TokenClaimKeys.Role, authenticatedUser.Role.ToString() } |
| | 7 | 17 | | }; |
| | | 18 | | } |