1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-15 21:05:48 -04:00
Files
Radarr/src/Radarr.Http/Authentication/NoAuthenticationHandler.cs
ta264 06e2d5b3c3 New: Use native dotnet host and DryIoc
(cherry picked from commit d6170dbfedf27a6218afe242a0fae2eb8b368aec)
(cherry picked from commit 7fe36a7e9222e830f4920e09a85115df0bdbf190)
2021-10-25 13:45:44 -04:00

38 lines
1.2 KiB
C#

using System.Collections.Generic;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NzbDrone.Core.Authentication;
namespace Radarr.Http.Authentication
{
public class NoAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{
public NoAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock)
: base(options, logger, encoder, clock)
{
}
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
var claims = new List<Claim>
{
new Claim("user", "Anonymous"),
new Claim("AuthType", AuthenticationType.None.ToString())
};
var identity = new ClaimsIdentity(claims, "NoAuth", "user", "identifier");
var principal = new ClaimsPrincipal(identity);
var ticket = new AuthenticationTicket(principal, "NoAuth");
return Task.FromResult(AuthenticateResult.Success(ticket));
}
}
}