aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-06-30 17:53:20 -0600
committercrobibero <cody@robibe.ro>2020-06-30 17:53:20 -0600
commit14faebc7fe7a5a75d4d39ef0c70e6ff0106e76f3 (patch)
tree0552309271dd0ff99c4db6f97ed0051f4d888591 /Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
parent7e94bb786432536e95f4e76ea1f8fe02dd292fef (diff)
parentd300d80479597faa4a8b6e840f6fcb1efdb63c8c (diff)
Merge remote-tracking branch 'upstream/api-migration' into api-livetv
Diffstat (limited to 'Jellyfin.Api/Auth/BaseAuthorizationHandler.cs')
-rw-r--r--Jellyfin.Api/Auth/BaseAuthorizationHandler.cs11
1 files changed, 10 insertions, 1 deletions
diff --git a/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs b/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
index 953acac80..50b6468db 100644
--- a/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
+++ b/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
@@ -42,11 +42,13 @@ namespace Jellyfin.Api.Auth
/// <param name="claimsPrincipal">Request claims.</param>
/// <param name="ignoreSchedule">Whether to ignore parental control.</param>
/// <param name="localAccessOnly">Whether access is to be allowed locally only.</param>
+ /// <param name="requiredDownloadPermission">Whether validation requires download permission.</param>
/// <returns>Validated claim status.</returns>
protected bool ValidateClaims(
ClaimsPrincipal claimsPrincipal,
bool ignoreSchedule = false,
- bool localAccessOnly = false)
+ bool localAccessOnly = false,
+ bool requiredDownloadPermission = false)
{
// Ensure claim has userId.
var userId = ClaimHelpers.GetUserId(claimsPrincipal);
@@ -89,6 +91,13 @@ namespace Jellyfin.Api.Auth
return false;
}
+ // User attempting to download without permission.
+ if (requiredDownloadPermission
+ && !user.HasPermission(PermissionKind.EnableContentDownloading))
+ {
+ return false;
+ }
+
return true;
}