mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-16 22:13:06 +03:00
Validate requested user id (#8812)
This commit is contained in:
@@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Api.Constants;
|
||||
using Jellyfin.Api.Extensions;
|
||||
using Jellyfin.Api.Helpers;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Authentication;
|
||||
using MediaBrowser.Controller.Net;
|
||||
@@ -116,17 +117,11 @@ public class QuickConnectController : BaseJellyfinApiController
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult<bool>> AuthorizeQuickConnect([FromQuery, Required] string code, [FromQuery] Guid? userId = null)
|
||||
{
|
||||
var currentUserId = User.GetUserId();
|
||||
var actualUserId = userId ?? currentUserId;
|
||||
|
||||
if (actualUserId.Equals(default) || (!userId.Equals(currentUserId) && !User.IsInRole(UserRoles.Administrator)))
|
||||
{
|
||||
return Forbid("Unknown user id");
|
||||
}
|
||||
userId = RequestHelpers.GetUserId(User, userId);
|
||||
|
||||
try
|
||||
{
|
||||
return await _quickConnect.AuthorizeRequest(actualUserId, code).ConfigureAwait(false);
|
||||
return await _quickConnect.AuthorizeRequest(userId.Value, code).ConfigureAwait(false);
|
||||
}
|
||||
catch (AuthenticationException)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user