From f104be6dd117f214bf141655bae9d86f3fb16777 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 21 Apr 2014 18:04:23 -0700 Subject: [PATCH 01/23] New: Support API Key via query string --- .../EnableStatelessAuthInNancy.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Api/Authentication/EnableStatelessAuthInNancy.cs b/src/NzbDrone.Api/Authentication/EnableStatelessAuthInNancy.cs index 1bcb8685e..a7aae870d 100644 --- a/src/NzbDrone.Api/Authentication/EnableStatelessAuthInNancy.cs +++ b/src/NzbDrone.Api/Authentication/EnableStatelessAuthInNancy.cs @@ -5,7 +5,6 @@ using Nancy.Bootstrapper; using NzbDrone.Api.Extensions; using NzbDrone.Api.Extensions.Pipelines; using NzbDrone.Common; -using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Core.Configuration; namespace NzbDrone.Api.Authentication @@ -28,9 +27,7 @@ namespace NzbDrone.Api.Authentication { Response response = null; - var authorizationHeader = context.Request.Headers.Authorization; - var apiKeyHeader = context.Request.Headers["X-Api-Key"].FirstOrDefault(); - var apiKey = apiKeyHeader.IsNullOrWhiteSpace() ? authorizationHeader : apiKeyHeader; + var apiKey = GetApiKey(context); if (context.Request.IsApiRequest() && !ValidApiKey(apiKey)) { @@ -46,5 +43,23 @@ namespace NzbDrone.Api.Authentication return true; } + + private string GetApiKey(NancyContext context) + { + var apiKeyHeader = context.Request.Headers["X-Api-Key"].FirstOrDefault(); + var apiKeyQueryString = context.Request.Query["ApiKey"]; + + if (!apiKeyHeader.IsNullOrWhiteSpace()) + { + return apiKeyHeader; + } + + if (apiKeyQueryString.HasValue) + { + return apiKeyQueryString.Value; + } + + return context.Request.Headers.Authorization; + } } } \ No newline at end of file From cde3d0b44ab2508ff87d519d84977a6802c3396c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 21 Apr 2014 20:11:18 -0700 Subject: [PATCH 02/23] Don't throw permissions errors when importing files Fixed: Better error handling when setting permissions after import (mono) --- .../MediaFiles/EpisodeFileMovingService.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs index 34eac41c4..5e3086835 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeFileMovingService.cs @@ -7,6 +7,7 @@ using NzbDrone.Common; using NzbDrone.Common.Disk; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Common.Exceptions; using NzbDrone.Core.Configuration; using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser.Model; @@ -172,15 +173,9 @@ namespace NzbDrone.Core.MediaFiles catch (Exception ex) { - if (ex is UnauthorizedAccessException || ex is InvalidOperationException) - { - _logger.Debug("Unable to apply permissions to: ", path); - _logger.DebugException(ex.Message, ex); - } - else - { - throw; - } + + _logger.WarnException("Unable to apply permissions to: " + path, ex); + _logger.DebugException(ex.Message, ex); } } From bb25c8955cedd8728454344907c400582377cdaa Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 21 Apr 2014 20:45:13 -0700 Subject: [PATCH 03/23] Advanced options toggle should be more clear --- src/UI/Settings/SettingsLayoutTemplate.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UI/Settings/SettingsLayoutTemplate.html b/src/UI/Settings/SettingsLayoutTemplate.html index 62ee238fb..f5717ede2 100644 --- a/src/UI/Settings/SettingsLayoutTemplate.html +++ b/src/UI/Settings/SettingsLayoutTemplate.html @@ -11,8 +11,8 @@