diff options
| author | crobibero <cody@robibe.ro> | 2020-10-28 08:40:11 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-10-28 08:40:11 -0600 |
| commit | 981f000437467832d78b1eb36d9c449adb38e814 (patch) | |
| tree | 0290d8203bd367476c55004912bc89572f43b176 /Jellyfin.Api/Helpers/ClaimHelpers.cs | |
| parent | d5c226b1c3b04fa824adbcdc3eb0cbe09815f643 (diff) | |
Use proper IsApiKey flag
Diffstat (limited to 'Jellyfin.Api/Helpers/ClaimHelpers.cs')
| -rw-r--r-- | Jellyfin.Api/Helpers/ClaimHelpers.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Jellyfin.Api/Helpers/ClaimHelpers.cs b/Jellyfin.Api/Helpers/ClaimHelpers.cs index df235ced2..29e6b4193 100644 --- a/Jellyfin.Api/Helpers/ClaimHelpers.cs +++ b/Jellyfin.Api/Helpers/ClaimHelpers.cs @@ -63,6 +63,19 @@ namespace Jellyfin.Api.Helpers public static string? GetToken(in ClaimsPrincipal user) => GetClaimValue(user, InternalClaimTypes.Token); + /// <summary> + /// Gets a flag specifying whether the request is using an api key. + /// </summary> + /// <param name="user">Current claims principal.</param> + /// <returns>The flag specifying whether the request is using an api key.</returns> + public static bool GetIsApiKey(in ClaimsPrincipal user) + { + var claimValue = GetClaimValue(user, InternalClaimTypes.IsApiKey); + return !string.IsNullOrEmpty(claimValue) + && bool.TryParse(claimValue, out var parsedClaimValue) + && parsedClaimValue; + } + private static string? GetClaimValue(in ClaimsPrincipal user, string name) { return user?.Identities |
