aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-11-02 22:38:43 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-11-02 22:38:43 -0500
commit7ca1cd8795c465953ddb4560ce62fe6efba9f9d3 (patch)
tree637729589e12c3e6bee826ba3f4cc4dc5c1e77ca /MediaBrowser.Server.Implementations
parent7a4d5b79517f28dab668090bc4a540aa7aa75f5f (diff)
upgrade to jquery mobile 1.4.5
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/Connect/ConnectData.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Connect/ConnectManager.cs49
-rw-r--r--MediaBrowser.Server.Implementations/Connect/Responses.cs6
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs15
-rw-r--r--MediaBrowser.Server.Implementations/Localization/Server/server.json2
5 files changed, 63 insertions, 16 deletions
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectData.cs b/MediaBrowser.Server.Implementations/Connect/ConnectData.cs
index 87d59f356..5ec0bea22 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectData.cs
+++ b/MediaBrowser.Server.Implementations/Connect/ConnectData.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Model.Connect;
-using System;
+using System;
using System.Collections.Generic;
namespace MediaBrowser.Server.Implementations.Connect
@@ -21,7 +20,7 @@ namespace MediaBrowser.Server.Implementations.Connect
/// Gets or sets the authorizations.
/// </summary>
/// <value>The authorizations.</value>
- public List<ConnectAuthorization> PendingAuthorizations { get; set; }
+ public List<ConnectAuthorizationInternal> PendingAuthorizations { get; set; }
/// <summary>
/// Gets or sets the last authorizations refresh.
@@ -31,7 +30,7 @@ namespace MediaBrowser.Server.Implementations.Connect
public ConnectData()
{
- PendingAuthorizations = new List<ConnectAuthorization>();
+ PendingAuthorizations = new List<ConnectAuthorizationInternal>();
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
index 6f8f5e85b..9bf15e43a 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
+++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
@@ -498,7 +498,7 @@ namespace MediaBrowser.Server.Implementations.Connect
result.IsPending = string.Equals(response.AcceptStatus, "waiting", StringComparison.OrdinalIgnoreCase);
- _data.PendingAuthorizations.Add(new ConnectAuthorization
+ _data.PendingAuthorizations.Add(new ConnectAuthorizationInternal
{
ConnectUserId = response.UserId,
Id = response.Id,
@@ -506,7 +506,8 @@ namespace MediaBrowser.Server.Implementations.Connect
UserName = response.UserName,
ExcludedLibraries = request.ExcludedLibraries,
ExcludedChannels = request.ExcludedChannels,
- EnableLiveTv = request.EnableLiveTv
+ EnableLiveTv = request.EnableLiveTv,
+ AccessToken = accessToken
});
CacheData();
@@ -704,7 +705,7 @@ namespace MediaBrowser.Server.Implementations.Connect
}
var currentPendingList = _data.PendingAuthorizations.ToList();
- var newPendingList = new List<ConnectAuthorization>();
+ var newPendingList = new List<ConnectAuthorizationInternal>();
foreach (var connectEntry in list)
{
@@ -749,12 +750,13 @@ namespace MediaBrowser.Server.Implementations.Connect
}
else if (string.Equals(connectEntry.AcceptStatus, "waiting", StringComparison.OrdinalIgnoreCase))
{
- currentPendingEntry = currentPendingEntry ?? new ConnectAuthorization();
+ currentPendingEntry = currentPendingEntry ?? new ConnectAuthorizationInternal();
currentPendingEntry.ConnectUserId = connectEntry.UserId;
currentPendingEntry.ImageUrl = connectEntry.UserImageUrl;
currentPendingEntry.UserName = connectEntry.UserName;
currentPendingEntry.Id = connectEntry.Id;
+ currentPendingEntry.AccessToken = connectEntry.AccessToken;
newPendingList.Add(currentPendingEntry);
}
@@ -860,7 +862,17 @@ namespace MediaBrowser.Server.Implementations.Connect
}
}
- return _data.PendingAuthorizations.ToList();
+ return _data.PendingAuthorizations.Select(i => new ConnectAuthorization
+ {
+ ConnectUserId = i.ConnectUserId,
+ EnableLiveTv = i.EnableLiveTv,
+ ExcludedChannels = i.ExcludedChannels,
+ ExcludedLibraries = i.ExcludedLibraries,
+ Id = i.Id,
+ ImageUrl = i.ImageUrl,
+ UserName = i.UserName
+
+ }).ToList();
}
public async Task CancelAuthorization(string id)
@@ -951,7 +963,7 @@ namespace MediaBrowser.Server.Implementations.Connect
{
var user = e.Argument;
- //await TryUploadUserPreferences(user, CancellationToken.None).ConfigureAwait(false);
+ await TryUploadUserPreferences(user, CancellationToken.None).ConfigureAwait(false);
}
private async Task TryUploadUserPreferences(User user, CancellationToken cancellationToken)
@@ -999,5 +1011,30 @@ namespace MediaBrowser.Server.Implementations.Connect
{
}
+
+ public async Task<User> GetLocalUser(string connectUserId)
+ {
+ var user = _userManager.Users
+ .FirstOrDefault(i => string.Equals(i.ConnectUserId, connectUserId, StringComparison.OrdinalIgnoreCase));
+
+ if (user == null)
+ {
+ await RefreshAuthorizations(CancellationToken.None).ConfigureAwait(false);
+ }
+
+ return _userManager.Users
+ .FirstOrDefault(i => string.Equals(i.ConnectUserId, connectUserId, StringComparison.OrdinalIgnoreCase));
+ }
+
+ public bool IsAuthorizationTokenValid(string token)
+ {
+ if (string.IsNullOrWhiteSpace(token))
+ {
+ throw new ArgumentNullException("token");
+ }
+
+ return _userManager.Users.Any(u => string.Equals(token, u.ConnectAccessKey, StringComparison.OrdinalIgnoreCase)) ||
+ _data.PendingAuthorizations.Select(i => i.AccessToken).Contains(token, StringComparer.OrdinalIgnoreCase);
+ }
}
}
diff --git a/MediaBrowser.Server.Implementations/Connect/Responses.cs b/MediaBrowser.Server.Implementations/Connect/Responses.cs
index ff2825d73..e7c3f8154 100644
--- a/MediaBrowser.Server.Implementations/Connect/Responses.cs
+++ b/MediaBrowser.Server.Implementations/Connect/Responses.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Connect;
namespace MediaBrowser.Server.Implementations.Connect
{
@@ -77,4 +78,9 @@ namespace MediaBrowser.Server.Implementations.Connect
{
public T data { get; set; }
}
+
+ public class ConnectAuthorizationInternal : ConnectAuthorization
+ {
+ public string AccessToken { get; set; }
+ }
}
diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
index 76e625c05..20137af13 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Connect;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
@@ -15,10 +16,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
{
private readonly IServerConfigurationManager _config;
- public AuthService(IUserManager userManager, ISessionManager sessionManager, IAuthorizationContext authorizationContext, IServerConfigurationManager config)
+ public AuthService(IUserManager userManager, ISessionManager sessionManager, IAuthorizationContext authorizationContext, IServerConfigurationManager config, IConnectManager connectManager)
{
AuthorizationContext = authorizationContext;
_config = config;
+ ConnectManager = connectManager;
SessionManager = sessionManager;
UserManager = userManager;
}
@@ -26,6 +28,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
public IUserManager UserManager { get; private set; }
public ISessionManager SessionManager { get; private set; }
public IAuthorizationContext AuthorizationContext { get; private set; }
+ public IConnectManager ConnectManager { get; private set; }
/// <summary>
/// Restrict authentication to a specific <see cref="IAuthProvider"/>.
@@ -65,7 +68,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
if (!string.IsNullOrWhiteSpace(auth.Token) ||
!_config.Configuration.InsecureApps3.Contains(auth.Client ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{
- if (!IsValidConnectKey(auth.Token))
+ var valid = IsValidConnectKey(auth.Token);
+
+ if (!valid)
{
SessionManager.ValidateSecurityToken(auth.Token);
}
@@ -122,12 +127,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
private bool IsValidConnectKey(string token)
{
- if (!string.IsNullOrEmpty(token))
+ if (string.IsNullOrEmpty(token))
{
- return UserManager.Users.Any(u => string.Equals(token, u.ConnectAccessKey, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(u.ConnectAccessKey));
+ return false;
}
- return false;
+ return ConnectManager.IsAuthorizationTokenValid(token);
}
protected bool DoHtmlRedirectIfConfigured(IRequest req, IResponse res, bool includeRedirectParam = false)
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json
index 29862cca6..a263d960d 100644
--- a/MediaBrowser.Server.Implementations/Localization/Server/server.json
+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json
@@ -889,7 +889,7 @@
"LabelProtocolInfoHelp": "The value that will be used when responding to GetProtocolInfo requests from the device.",
"TabKodiMetadata": "Kodi",
"HeaderKodiMetadataHelp": "Media Browser includes native support for Kodi Nfo metadata and images. To enable or disable Kodi metadata, use the Advanced tab to configure options for your media types.",
- "LabelKodiMetadataUser": "Add user watch data to nfo's for:",
+ "LabelKodiMetadataUser": "Sync user watch data to nfo's for:",
"LabelKodiMetadataUserHelp": "Enable this to keep watch data in sync between Media Browser and Kodi.",
"LabelKodiMetadataDateFormat": "Release date format:",
"LabelKodiMetadataDateFormatHelp": "All dates within nfo's will be read and written to using this format.",