1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00

Reformat and apply Stylecop rules

This commit is contained in:
ta264
2019-12-22 22:08:53 +00:00
committed by Qstick
parent d4fa9b7345
commit f02fa629cc
1186 changed files with 7105 additions and 5616 deletions
@@ -16,8 +16,8 @@ namespace Radarr.Http.Authentication
{
_authService = authService;
_configFileProvider = configFileProvider;
Post("/login", x => Login(this.Bind<LoginResource>()));
Get("/logout", x => Logout());
Post("/login", x => Login(this.Bind<LoginResource>()));
Get("/logout", x => Logout());
}
private Response Login(LoginResource resource)
@@ -25,8 +25,8 @@ namespace Radarr.Http.Authentication
public class AuthenticationService : IAuthenticationService
{
private static readonly Logger _authLogger = LogManager.GetLogger("Auth");
private const string AnonymousUser = "Anonymous";
private static readonly Logger _authLogger = LogManager.GetLogger("Auth");
private readonly IUserService _userService;
private static string API_KEY;
@@ -170,14 +170,20 @@ namespace Radarr.Http.Authentication
private bool ValidUser(NancyContext context)
{
if (context.CurrentUser != null) return true;
if (context.CurrentUser != null)
{
return true;
}
return false;
}
private bool ValidApiKey(string apiKey)
{
if (API_KEY.Equals(apiKey)) return true;
if (API_KEY.Equals(apiKey))
{
return true;
}
return false;
}
@@ -19,7 +19,7 @@ namespace Radarr.Http.Authentication
private readonly IAuthenticationService _authenticationService;
private readonly IConfigService _configService;
private readonly IConfigFileProvider _configFileProvider;
private FormsAuthenticationConfiguration FormsAuthConfig;
private FormsAuthenticationConfiguration _formsAuthConfig;
public EnableAuthInNancy(IAuthenticationService authenticationService,
IConfigService configService,
@@ -39,7 +39,6 @@ namespace Radarr.Http.Authentication
RegisterFormsAuth(pipelines);
pipelines.AfterRequest.AddItemToEndOfPipeline((Action<NancyContext>)SlidingAuthenticationForFormsAuth);
}
else if (_configFileProvider.AuthenticationMethod == AuthenticationType.Basic)
{
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(_authenticationService, "Radarr"));
@@ -57,7 +56,6 @@ namespace Radarr.Http.Authentication
return null;
}
private Response RequiresAuthentication(NancyContext context)
{
Response response = null;
@@ -77,10 +75,9 @@ namespace Radarr.Http.Authentication
var cryptographyConfiguration = new CryptographyConfiguration(
new AesEncryptionProvider(new PassphraseKeyGenerator(_configService.RijndaelPassphrase, Encoding.ASCII.GetBytes(_configService.RijndaelSalt))),
new DefaultHmacProvider(new PassphraseKeyGenerator(_configService.HmacPassphrase, Encoding.ASCII.GetBytes(_configService.HmacSalt)))
);
new DefaultHmacProvider(new PassphraseKeyGenerator(_configService.HmacPassphrase, Encoding.ASCII.GetBytes(_configService.HmacSalt))));
FormsAuthConfig = new FormsAuthenticationConfiguration
_formsAuthConfig = new FormsAuthenticationConfiguration
{
RedirectUrl = _configFileProvider.UrlBase + "/login",
UserMapper = _authenticationService,
@@ -88,7 +85,7 @@ namespace Radarr.Http.Authentication
CryptographyConfiguration = cryptographyConfiguration
};
FormsAuthentication.Enable(pipelines, FormsAuthConfig);
FormsAuthentication.Enable(pipelines, _formsAuthConfig);
}
private void RemoveLoginHooksForApiCalls(NancyContext context)
@@ -118,7 +115,7 @@ namespace Radarr.Http.Authentication
{
var formsAuthCookieValue = context.Request.Cookies[formsAuthCookieName];
if (FormsAuthentication.DecryptAndValidateAuthenticationCookie(formsAuthCookieValue, FormsAuthConfig).IsNotNullOrWhiteSpace())
if (FormsAuthentication.DecryptAndValidateAuthenticationCookie(formsAuthCookieValue, _formsAuthConfig).IsNotNullOrWhiteSpace())
{
var formsAuthCookie = new NancyCookie(formsAuthCookieName, formsAuthCookieValue, true, false, DateTime.UtcNow.AddDays(7))
{