From 7c2248727aec0d407ca5ad811b8c86b4efc1c19c Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Mon, 10 Dec 2018 19:27:54 -0500 Subject: [PATCH] Remove Emby.Server.Connect --- .../ApplicationHost.cs | 6 ++- .../HttpServer/Security/AuthService.cs | 17 +------ .../Security/AuthorizationContext.cs | 4 -- .../Library/ConnectManager.cs | 46 +++++++++++++++++++ .../Library/UserManager.cs | 38 +-------------- MediaBrowser.Api/StartupWizardService.cs | 10 ---- MediaBrowser.Server.Mono/EmbyServer.csproj | 3 -- MediaBrowser.Server.Mono/MonoAppHost.cs | 5 +- 8 files changed, 54 insertions(+), 75 deletions(-) create mode 100644 Emby.Server.Implementations/Library/ConnectManager.cs diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 3208c6a1f..de1a1dfcd 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1994,7 +1994,8 @@ namespace Emby.Server.Implementations CanSelfRestart = CanSelfRestart, CanSelfUpdate = CanSelfUpdate, CanLaunchWebBrowser = CanLaunchWebBrowser, - WanAddress = ConnectManager.WanApiAddress, + // TODO - remove WanAddress + WanAddress = "0.0.0.0", HasUpdateAvailable = HasUpdateAvailable, SupportsAutoRunAtStartup = SupportsAutoRunAtStartup, TranscodingTempPath = ApplicationPaths.TranscodingTempPath, @@ -2027,7 +2028,8 @@ namespace Emby.Server.Implementations Version = ApplicationVersion.ToString(), Id = SystemId, OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(), - WanAddress = ConnectManager.WanApiAddress, + // TODO - remove WanAddress + WanAddress = "0.0.0.0", ServerName = FriendlyName, LocalAddress = localAddress }; diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs index 8f6d042dd..9dfb8cf03 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs @@ -51,12 +51,7 @@ namespace Emby.Server.Implementations.HttpServer.Security if (!IsExemptFromAuthenticationToken(auth, authAttribtues, request)) { - var valid = IsValidConnectKey(auth.Token); - - if (!valid) - { - ValidateSecurityToken(request, auth.Token); - } + ValidateSecurityToken(request, auth.Token); } if (authAttribtues.AllowLocalOnly && !request.IsLocal) @@ -221,16 +216,6 @@ namespace Emby.Server.Implementations.HttpServer.Security return info as AuthenticationInfo; } - private bool IsValidConnectKey(string token) - { - if (string.IsNullOrEmpty(token)) - { - return false; - } - - return ConnectManager.IsAuthorizationTokenValid(token); - } - private void ValidateSecurityToken(IRequest request, string token) { if (string.IsNullOrEmpty(token)) diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index ee8f6c60b..75dfa95d9 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -162,10 +162,6 @@ namespace Emby.Server.Implementations.HttpServer.Security _authRepo.Update(tokenInfo); } } - else - { - info.User = _connectManager.GetUserFromExchangeToken(token); - } httpReq.Items["OriginalAuthenticationInfo"] = tokenInfo; } diff --git a/Emby.Server.Implementations/Library/ConnectManager.cs b/Emby.Server.Implementations/Library/ConnectManager.cs new file mode 100644 index 000000000..5df45aa44 --- /dev/null +++ b/Emby.Server.Implementations/Library/ConnectManager.cs @@ -0,0 +1,46 @@ +using MediaBrowser.Common.Events; +using MediaBrowser.Common.Net; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Connect; +using MediaBrowser.Controller.Drawing; +using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Persistence; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Connect; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Events; +using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Users; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Model.Cryptography; +using MediaBrowser.Model.IO; +using MediaBrowser.Controller.Authentication; +using MediaBrowser.Controller.Security; +using MediaBrowser.Controller.Devices; +using MediaBrowser.Controller.Session; +using MediaBrowser.Controller.Plugins; + +namespace Emby.Server.Implementations.Library +{ + public class ConnectManager : IConnectManager + { + public ConnectManager() + { + } + + } +} diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index b13a255aa..a13e8248f 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -272,20 +272,6 @@ namespace Emby.Server.Implementations.Library authenticationProvider = authResult.Item1; success = authResult.Item2; } - - // Maybe user accidently entered connect credentials. let's be flexible - if (!success && user.ConnectLinkType.HasValue && !string.IsNullOrWhiteSpace(user.ConnectUserName)) - { - try - { - await _connectFactory().Authenticate(user.ConnectUserName, password).ConfigureAwait(false); - success = true; - } - catch - { - - } - } } else { @@ -318,23 +304,6 @@ namespace Emby.Server.Implementations.Library } } - // Try originally entered username - if (!success && (user == null || !string.Equals(user.ConnectUserName, username, StringComparison.OrdinalIgnoreCase))) - { - try - { - var connectAuthResult = await _connectFactory().Authenticate(username, password).ConfigureAwait(false); - - user = Users.FirstOrDefault(i => string.Equals(i.ConnectUserId, connectAuthResult.User.Id, StringComparison.OrdinalIgnoreCase)); - - success = user != null; - } - catch - { - - } - } - if (user == null) { throw new SecurityException("Invalid username or password entered."); @@ -777,11 +746,6 @@ namespace Emby.Server.Implementations.Library throw new ArgumentNullException("user"); } - if (user.ConnectLinkType.HasValue) - { - await _connectFactory().RemoveConnect(user).ConfigureAwait(false); - } - var allUsers = Users.ToList(); if (allUsers.FirstOrDefault(u => u.Id == user.Id) == null) @@ -1277,4 +1241,4 @@ namespace Emby.Server.Implementations.Library } } -} \ No newline at end of file +} diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 425eb2ef0..b4891ba1a 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -148,16 +148,6 @@ namespace MediaBrowser.Api var result = new UpdateStartupUserResult(); - if (!string.IsNullOrWhiteSpace(user.ConnectUserName) && - string.IsNullOrWhiteSpace(request.ConnectUserName)) - { - await _connectManager.RemoveConnect(user).ConfigureAwait(false); - } - else if (!string.Equals(user.ConnectUserName, request.ConnectUserName, StringComparison.OrdinalIgnoreCase)) - { - result.UserLinkResult = await _connectManager.LinkUser(user, request.ConnectUserName).ConfigureAwait(false); - } - return result; } } diff --git a/MediaBrowser.Server.Mono/EmbyServer.csproj b/MediaBrowser.Server.Mono/EmbyServer.csproj index 420505494..1cc08450c 100644 --- a/MediaBrowser.Server.Mono/EmbyServer.csproj +++ b/MediaBrowser.Server.Mono/EmbyServer.csproj @@ -25,9 +25,6 @@ - - ..\ThirdParty\emby\Emby.Server.Connect.dll - ..\ThirdParty\emby\Emby.Server.MediaEncoding.dll diff --git a/MediaBrowser.Server.Mono/MonoAppHost.cs b/MediaBrowser.Server.Mono/MonoAppHost.cs index 914e50d29..d4614ec00 100644 --- a/MediaBrowser.Server.Mono/MonoAppHost.cs +++ b/MediaBrowser.Server.Mono/MonoAppHost.cs @@ -4,8 +4,8 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; //using Emby.Server.CinemaMode; -using Emby.Server.Connect; using Emby.Server.Implementations; +using Emby.Server.Implementations.Library; using Emby.Server.Implementations.HttpServer; using Emby.Server.Implementations.Net; using MediaBrowser.Controller.Connect; @@ -36,7 +36,7 @@ namespace MediaBrowser.Server.Mono protected override IConnectManager CreateConnectManager() { - return new ConnectManager(); + return new Emby.Server.Implementations.Library.ConnectManager(); } //protected override ISyncManager CreateSyncManager() @@ -54,7 +54,6 @@ namespace MediaBrowser.Server.Mono var list = new List(); list.Add(GetType().Assembly); - list.Add(typeof(ConnectManager).Assembly); return list; }