From 5ca4d60c34c7ead76c388bd2c3ca192b38aae1f0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 28 Oct 2014 19:17:55 -0400 Subject: [PATCH] connect updates --- MediaBrowser.Api/System/SystemService.cs | 2 +- MediaBrowser.Api/UserService.cs | 2 +- .../Entities/AdultVideo.cs | 13 +--- .../Entities/Movies/Movie.cs | 10 +-- MediaBrowser.Controller/Entities/Trailer.cs | 9 +-- MediaBrowser.Controller/Entities/Video.cs | 8 +++ .../LiveTv/LiveTvChannel.cs | 5 ++ .../Net/AuthenticatedAttribute.cs | 34 ++++++++-- MediaBrowser.Controller/Net/IAuthService.cs | 4 +- MediaBrowser.Controller/Playlists/Playlist.cs | 5 ++ .../MediaBrowser.Model.Portable.csproj | 6 ++ .../MediaBrowser.Model.net35.csproj | 6 ++ MediaBrowser.Model/ApiClient/ApiHelpers.cs | 22 +++++++ .../ApiClient/ConnectionState.cs | 3 +- .../ApiClient/HttpResponseEventArgs.cs | 11 ++++ MediaBrowser.Model/ApiClient/IApiClient.cs | 2 +- .../ApiClient/RemoteLogoutReason.cs | 9 +++ MediaBrowser.Model/MediaBrowser.Model.csproj | 2 + .../Manager/MetadataService.cs | 20 +++++- .../Manager/ProviderUtils.cs | 66 +++++++++++-------- .../HttpServer/HttpListenerHost.cs | 4 +- .../HttpServer/ResponseFilter.cs | 2 +- .../HttpServer/Security/AuthService.cs | 20 +++--- .../Localization/JavaScript/javascript.json | 5 +- .../Api/PackageCreator.cs | 1 + .../MediaBrowser.WebDashboard.csproj | 3 + Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 30 files changed, 194 insertions(+), 92 deletions(-) create mode 100644 MediaBrowser.Model/ApiClient/ApiHelpers.cs create mode 100644 MediaBrowser.Model/ApiClient/RemoteLogoutReason.cs diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index 3fb17f74ea..9d22d8dfaa 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Api.System /// Class GetSystemInfo /// [Route("/System/Info", "GET", Summary = "Gets information about the server")] - [Authenticated] + [Authenticated(EscapeParentalControl = true)] public class GetSystemInfo : IReturn { diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 48bd2fc1ea..ec0b853c58 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Api /// Class GetUser /// [Route("/Users/{Id}", "GET", Summary = "Gets a user by Id")] - [Authenticated] + [Authenticated(EscapeParentalControl = true)] public class GetUser : IReturn { /// diff --git a/MediaBrowser.Controller/Entities/AdultVideo.cs b/MediaBrowser.Controller/Entities/AdultVideo.cs index 90e54c887c..ec2913ab46 100644 --- a/MediaBrowser.Controller/Entities/AdultVideo.cs +++ b/MediaBrowser.Controller/Entities/AdultVideo.cs @@ -5,19 +5,8 @@ using System.Collections.Generic; namespace MediaBrowser.Controller.Entities { [Obsolete] - public class AdultVideo : Video, IHasProductionLocations, IHasPreferredMetadataLanguage, IHasTaglines + public class AdultVideo : Video, IHasProductionLocations, IHasTaglines { - /// - /// Gets or sets the preferred metadata language. - /// - /// The preferred metadata language. - public string PreferredMetadataLanguage { get; set; } - - /// - /// Gets or sets the preferred metadata country code. - /// - /// The preferred metadata country code. - public string PreferredMetadataCountryCode { get; set; } public List ProductionLocations { get; set; } public List Taglines { get; set; } diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 8d2f19d4c1..c0afe3df9e 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities.Movies /// /// Class Movie /// - public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasSpecialFeatures, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasPreferredMetadataLanguage, IHasAwards, IHasMetascore, IHasLookupInfo, ISupportsBoxSetGrouping + public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasSpecialFeatures, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasAwards, IHasMetascore, IHasLookupInfo, ISupportsBoxSetGrouping { public List SpecialFeatureIds { get; set; } @@ -30,14 +30,6 @@ namespace MediaBrowser.Controller.Entities.Movies [IgnoreDataMember] public List BoxSetIdList { get; set; } - /// - /// Gets or sets the preferred metadata country code. - /// - /// The preferred metadata country code. - public string PreferredMetadataCountryCode { get; set; } - - public string PreferredMetadataLanguage { get; set; } - public Movie() { SpecialFeatureIds = new List(); diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 450555b3df..bbbf2358f0 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -12,19 +12,12 @@ namespace MediaBrowser.Controller.Entities /// /// Class Trailer /// - public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasProductionLocations, IHasBudget, IHasTrailers, IHasKeywords, IHasTaglines, IHasPreferredMetadataLanguage, IHasMetascore, IHasLookupInfo + public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasProductionLocations, IHasBudget, IHasTrailers, IHasKeywords, IHasTaglines, IHasMetascore, IHasLookupInfo { public List SoundtrackIds { get; set; } - public string PreferredMetadataLanguage { get; set; } public List ProductionLocations { get; set; } - /// - /// Gets or sets the preferred metadata country code. - /// - /// The preferred metadata country code. - public string PreferredMetadataCountryCode { get; set; } - public Trailer() { RemoteTrailers = new List(); diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 0b22d639e2..6550f43b43 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -25,6 +25,7 @@ namespace MediaBrowser.Controller.Entities ISupportsPlaceHolders, IHasMediaSources, IHasShortOverview, + IHasPreferredMetadataLanguage, IThemeMedia { public bool IsMultiPart { get; set; } @@ -43,6 +44,13 @@ namespace MediaBrowser.Controller.Entities public string ShortOverview { get; set; } public ExtraType ExtraType { get; set; } + /// + /// Gets or sets the preferred metadata country code. + /// + /// The preferred metadata country code. + public string PreferredMetadataCountryCode { get; set; } + public string PreferredMetadataLanguage { get; set; } + /// /// Gets or sets the timestamp. /// diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index f2fa912cad..df118b25fe 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -50,6 +50,11 @@ namespace MediaBrowser.Controller.LiveTv } } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + /// /// Gets or sets the number. /// diff --git a/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs b/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs index 31bb7c66be..83e404dfce 100644 --- a/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs +++ b/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs @@ -1,10 +1,11 @@ using ServiceStack.Web; using System; +using System.Collections.Generic; using System.Linq; namespace MediaBrowser.Controller.Net { - public class AuthenticatedAttribute : Attribute, IHasRequestFilter + public class AuthenticatedAttribute : Attribute, IHasRequestFilter, IAuthenticated { public IAuthService AuthService { get; set; } @@ -14,8 +15,18 @@ namespace MediaBrowser.Controller.Net /// true if [allow local]; otherwise, false. public bool AllowLocal { get; set; } + /// + /// Gets or sets the roles. + /// + /// The roles. public string Roles { get; set; } + /// + /// Gets or sets a value indicating whether [escape parental control]. + /// + /// true if [escape parental control]; otherwise, false. + public bool EscapeParentalControl { get; set; } + /// /// The request filter is executed before the service. /// @@ -24,11 +35,7 @@ namespace MediaBrowser.Controller.Net /// The request DTO public void RequestFilter(IRequest request, IResponse response, object requestDto) { - var roles = (Roles ?? string.Empty).Split(',') - .Where(i => !string.IsNullOrWhiteSpace(i)) - .ToArray(); - - AuthService.Authenticate(request, response, requestDto, AllowLocal, roles); + AuthService.Authenticate(request, response, requestDto, this); } /// @@ -50,5 +57,20 @@ namespace MediaBrowser.Controller.Net { get { return 0; } } + + + public IEnumerable GetRoles() + { + return (Roles ?? string.Empty).Split(',') + .Where(i => !string.IsNullOrWhiteSpace(i)); + } + } + + public interface IAuthenticated + { + bool EscapeParentalControl { get; } + + bool AllowLocal { get; } + IEnumerable GetRoles(); } } diff --git a/MediaBrowser.Controller/Net/IAuthService.cs b/MediaBrowser.Controller/Net/IAuthService.cs index 69014d0ff1..9d335566ff 100644 --- a/MediaBrowser.Controller/Net/IAuthService.cs +++ b/MediaBrowser.Controller/Net/IAuthService.cs @@ -1,5 +1,4 @@ using ServiceStack.Web; -using System.Collections.Generic; namespace MediaBrowser.Controller.Net { @@ -8,7 +7,6 @@ namespace MediaBrowser.Controller.Net void Authenticate(IRequest request, IResponse response, object requestDto, - bool allowLocal, - string[] roles); + IAuthenticated authAttribtues); } } diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index f7bd439a33..75e1bbde71 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -33,6 +33,11 @@ namespace MediaBrowser.Controller.Playlists } } + public override bool IsSaveLocalMetadataEnabled() + { + return true; + } + public override IEnumerable GetChildren(User user, bool includeLinkedChildren) { return GetPlayableItems(user); diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index a24f0cd2cf..627b7a2662 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -74,6 +74,9 @@ ApiClient\ApiClientExtensions.cs + + ApiClient\ApiHelpers.cs + ApiClient\ConnectionMode.cs @@ -104,6 +107,9 @@ ApiClient\IServerEvents.cs + + ApiClient\RemoteLogoutReason.cs + ApiClient\ServerCredentials.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index d03672966a..7c3235eed9 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -54,6 +54,9 @@ Activity\ActivityLogEntry.cs + + ApiClient\ApiHelpers.cs + ApiClient\ConnectionMode.cs @@ -69,6 +72,9 @@ ApiClient\IServerEvents.cs + + ApiClient\RemoteLogoutReason.cs + ApiClient\ServerCredentials.cs diff --git a/MediaBrowser.Model/ApiClient/ApiHelpers.cs b/MediaBrowser.Model/ApiClient/ApiHelpers.cs new file mode 100644 index 0000000000..65b6495ab2 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/ApiHelpers.cs @@ -0,0 +1,22 @@ +using System; + +namespace MediaBrowser.Model.ApiClient +{ + public static class ApiHelpers + { + /// + /// Gets the name of the slug. + /// + /// The name. + /// System.String. + public static string GetSlugName(string name) + { + if (string.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + + return name.Replace('/', '-').Replace('?', '-').Replace('&', '-'); + } + } +} diff --git a/MediaBrowser.Model/ApiClient/ConnectionState.cs b/MediaBrowser.Model/ApiClient/ConnectionState.cs index 63e156eb1f..5e47d688e1 100644 --- a/MediaBrowser.Model/ApiClient/ConnectionState.cs +++ b/MediaBrowser.Model/ApiClient/ConnectionState.cs @@ -5,6 +5,7 @@ namespace MediaBrowser.Model.ApiClient Unavailable = 1, ServerSignIn = 2, SignedIn = 3, - ServerSelection = 4 + ServerSelection = 4, + ConnectSignIn = 5 } } \ No newline at end of file diff --git a/MediaBrowser.Model/ApiClient/HttpResponseEventArgs.cs b/MediaBrowser.Model/ApiClient/HttpResponseEventArgs.cs index 417db404fa..b1c19f0566 100644 --- a/MediaBrowser.Model/ApiClient/HttpResponseEventArgs.cs +++ b/MediaBrowser.Model/ApiClient/HttpResponseEventArgs.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Net; namespace MediaBrowser.Model.ApiClient @@ -18,5 +19,15 @@ namespace MediaBrowser.Model.ApiClient /// /// The status code. public HttpStatusCode StatusCode { get; set; } + /// + /// Gets or sets the headers. + /// + /// The headers. + public Dictionary Headers { get; set; } + + public HttpResponseEventArgs() + { + Headers = new Dictionary(); + } } } diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index bc909284b3..89c7312238 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Model.ApiClient /// /// Occurs when [remote logged out]. /// - event EventHandler RemoteLoggedOut; + event EventHandler> RemoteLoggedOut; /// /// Occurs when [authenticated]. diff --git a/MediaBrowser.Model/ApiClient/RemoteLogoutReason.cs b/MediaBrowser.Model/ApiClient/RemoteLogoutReason.cs new file mode 100644 index 0000000000..237949c694 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/RemoteLogoutReason.cs @@ -0,0 +1,9 @@ + +namespace MediaBrowser.Model.ApiClient +{ + public enum RemoteLogoutReason + { + GeneralAccesError = 0, + ParentalControlRestriction = 1 + } +} diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 549023303e..24bf2c93c6 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -60,6 +60,7 @@ Properties\SharedVersion.cs + @@ -71,6 +72,7 @@ + diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 1f46ee488e..e27c39df13 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -350,6 +350,7 @@ namespace MediaBrowser.Providers.Manager { var remoteResult = await ExecuteRemoteProviders(item, temp, logName, id, providers.OfType>(), cancellationToken) .ConfigureAwait(false); + refreshResult.UpdateType = refreshResult.UpdateType | remoteResult.UpdateType; refreshResult.Status = remoteResult.Status; refreshResult.ErrorMessage = remoteResult.ErrorMessage; @@ -359,8 +360,9 @@ namespace MediaBrowser.Providers.Manager var hasLocalMetadata = false; var userDataList = new List(); + var localProviders = providers.OfType>().ToList(); - foreach (var provider in providers.OfType>()) + foreach (var provider in localProviders) { var providerName = provider.GetType().Name; Logger.Debug("Running {0} for {1}", providerName, logName); @@ -428,6 +430,16 @@ namespace MediaBrowser.Providers.Manager successfulProviderCount += remoteResult.Successes; } + // If no local providers and doing a full refresh, take data from item itself + if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh && + localProviders.Count == 0 && + refreshResult.UpdateType > ItemUpdateType.None) + { + // TODO: If the new metadata from above has some blank data, this + // can cause old data to get filled into those empty fields + MergeData(item, temp, new List(), false, true); + } + if (refreshResult.UpdateType > ItemUpdateType.None) { MergeData(temp, item, item.LockedFields, true, true); @@ -598,7 +610,11 @@ namespace MediaBrowser.Providers.Manager } } - protected abstract void MergeData(TItemType source, TItemType target, List lockedFields, bool replaceData, bool mergeMetadataSettings); + protected abstract void MergeData(TItemType source, + TItemType target, + List lockedFields, + bool replaceData, + bool mergeMetadataSettings); public virtual int Order { diff --git a/MediaBrowser.Providers/Manager/ProviderUtils.cs b/MediaBrowser.Providers/Manager/ProviderUtils.cs index 2c19c33123..155cd208f3 100644 --- a/MediaBrowser.Providers/Manager/ProviderUtils.cs +++ b/MediaBrowser.Providers/Manager/ProviderUtils.cs @@ -8,7 +8,11 @@ namespace MediaBrowser.Providers.Manager { public static class ProviderUtils { - public static void MergeBaseItemData(BaseItem source, BaseItem target, List lockedFields, bool replaceData, bool mergeMetadataSettings) + public static void MergeBaseItemData(BaseItem source, + BaseItem target, + List lockedFields, + bool replaceData, + bool mergeMetadataSettings) { if (!lockedFields.Contains(MetadataFields.Name)) { @@ -191,36 +195,42 @@ namespace MediaBrowser.Providers.Manager if (mergeMetadataSettings) { - target.ForcedSortName = source.ForcedSortName; - target.LockedFields = source.LockedFields; - target.IsLocked = source.IsLocked; - target.DisplayMediaType = source.DisplayMediaType; - - // Grab the value if it's there, but if not then don't overwrite the default - if (source.DateCreated != default(DateTime)) - { - target.DateCreated = source.DateCreated; - } - - var sourceHasLanguageSettings = source as IHasPreferredMetadataLanguage; - var targetHasLanguageSettings = target as IHasPreferredMetadataLanguage; - - if (sourceHasLanguageSettings != null && targetHasLanguageSettings != null) - { - targetHasLanguageSettings.PreferredMetadataCountryCode = sourceHasLanguageSettings.PreferredMetadataCountryCode; - targetHasLanguageSettings.PreferredMetadataLanguage = sourceHasLanguageSettings.PreferredMetadataLanguage; - } - - var sourceHasDisplayOrder = source as IHasDisplayOrder; - var targetHasDisplayOrder = target as IHasDisplayOrder; - - if (sourceHasDisplayOrder != null && targetHasDisplayOrder != null) - { - targetHasDisplayOrder.DisplayOrder = sourceHasDisplayOrder.DisplayOrder; - } + MergeMetadataSettings(source, target); } } + public static void MergeMetadataSettings(BaseItem source, + BaseItem target) + { + target.ForcedSortName = source.ForcedSortName; + target.LockedFields = source.LockedFields; + target.IsLocked = source.IsLocked; + target.DisplayMediaType = source.DisplayMediaType; + + // Grab the value if it's there, but if not then don't overwrite the default + if (source.DateCreated != default(DateTime)) + { + target.DateCreated = source.DateCreated; + } + + var sourceHasLanguageSettings = source as IHasPreferredMetadataLanguage; + var targetHasLanguageSettings = target as IHasPreferredMetadataLanguage; + + if (sourceHasLanguageSettings != null && targetHasLanguageSettings != null) + { + targetHasLanguageSettings.PreferredMetadataCountryCode = sourceHasLanguageSettings.PreferredMetadataCountryCode; + targetHasLanguageSettings.PreferredMetadataLanguage = sourceHasLanguageSettings.PreferredMetadataLanguage; + } + + var sourceHasDisplayOrder = source as IHasDisplayOrder; + var targetHasDisplayOrder = target as IHasDisplayOrder; + + if (sourceHasDisplayOrder != null && targetHasDisplayOrder != null) + { + targetHasDisplayOrder.DisplayOrder = sourceHasDisplayOrder.DisplayOrder; + } + } + private static void MergeShortOverview(BaseItem source, BaseItem target, List lockedFields, bool replaceData) { var sourceHasShortOverview = source as IHasShortOverview; diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 4972736ef5..a750dd82ee 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -235,14 +235,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer { return; } - + var errorResponse = new ErrorResponse { ResponseStatus = new ResponseStatus { ErrorCode = ex.GetType().GetOperationName(), Message = ex.Message, - StackTrace = ex.StackTrace, + StackTrace = ex.StackTrace } }; diff --git a/MediaBrowser.Server.Implementations/HttpServer/ResponseFilter.cs b/MediaBrowser.Server.Implementations/HttpServer/ResponseFilter.cs index e0a5764d5c..23ecde1910 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/ResponseFilter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/ResponseFilter.cs @@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// /// The in string. /// System.String. - private static string RemoveControlCharacters(string inString) + public static string RemoveControlCharacters(string inString) { if (inString == null) return null; diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs index a1a68586b7..3a2bd7b752 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; @@ -45,8 +44,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security public void Authenticate(IRequest request, IResponse response, object requestDto, - bool allowLocal, - string[] roles) + IAuthenticated authAttribtues) { if (HostContext.HasValidAuthSecret(request)) return; @@ -54,16 +52,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security //ExecuteBasic(req, res, requestDto); //first check if session is authenticated //if (res.IsClosed) return; //AuthenticateAttribute already closed the request (ie auth failed) - ValidateUser(request, allowLocal, roles); + ValidateUser(request, response, authAttribtues); } - private void ValidateUser(IRequest req, bool allowLocal, - IEnumerable roles) + private void ValidateUser(IRequest req, IResponse response, IAuthenticated authAttribtues) { // This code is executed before the service var auth = AuthorizationContext.GetAuthorizationInfo(req); - if (!allowLocal || !req.IsLocal) + if (!authAttribtues.AllowLocal || !req.IsLocal) { if (!string.IsNullOrWhiteSpace(auth.Token) || !_config.Configuration.InsecureApps2.Contains(auth.Client ?? string.Empty, StringComparer.OrdinalIgnoreCase)) @@ -91,12 +88,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security throw new AuthenticationException("User account has been disabled."); } - if (!user.Configuration.IsAdministrator && !user.IsParentalScheduleAllowed()) + if (!user.Configuration.IsAdministrator && + !authAttribtues.EscapeParentalControl && + !user.IsParentalScheduleAllowed()) { + response.AddHeader("X-Application-Error-Code", "ParentalControl"); throw new AuthenticationException("This user account is not allowed access at this time."); } } + var roles = authAttribtues.GetRoles().ToList(); + if (roles.Contains("admin", StringComparer.OrdinalIgnoreCase)) { if (user == null || !user.Configuration.IsAdministrator) diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 7b5fd2da6e..9a7d24a704 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -619,6 +619,7 @@ "MessageInvitationSentToNewUser": "An email has been sent to {0} inviting them to sign up with Media Browser.", "HeaderConnectionFailure": "Connection Failure", "MessageUnableToConnectToServer": "We're unable to connect to the selected right now. Please try again later.", - "ButtonSelectServer": "Select server", - "MessagePluginConfigurationRequiresLocalAccess": "To configure this plugin please sign in to your local server directly." + "ButtonSelectServer": "Select server", + "MessagePluginConfigurationRequiresLocalAccess": "To configure this plugin please sign in to your local server directly.", + "MessageLoggedOutParentalControl": "Access is currently restricted. Please try again later." } diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 09bda8efe5..e835f6d49f 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -265,6 +265,7 @@ namespace MediaBrowser.WebDashboard.Api "thirdparty/apiclient/md5.js", "thirdparty/apiclient/sha1.js", "thirdparty/apiclient/store.js", + "thirdparty/apiclient/network.js", "thirdparty/apiclient/device.js", "thirdparty/apiclient/credentials.js", "thirdparty/apiclient/mediabrowser.apiclient.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index dddf9c6313..b657acc65f 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -920,6 +920,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 23d51c9f57..e1aec93a39 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.501 + 3.0.502 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 41a81d8169..e467bae2d1 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.501 + 3.0.502 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index afd9c64a7c..093eb066e8 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.501 + 3.0.502 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 5e9b013d03..ca8aa13fa4 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.501 + 3.0.502 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +