Skip to content

MiniProfilerOptions.ResultsAuthorize and ResultsListAuthorize are not async #354

@metoule

Description

@metoule

To properly check who can access the profiler results, I first need to authenticate the user, but the authentication API is async. That means I have to block the call in ResultsAuthorize, for example:

    services.AddMiniProfiler(options =>
    {
        options.RouteBasePath = "/profiler";
        options.ResultsAuthorize = request =>
        {
            var context = request.HttpContext;

            // --> here, I'd like to write await context.AuthenticateAsync()
            var authResult = context.AuthenticateAsync().Result;
            if (!authResult.Succeeded)
                return false;

            var claimsPrincipal = authResult.Principal;
            return claimsPrincipal.IsInRole("ProfilerContributor");
        };
    })

Do you think you could add an async version Func<HttpRequest, Task<bool>>? Or is there a better way to authenticate a user first?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions