mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-02-12 19:22:45 +00:00
18 lines
683 B
C#
18 lines
683 B
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace Notesnook.API.Authorization
|
|
{
|
|
public class NotesnookUserRequirement : AuthorizationHandler<NotesnookUserRequirement>, IAuthorizationRequirement
|
|
{
|
|
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, NotesnookUserRequirement requirement)
|
|
{
|
|
var isInAudience = context.User.HasClaim("aud", "notesnook");
|
|
var hasRole = context.User.HasClaim("role", "notesnook");
|
|
if (isInAudience && hasRole)
|
|
context.Succeed(requirement);
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
} |