mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 18:57:39 -07:00
Basic Authentication Added
This commit is contained in:
parent
339e220cac
commit
f1d2e0e6df
13 changed files with 103 additions and 11 deletions
31
NzbDrone.Api/Authentication/AuthenticationValidator.cs
Normal file
31
NzbDrone.Api/Authentication/AuthenticationValidator.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Nancy.Authentication.Basic;
|
||||
using Nancy.Security;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Api.Authentication
|
||||
{
|
||||
public class AuthenticationValidator : IUserValidator
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
|
||||
public AuthenticationValidator(IConfigFileProvider configFileProvider)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
}
|
||||
|
||||
public IUserIdentity Validate(string username, string password)
|
||||
{
|
||||
if (_configFileProvider.BasicAuthUsername.Equals(username) &&
|
||||
_configFileProvider.BasicAuthPassword.Equals(password))
|
||||
{
|
||||
return new NzbDroneUser { UserName = username};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
15
NzbDrone.Api/Authentication/NzbDroneUser.cs
Normal file
15
NzbDrone.Api/Authentication/NzbDroneUser.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Nancy.Security;
|
||||
|
||||
namespace NzbDrone.Api.Authentication
|
||||
{
|
||||
public class NzbDroneUser : IUserIdentity
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
|
||||
public IEnumerable<string> Claims { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue