Skip to content

JsonAPI Middleware breaks authentication middleware #713

@mmatonok

Description

@mmatonok

Description

There is a problem in initialization middleware for JsonAPI and order.
All works fine untl authentication [Authorize] attribute in controller is setup.

After [Authorize] attribute is setup:

  1. in case UseJsonAPI is used before app.UseAuthentication() , system is not able to find authentiation middleware. custome error handler works.
    Below error is received for jsonapi controllers also no-json api controller where authentication is enabled.

{
"ErrorCode": 0,
"FriendlyMessage": "Endpoint xxxxxxxxController.GetAsync (xxxxxxx contains authorization metadata, but a middleware was not found that supports authorization.\nConfigure 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(...)."
}

  1. in cas UseJsonApi is used after .Useendpoints()..., JsonApi , attached error is received.
    also custom error handler ( not jsonapi ) does not work
    Note: no-jsonapi controllers with authentication in this case works fine.
    ...

Environment

  • JsonApiDotNetCore Version: 4.0.0 - alpha4
  • Other Relevant Package Versions: .net core 3.1
    error2.txt

tnx.
m

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