The Free Software Media System - Server Backend & API
Perform hashing of Password for Schedules Direct on server
Neil Burrows866c41519f2d
diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.csindex 28aabc1599..8735745c6b 100644--- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs+++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs@@ -15,6 +15,7 @@ using System.Threading.Tasks;using MediaBrowser.Common;using MediaBrowser.Common.Net;using MediaBrowser.Controller.LiveTv;+using MediaBrowser.Model.Cryptography;using MediaBrowser.Model.Dto;using MediaBrowser.Model.Entities;using MediaBrowser.Model.LiveTv;@@ -33,17 +34,20 @@ namespace Emby.Server.Implementations.LiveTv.Listingsprivate readonly IHttpClientFactory _httpClientFactory;private readonly SemaphoreSlim _tokenSemaphore = new SemaphoreSlim(1, 1);private readonly IApplicationHost _appHost;+ private readonly ICryptoProvider _cryptoProvider;public SchedulesDirect(ILogger<SchedulesDirect> logger,IJsonSerializer jsonSerializer,IHttpClientFactory httpClientFactory,- IApplicationHost appHost)+ IApplicationHost appHost,+ ICryptoProvider cryptoProvider){_logger = logger;_jsonSerializer = jsonSerializer;_httpClientFactory = httpClientFactory;_appHost = appHost;+ _cryptoProvider = cryptoProvider;}private string UserAgent => _appHost.ApplicationUserAgent;@@ -642,7 +646,9 @@ namespace Emby.Server.Implementations.LiveTv.ListingsCancellationToken cancellationToken){using var options = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/token");- options.Content = new StringContent("{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}", Encoding.UTF8, MediaTypeNames.Application.Json);+ var hashedPasswordBytes = _cryptoProvider.ComputeHash("SHA1", Encoding.ASCII.GetBytes(password), Array.Empty<byte>());+ string hashedPassword = string.Concat(hashedPasswordBytes.Select(b => b.ToString("x2", CultureInfo.InvariantCulture)));+ options.Content = new StringContent("{\"username\":\"" + username + "\",\"password\":\"" + hashedPassword + "\"}", Encoding.UTF8, MediaTypeNames.Application.Json);using var response = await Send(options, false, null, cancellationToken).ConfigureAwait(false);await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);