mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 17:44:43 +01:00
update to jquery mobile 1.4.3
This commit is contained in:
@@ -51,13 +51,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||
|
||||
private void ValidateUser(IRequest req)
|
||||
{
|
||||
User user = null;
|
||||
|
||||
//This code is executed before the service
|
||||
var auth = AuthorizationContext.GetAuthorizationInfo(req);
|
||||
|
||||
if (auth != null)
|
||||
if (string.IsNullOrWhiteSpace(auth.Token))
|
||||
{
|
||||
// Legacy
|
||||
// TODO: Deprecate this in Oct 2014
|
||||
|
||||
User user = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(auth.UserId))
|
||||
{
|
||||
var userId = auth.UserId;
|
||||
@@ -65,22 +68,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||
user = UserManager.GetUserById(new Guid(userId));
|
||||
}
|
||||
|
||||
string deviceId = auth.DeviceId;
|
||||
string device = auth.Device;
|
||||
string client = auth.Client;
|
||||
string version = auth.Version;
|
||||
|
||||
if (!string.IsNullOrEmpty(client) && !string.IsNullOrEmpty(deviceId) && !string.IsNullOrEmpty(device) && !string.IsNullOrEmpty(version))
|
||||
if (user == null || user.Configuration.IsDisabled)
|
||||
{
|
||||
var remoteEndPoint = req.RemoteIp;
|
||||
|
||||
SessionManager.LogSessionActivity(client, version, deviceId, device, remoteEndPoint, user);
|
||||
throw new UnauthorizedAccessException("Unauthorized access.");
|
||||
}
|
||||
}
|
||||
|
||||
if (user == null || user.Configuration.IsDisabled)
|
||||
else
|
||||
{
|
||||
throw new UnauthorizedAccessException("Unauthorized access.");
|
||||
SessionManager.ValidateSecurityToken(auth.Token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||
Device = device,
|
||||
DeviceId = deviceId,
|
||||
UserId = userId,
|
||||
Version = version
|
||||
Version = version,
|
||||
Token = httpReq.Headers["X-AUTH-TOKEN"]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -121,17 +121,20 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <summary>
|
||||
/// Authenticates a User and returns a result indicating whether or not it succeeded
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="password">The password.</param>
|
||||
/// <returns>Task{System.Boolean}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">user</exception>
|
||||
public async Task<bool> AuthenticateUser(User user, string password)
|
||||
/// <exception cref="System.UnauthorizedAccessException"></exception>
|
||||
public async Task<bool> AuthenticateUser(string username, string password)
|
||||
{
|
||||
if (user == null)
|
||||
if (string.IsNullOrWhiteSpace(username))
|
||||
{
|
||||
throw new ArgumentNullException("user");
|
||||
throw new ArgumentNullException("username");
|
||||
}
|
||||
|
||||
var user = Users.First(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (user.Configuration.IsDisabled)
|
||||
{
|
||||
throw new UnauthorizedAccessException(string.Format("The {0} account is currently disabled. Please consult with your administrator.", user.Name));
|
||||
|
||||
@@ -49,8 +49,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
private readonly List<ILiveTvService> _services = new List<ILiveTvService>();
|
||||
|
||||
private readonly ConcurrentDictionary<string, LiveStreamInfo> _openStreams =
|
||||
new ConcurrentDictionary<string, LiveStreamInfo>();
|
||||
private readonly ConcurrentDictionary<string, LiveStreamData> _openStreams =
|
||||
new ConcurrentDictionary<string, LiveStreamData>();
|
||||
|
||||
private List<Guid> _channelIdList = new List<Guid>();
|
||||
private Dictionary<Guid, LiveTvProgram> _programs = new Dictionary<Guid, LiveTvProgram>();
|
||||
@@ -292,65 +292,68 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
public async Task<LiveStreamInfo> GetRecordingStream(string id, CancellationToken cancellationToken)
|
||||
{
|
||||
await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
var service = ActiveService;
|
||||
|
||||
var recordings = await service.GetRecordingsAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var recording = recordings.First(i => _tvDtoService.GetInternalRecordingId(service.Name, i.Id) == new Guid(id));
|
||||
|
||||
var result = await service.GetRecordingStream(recording.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Sanitize(result);
|
||||
|
||||
_logger.Debug("Live stream info: " + _json.SerializeToString(result));
|
||||
|
||||
if (!string.IsNullOrEmpty(result.Id))
|
||||
{
|
||||
_openStreams.AddOrUpdate(result.Id, result, (key, info) => result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting recording stream", ex);
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_liveStreamSemaphore.Release();
|
||||
}
|
||||
return await GetLiveStream(id, false, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<LiveStreamInfo> GetChannelStream(string id, CancellationToken cancellationToken)
|
||||
{
|
||||
return await GetLiveStream(id, true, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<LiveStreamInfo> GetLiveStream(string id, bool isChannel, CancellationToken cancellationToken)
|
||||
{
|
||||
await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
var service = ActiveService;
|
||||
// Avoid implicitly captured closure
|
||||
var itemId = id;
|
||||
|
||||
var channel = GetInternalChannel(id);
|
||||
var stream = _openStreams
|
||||
.Where(i => string.Equals(i.Value.ItemId, itemId) && isChannel == i.Value.IsChannel)
|
||||
.Take(1)
|
||||
.Select(i => i.Value)
|
||||
.FirstOrDefault();
|
||||
|
||||
_logger.Info("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId);
|
||||
|
||||
var result = await service.GetChannelStream(channel.ExternalId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Sanitize(result);
|
||||
|
||||
_logger.Debug("Live stream info: " + _json.SerializeToString(result));
|
||||
|
||||
if (!string.IsNullOrEmpty(result.Id))
|
||||
if (stream != null)
|
||||
{
|
||||
_openStreams.AddOrUpdate(result.Id, result, (key, info) => result);
|
||||
stream.ConsumerCount++;
|
||||
_logger.Debug("Returning existing live tv stream");
|
||||
return stream.Info;
|
||||
}
|
||||
|
||||
return result;
|
||||
var service = ActiveService;
|
||||
LiveStreamInfo info;
|
||||
|
||||
if (isChannel)
|
||||
{
|
||||
var channel = GetInternalChannel(id);
|
||||
_logger.Info("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId);
|
||||
|
||||
info = await service.GetChannelStream(channel.ExternalId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var recordings = await service.GetRecordingsAsync(cancellationToken).ConfigureAwait(false);
|
||||
var recording = recordings.First(i => _tvDtoService.GetInternalRecordingId(service.Name, i.Id) == new Guid(id));
|
||||
|
||||
_logger.Info("Opening recording stream from {0}, external recording Id: {1}", service.Name, recording.Id);
|
||||
info = await service.GetRecordingStream(recording.Id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Sanitize(info);
|
||||
|
||||
var data = new LiveStreamData
|
||||
{
|
||||
Info = info,
|
||||
ConsumerCount = 1,
|
||||
IsChannel = isChannel,
|
||||
ItemId = id
|
||||
};
|
||||
|
||||
_openStreams.AddOrUpdate(info.Id, data, (key, i) => data);
|
||||
|
||||
return info;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1597,20 +1600,38 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
};
|
||||
}
|
||||
|
||||
class LiveStreamData
|
||||
{
|
||||
internal LiveStreamInfo Info;
|
||||
internal int ConsumerCount;
|
||||
internal string ItemId;
|
||||
internal bool IsChannel;
|
||||
}
|
||||
|
||||
public async Task CloseLiveStream(string id, CancellationToken cancellationToken)
|
||||
{
|
||||
await _liveStreamSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var service = ActiveService;
|
||||
|
||||
_logger.Info("Closing live stream from {0}, stream Id: {1}", service.Name, id);
|
||||
|
||||
try
|
||||
{
|
||||
await service.CloseLiveStream(id, cancellationToken).ConfigureAwait(false);
|
||||
var service = ActiveService;
|
||||
|
||||
LiveStreamInfo removed;
|
||||
_openStreams.TryRemove(id, out removed);
|
||||
LiveStreamData data;
|
||||
if (_openStreams.TryGetValue(id, out data))
|
||||
{
|
||||
if (data.ConsumerCount > 1)
|
||||
{
|
||||
data.ConsumerCount--;
|
||||
_logger.Info("Decrementing live stream client count.");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
_openStreams.TryRemove(id, out data);
|
||||
|
||||
_logger.Info("Closing live stream from {0}, stream Id: {1}", service.Name, id);
|
||||
|
||||
await service.CloseLiveStream(id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1662,7 +1683,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
{
|
||||
foreach (var stream in _openStreams.Values.ToList())
|
||||
{
|
||||
var task = CloseLiveStream(stream.Id, CancellationToken.None);
|
||||
var task = CloseLiveStream(stream.Info.Id, CancellationToken.None);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
@@ -201,5 +201,21 @@
|
||||
"ButtonOpenInNewTab": "Open in new tab",
|
||||
"ButtonShuffle": "Shuffle",
|
||||
"ButtonInstantMix": "Instant mix",
|
||||
"ButtonResume": "Resume"
|
||||
"ButtonResume": "Resume",
|
||||
"HeaderScenes": "Scenes",
|
||||
"HeaderAudioTracks": "Audio Tracks",
|
||||
"LabelUnknownLanguage": "Unknown language",
|
||||
"HeaderSubtitles": "Subtitles",
|
||||
"HeaderVideoQuality": "Video Quality",
|
||||
"MessageErrorPlayingVideo": "There was an error playing the video.",
|
||||
"MessageEnsureOpenTuner": "Please ensure there is an open tuner availalble.",
|
||||
"ButtonHome": "Home",
|
||||
"ButtonDashboard": "Dashboard",
|
||||
"ButtonReports": "Reports",
|
||||
"ButtonMetadataManager": "Metadata Manager",
|
||||
"HeaderTime": "Time",
|
||||
"HeaderName": "Name",
|
||||
"HeaderAlbum": "Album",
|
||||
"HeaderAlbumArtist": "Album Artist",
|
||||
"HeaderArtist": "Artist"
|
||||
}
|
||||
@@ -200,6 +200,7 @@
|
||||
<Compile Include="News\NewsService.cs" />
|
||||
<Compile Include="Notifications\CoreNotificationTypes.cs" />
|
||||
<Compile Include="Notifications\InternalNotificationService.cs" />
|
||||
<Compile Include="Notifications\NotificationConfigurationFactory.cs" />
|
||||
<Compile Include="Notifications\NotificationManager.cs" />
|
||||
<Compile Include="Persistence\SqliteChapterRepository.cs" />
|
||||
<Compile Include="Persistence\SqliteExtensions.cs" />
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Notifications
|
||||
{
|
||||
public class NotificationConfigurationFactory : IConfigurationFactory
|
||||
{
|
||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||
{
|
||||
return new List<ConfigurationStore>
|
||||
{
|
||||
new ConfigurationStore
|
||||
{
|
||||
Key = "notifications",
|
||||
ConfigurationType = typeof (NotificationOptions)
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -30,13 +31,18 @@ namespace MediaBrowser.Server.Implementations.Notifications
|
||||
_logger = logManager.GetLogger(GetType().Name);
|
||||
}
|
||||
|
||||
private NotificationOptions GetConfiguration()
|
||||
{
|
||||
return _config.GetConfiguration<NotificationOptions>("notifications");
|
||||
}
|
||||
|
||||
public Task SendNotification(NotificationRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var notificationType = request.NotificationType;
|
||||
|
||||
var options = string.IsNullOrWhiteSpace(notificationType) ?
|
||||
null :
|
||||
_config.Configuration.NotificationOptions.GetOptions(notificationType);
|
||||
GetConfiguration().GetOptions(notificationType);
|
||||
|
||||
var users = GetUserIds(request, options)
|
||||
.Except(request.ExcludeUserIds)
|
||||
@@ -223,7 +229,7 @@ namespace MediaBrowser.Server.Implementations.Notifications
|
||||
private bool IsEnabled(INotificationService service, string notificationType)
|
||||
{
|
||||
return string.IsNullOrEmpty(notificationType) ||
|
||||
_config.Configuration.NotificationOptions.IsServiceEnabled(service.Name, notificationType);
|
||||
GetConfiguration().IsServiceEnabled(service.Name, notificationType);
|
||||
}
|
||||
|
||||
public void AddParts(IEnumerable<INotificationService> services, IEnumerable<INotificationTypeFactory> notificationTypeFactories)
|
||||
@@ -248,9 +254,11 @@ namespace MediaBrowser.Server.Implementations.Notifications
|
||||
|
||||
}).SelectMany(i => i).ToList();
|
||||
|
||||
var config = GetConfiguration();
|
||||
|
||||
foreach (var i in list)
|
||||
{
|
||||
i.Enabled = _config.Configuration.NotificationOptions.IsEnabled(i.Type);
|
||||
i.Enabled = config.IsEnabled(i.Type);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -25,6 +25,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Session
|
||||
{
|
||||
@@ -1138,10 +1139,15 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
}
|
||||
}
|
||||
|
||||
public void ValidateSecurityToken(string token)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticates the new session.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="password">The password.</param>
|
||||
/// <param name="clientType">Type of the client.</param>
|
||||
/// <param name="appVersion">The application version.</param>
|
||||
@@ -1149,17 +1155,34 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
/// <param name="deviceName">Name of the device.</param>
|
||||
/// <param name="remoteEndPoint">The remote end point.</param>
|
||||
/// <returns>Task{SessionInfo}.</returns>
|
||||
/// <exception cref="System.UnauthorizedAccessException">Invalid user or password entered.</exception>
|
||||
/// <exception cref="UnauthorizedAccessException"></exception>
|
||||
public async Task<SessionInfo> AuthenticateNewSession(User user, string password, string clientType, string appVersion, string deviceId, string deviceName, string remoteEndPoint)
|
||||
public async Task<AuthenticationResult> AuthenticateNewSession(string username, string password, string clientType, string appVersion, string deviceId, string deviceName, string remoteEndPoint)
|
||||
{
|
||||
var result = await _userManager.AuthenticateUser(user, password).ConfigureAwait(false);
|
||||
var result = await _userManager.AuthenticateUser(username, password).ConfigureAwait(false);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
throw new UnauthorizedAccessException("Invalid user or password entered.");
|
||||
}
|
||||
|
||||
return await LogSessionActivity(clientType, appVersion, deviceId, deviceName, remoteEndPoint, user).ConfigureAwait(false);
|
||||
var user = _userManager.Users
|
||||
.First(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
var session = await LogSessionActivity(clientType,
|
||||
appVersion,
|
||||
deviceId,
|
||||
deviceName,
|
||||
remoteEndPoint,
|
||||
user)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return new AuthenticationResult
|
||||
{
|
||||
User = _dtoService.GetUserDto(user),
|
||||
SessionInfo = GetSessionInfoDto(session),
|
||||
AuthenticationToken = Guid.NewGuid().ToString("N")
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user