Allow Basic Auth on API

This commit is contained in:
Mark McDowall 2013-09-23 15:31:50 -07:00
commit 5841140c99
3 changed files with 28 additions and 11 deletions

View file

@ -1,4 +1,6 @@
using Nancy.Authentication.Basic;
using System;
using Nancy;
using Nancy.Authentication.Basic;
using Nancy.Security;
using NzbDrone.Core.Configuration;
@ -7,6 +9,7 @@ namespace NzbDrone.Api.Authentication
public interface IAuthenticationService : IUserValidator
{
bool Enabled { get; }
bool IsAuthenticated(NancyContext context);
}
public class AuthenticationService : IAuthenticationService
@ -44,5 +47,12 @@ namespace NzbDrone.Api.Authentication
return _configFileProvider.AuthenticationEnabled;
}
}
public bool IsAuthenticated(NancyContext context)
{
if (context.CurrentUser == null && _configFileProvider.AuthenticationEnabled) return false;
return true;
}
}
}