update connect methods
This commit is contained in:
parent
6ca771cc79
commit
4f207c43dd
|
@ -106,6 +106,9 @@ namespace MediaBrowser.Api
|
||||||
/// <value>The password.</value>
|
/// <value>The password.</value>
|
||||||
[ApiMember(Name = "Password", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
|
[ApiMember(Name = "Password", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
|
[ApiMember(Name = "PasswordMd5", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")]
|
||||||
|
public string PasswordMd5 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -351,7 +354,8 @@ namespace MediaBrowser.Api
|
||||||
AppVersion = auth.Version,
|
AppVersion = auth.Version,
|
||||||
DeviceId = auth.DeviceId,
|
DeviceId = auth.DeviceId,
|
||||||
DeviceName = auth.Device,
|
DeviceName = auth.Device,
|
||||||
Password = request.Password,
|
PasswordSha1 = request.Password,
|
||||||
|
PasswordMd5 = request.PasswordMd5,
|
||||||
RemoteEndPoint = Request.RemoteIp,
|
RemoteEndPoint = Request.RemoteIp,
|
||||||
Username = request.Username
|
Username = request.Username
|
||||||
|
|
||||||
|
|
|
@ -47,5 +47,13 @@ namespace MediaBrowser.Controller.Connect
|
||||||
/// <param name="id">The identifier.</param>
|
/// <param name="id">The identifier.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task CancelAuthorization(string id);
|
Task CancelAuthorization(string id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Authenticates the specified username.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username">The username.</param>
|
||||||
|
/// <param name="passwordMd5">The password MD5.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
Task Authenticate(string username, string passwordMd5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,5 +131,15 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// <param name="remoteEndPoint">The remote end point.</param>
|
/// <param name="remoteEndPoint">The remote end point.</param>
|
||||||
/// <returns>UserDto.</returns>
|
/// <returns>UserDto.</returns>
|
||||||
UserDto GetUserDto(User user, string remoteEndPoint = null);
|
UserDto GetUserDto(User user, string remoteEndPoint = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Authenticates the user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username">The username.</param>
|
||||||
|
/// <param name="passwordSha1">The password sha1.</param>
|
||||||
|
/// <param name="passwordMd5">The password MD5.</param>
|
||||||
|
/// <param name="remoteEndPoint">The remote end point.</param>
|
||||||
|
/// <returns>Task<System.Boolean>.</returns>
|
||||||
|
Task<bool> AuthenticateUser(string username, string passwordSha1, string passwordMd5, string remoteEndPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@ namespace MediaBrowser.Controller.Session
|
||||||
public class AuthenticationRequest
|
public class AuthenticationRequest
|
||||||
{
|
{
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string PasswordSha1 { get; set; }
|
||||||
|
public string PasswordMd5 { get; set; }
|
||||||
public string App { get; set; }
|
public string App { get; set; }
|
||||||
public string AppVersion { get; set; }
|
public string AppVersion { get; set; }
|
||||||
public string DeviceId { get; set; }
|
public string DeviceId { get; set; }
|
||||||
|
|
|
@ -20,6 +20,12 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
return string.Format("\"{0}\"", url);
|
return string.Format("\"{0}\"", url);
|
||||||
}
|
}
|
||||||
|
if (protocol == MediaProtocol.Rtsp)
|
||||||
|
{
|
||||||
|
var url = inputFiles.First();
|
||||||
|
|
||||||
|
return string.Format("\"{0}\"", url);
|
||||||
|
}
|
||||||
|
|
||||||
return GetConcatInputArgument(inputFiles);
|
return GetConcatInputArgument(inputFiles);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,9 @@
|
||||||
<Compile Include="..\MediaBrowser.Model\ApiClient\IServerEvents.cs">
|
<Compile Include="..\MediaBrowser.Model\ApiClient\IServerEvents.cs">
|
||||||
<Link>ApiClient\IServerEvents.cs</Link>
|
<Link>ApiClient\IServerEvents.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\ApiClient\ServerCredentials.cs">
|
||||||
|
<Link>ApiClient\ServerCredentials.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\ApiClient\ServerDiscoveryInfo.cs">
|
<Compile Include="..\MediaBrowser.Model\ApiClient\ServerDiscoveryInfo.cs">
|
||||||
<Link>ApiClient\ServerDiscoveryInfo.cs</Link>
|
<Link>ApiClient\ServerDiscoveryInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -70,6 +70,9 @@
|
||||||
<Compile Include="..\MediaBrowser.Model\ApiClient\IServerEvents.cs">
|
<Compile Include="..\MediaBrowser.Model\ApiClient\IServerEvents.cs">
|
||||||
<Link>ApiClient\IServerEvents.cs</Link>
|
<Link>ApiClient\IServerEvents.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\ApiClient\ServerCredentials.cs">
|
||||||
|
<Link>ApiClient\ServerCredentials.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\ApiClient\ServerDiscoveryInfo.cs">
|
<Compile Include="..\MediaBrowser.Model\ApiClient\ServerDiscoveryInfo.cs">
|
||||||
<Link>ApiClient\ServerDiscoveryInfo.cs</Link>
|
<Link>ApiClient\ServerDiscoveryInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
60
MediaBrowser.Model/ApiClient/ServerCredentials.cs
Normal file
60
MediaBrowser.Model/ApiClient/ServerCredentials.cs
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
using MediaBrowser.Model.Extensions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Model.ApiClient
|
||||||
|
{
|
||||||
|
public class ServerCredentials
|
||||||
|
{
|
||||||
|
public List<ServerInfo> Servers { get; set; }
|
||||||
|
|
||||||
|
public string ConnectUserId { get; set; }
|
||||||
|
public string ConnectAccessToken { get; set; }
|
||||||
|
|
||||||
|
public ServerCredentials()
|
||||||
|
{
|
||||||
|
Servers = new List<ServerInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddOrUpdateServer(ServerInfo server)
|
||||||
|
{
|
||||||
|
if (server == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("server");
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = Servers.ToList();
|
||||||
|
|
||||||
|
var index = FindIndex(list, server.Id);
|
||||||
|
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
list[index] = server;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.Add(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
Servers = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int FindIndex(List<ServerInfo> servers, string id)
|
||||||
|
{
|
||||||
|
var index = 0;
|
||||||
|
|
||||||
|
foreach (var server in servers)
|
||||||
|
{
|
||||||
|
if (StringHelper.Equals(id, server.Id))
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -71,6 +71,7 @@
|
||||||
<Compile Include="ApiClient\IDevice.cs" />
|
<Compile Include="ApiClient\IDevice.cs" />
|
||||||
<Compile Include="ApiClient\IServerEvents.cs" />
|
<Compile Include="ApiClient\IServerEvents.cs" />
|
||||||
<Compile Include="ApiClient\GeneralCommandEventArgs.cs" />
|
<Compile Include="ApiClient\GeneralCommandEventArgs.cs" />
|
||||||
|
<Compile Include="ApiClient\ServerCredentials.cs" />
|
||||||
<Compile Include="ApiClient\ServerDiscoveryInfo.cs" />
|
<Compile Include="ApiClient\ServerDiscoveryInfo.cs" />
|
||||||
<Compile Include="ApiClient\ServerInfo.cs" />
|
<Compile Include="ApiClient\ServerInfo.cs" />
|
||||||
<Compile Include="ApiClient\SessionUpdatesEventArgs.cs" />
|
<Compile Include="ApiClient\SessionUpdatesEventArgs.cs" />
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using MediaBrowser.Common.Configuration;
|
using System.Security.Cryptography;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
@ -825,5 +827,24 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||||
_logger.Debug("Connect returned a 404 when removing a user auth link. Handling it.");
|
_logger.Debug("Connect returned a 404 when removing a user auth link. Handling it.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task Authenticate(string username, string passwordMd5)
|
||||||
|
{
|
||||||
|
var request = new HttpRequestOptions
|
||||||
|
{
|
||||||
|
Url = GetConnectUrl("user/authenticate")
|
||||||
|
};
|
||||||
|
|
||||||
|
request.SetPostData(new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{"userName",username},
|
||||||
|
{"password",passwordMd5}
|
||||||
|
});
|
||||||
|
|
||||||
|
// No need to examine the response
|
||||||
|
using (var stream = (await _httpClient.SendAsync(request, "POST").ConfigureAwait(false)).Content)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
Users = await LoadUsers().ConfigureAwait(false);
|
Users = await LoadUsers().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> AuthenticateUser(string username, string passwordSha1, string remoteEndPoint)
|
public Task<bool> AuthenticateUser(string username, string passwordSha1, string remoteEndPoint)
|
||||||
|
{
|
||||||
|
return AuthenticateUser(username, passwordSha1, null, remoteEndPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> AuthenticateUser(string username, string passwordSha1, string passwordMd5, string remoteEndPoint)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(username))
|
if (string.IsNullOrWhiteSpace(username))
|
||||||
{
|
{
|
||||||
|
@ -161,12 +166,32 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
throw new AuthenticationException(string.Format("The {0} account is currently disabled. Please consult with your administrator.", user.Name));
|
throw new AuthenticationException(string.Format("The {0} account is currently disabled. Please consult with your administrator.", user.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
var success = string.Equals(GetPasswordHash(user), passwordSha1.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase);
|
var success = false;
|
||||||
|
|
||||||
|
// Authenticate using local credentials if not a guest
|
||||||
|
if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value != UserLinkType.Guest)
|
||||||
|
{
|
||||||
|
success = string.Equals(GetPasswordHash(user), passwordSha1.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
if (!success && _networkManager.IsInLocalNetwork(remoteEndPoint) && user.Configuration.EnableLocalPassword)
|
if (!success && _networkManager.IsInLocalNetwork(remoteEndPoint) && user.Configuration.EnableLocalPassword)
|
||||||
{
|
{
|
||||||
success = string.Equals(GetLocalPasswordHash(user), passwordSha1.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase);
|
success = string.Equals(GetLocalPasswordHash(user), passwordSha1.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maybe user accidently entered connect credentials. let's be flexible
|
||||||
|
if (!success && user.ConnectLinkType.HasValue && !string.IsNullOrWhiteSpace(passwordMd5))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _connectFactory().Authenticate(user.ConnectUserName, passwordMd5).ConfigureAwait(false);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update LastActivityDate and LastLoginDate, then save
|
// Update LastActivityDate and LastLoginDate, then save
|
||||||
if (success)
|
if (success)
|
||||||
|
|
|
@ -1245,5 +1245,6 @@
|
||||||
"HeaderSchedule": "Schedule",
|
"HeaderSchedule": "Schedule",
|
||||||
"OptionEveryday": "Every day",
|
"OptionEveryday": "Every day",
|
||||||
"OptionWeekdays": "Weekdays",
|
"OptionWeekdays": "Weekdays",
|
||||||
"OptionWeekends": "Weekends"
|
"OptionWeekends": "Weekends",
|
||||||
|
"MessageProfileInfoSynced": "User profile information synced with Media Browser Connect."
|
||||||
}
|
}
|
||||||
|
|
|
@ -1252,7 +1252,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
&& !(user != null && user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest);
|
&& !(user != null && user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest);
|
||||||
|
|
||||||
var result = allowWithoutPassword ||
|
var result = allowWithoutPassword ||
|
||||||
await _userManager.AuthenticateUser(request.Username, request.Password, request.RemoteEndPoint).ConfigureAwait(false);
|
await _userManager.AuthenticateUser(request.Username, request.PasswordSha1, request.PasswordMd5, request.RemoteEndPoint).ConfigureAwait(false);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Common.Internal</id>
|
<id>MediaBrowser.Common.Internal</id>
|
||||||
<version>3.0.487</version>
|
<version>3.0.488</version>
|
||||||
<title>MediaBrowser.Common.Internal</title>
|
<title>MediaBrowser.Common.Internal</title>
|
||||||
<authors>Luke</authors>
|
<authors>Luke</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
||||||
<copyright>Copyright © Media Browser 2013</copyright>
|
<copyright>Copyright © Media Browser 2013</copyright>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="MediaBrowser.Common" version="3.0.487" />
|
<dependency id="MediaBrowser.Common" version="3.0.488" />
|
||||||
<dependency id="NLog" version="3.1.0.0" />
|
<dependency id="NLog" version="3.1.0.0" />
|
||||||
<dependency id="SimpleInjector" version="2.5.2" />
|
<dependency id="SimpleInjector" version="2.5.2" />
|
||||||
<dependency id="sharpcompress" version="0.10.2" />
|
<dependency id="sharpcompress" version="0.10.2" />
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Common</id>
|
<id>MediaBrowser.Common</id>
|
||||||
<version>3.0.487</version>
|
<version>3.0.488</version>
|
||||||
<title>MediaBrowser.Common</title>
|
<title>MediaBrowser.Common</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Model.Signed</id>
|
<id>MediaBrowser.Model.Signed</id>
|
||||||
<version>3.0.487</version>
|
<version>3.0.488</version>
|
||||||
<title>MediaBrowser.Model - Signed Edition</title>
|
<title>MediaBrowser.Model - Signed Edition</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Server.Core</id>
|
<id>MediaBrowser.Server.Core</id>
|
||||||
<version>3.0.487</version>
|
<version>3.0.488</version>
|
||||||
<title>Media Browser.Server.Core</title>
|
<title>Media Browser.Server.Core</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||||
<copyright>Copyright © Media Browser 2013</copyright>
|
<copyright>Copyright © Media Browser 2013</copyright>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="MediaBrowser.Common" version="3.0.487" />
|
<dependency id="MediaBrowser.Common" version="3.0.488" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user