(cherry picked from commit 8a3a998243e888e8f27c609f4bace5b42ad7ec50)zeus-old
parent
993144b67a
commit
46a20e1dcd
@ -0,0 +1,20 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace NzbDrone.Http.Authentication
|
||||
{
|
||||
public class ApiKeyRequirement : AuthorizationHandler<ApiKeyRequirement>, IAuthorizationRequirement
|
||||
{
|
||||
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ApiKeyRequirement requirement)
|
||||
{
|
||||
var apiKeyClaim = context.User.FindFirst(c => c.Type == "ApiKey");
|
||||
|
||||
if (apiKeyClaim != null)
|
||||
{
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue