mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Allow Basic Auth on API
This commit is contained in:
parent
c5ae38638a
commit
5841140c99
3 changed files with 28 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue