From 3bed87ec4e44b0af6392ff838db233807b11c587 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 21 May 2013 22:55:53 -0700 Subject: [PATCH] fixed authentication. --- .../Authentication/AuthenticationValidator.cs | 14 ++++++++------ NzbDrone.Api/NancyBootstrapper.cs | 9 +++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/NzbDrone.Api/Authentication/AuthenticationValidator.cs b/NzbDrone.Api/Authentication/AuthenticationValidator.cs index c979e1467..ec8fd1154 100644 --- a/NzbDrone.Api/Authentication/AuthenticationValidator.cs +++ b/NzbDrone.Api/Authentication/AuthenticationValidator.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Nancy.Authentication.Basic; +using Nancy.Authentication.Basic; using Nancy.Security; using NzbDrone.Common; +using NzbDrone.Common.Model; namespace NzbDrone.Api.Authentication { @@ -19,10 +16,15 @@ namespace NzbDrone.Api.Authentication public IUserIdentity Validate(string username, string password) { + if (_configFileProvider.AuthenticationType == AuthenticationType.Anonymous) + { + return new NzbDroneUser { UserName = "Anonymous" }; + } + if (_configFileProvider.BasicAuthUsername.Equals(username) && _configFileProvider.BasicAuthPassword.Equals(password)) { - return new NzbDroneUser { UserName = username}; + return new NzbDroneUser { UserName = username }; } return null; diff --git a/NzbDrone.Api/NancyBootstrapper.cs b/NzbDrone.Api/NancyBootstrapper.cs index 348d0acbe..cded8b292 100644 --- a/NzbDrone.Api/NancyBootstrapper.cs +++ b/NzbDrone.Api/NancyBootstrapper.cs @@ -39,12 +39,9 @@ namespace NzbDrone.Api container.Resolve().PublishEvent(new ApplicationStartedEvent()); - if (container.Resolve().AuthenticationType == AuthenticationType.Basic) - { - pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration( - container.Resolve(), - "NzbDrone")); - } + pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration( + container.Resolve(), + "NzbDrone")); ApplicationPipelines.OnError.AddItemToEndOfPipeline(container.Resolve().HandleException); }