Skip to content

Question: Upgrading to v4.0.0-alpha4 and Authentication #676

Closed
@fdlane

Description

@fdlane

Description

I am trying to upgrade to v4.0.0-alpha4 and my project has authentication.

This was working in 3.x but I am getting the following error.

Thank you for your help.

System.InvalidOperationException: Endpoint Controller.GetAsync contains authorization metadata, but a middleware was not found that supports authorization.
Configure your application startup by adding app.UseAuthorization() inside the call to Configure(..) in the application startup code. The call to app.UseAuthorization() must appear between app.UseRouting() and app.UseEndpoints(...).
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.ThrowMissingAuthMiddlewareException(Endpoint endpoint)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
   at JsonApiDotNetCore.Middleware.CurrentRequestMiddleware.Invoke(HttpContext httpContext, IControllerResourceMapping controllerResourceMapping, IJsonApiOptions options, ICurrentRequest currentRequest, IResourceGraph resourceGraph)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Here is my configure method that was working with 3.x

  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
      if (env.IsDevelopment())
      {
        app.UseDeveloperExceptionPage();
        app.EnableDetailedErrors();
      }
      else
      {
        // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
        app.UseHsts();
      }

      app.UseHttpsRedirection();  
      app.UseAuthentication();
      app.UseJsonApi();
    }

...

Environment

  • JsonApiDotNetCore Version: 4.0.0-alpha4
  • Other Relevant Package Versions:
    • netcoreapp3.1
    • Microsoft.AspNetCore.Authentication.AzureAD.UI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions