I have added the current user role and claims to the nuget Usefull Endpoints for .NET Core . The endpoints are
api/usefull/user/isInRole/{roleName}
and
api/usefull/user/claims/simple
and
api/usefull/user/authorization
For the first one the code is pretty simple
 route.MapGet("api/usefull/user/isInRole/{roleName}",(HttpContext httpContext,string roleName) =>
        {            
            return httpContext.User?.IsInRole(roleName)??false;
        }).WithTags("NetCoreUsefullEndpoints")
        .WithOpenApi();
For claims and authorization,please see code at ignatandrei/NetCoreUsefullEndpoints: Usefull Endpoints for .NET Core
Leave a Reply