79122252

Date: 2024-10-24 13:58:21
Score: 3
Natty:
Report link

I'm using DataAnnotatedModelValidations package in my GraphQL application And i've shared a part of my program.cs

builder.Services
 .AddGraphQLServer()
 .AddDataAnnotationsValidator()
.
.
.
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.MapGraphQL("/");

My problem is every time I am executing a mutation a validation process has priority over authorization. So if I am executing a mutation with invalid input and without required permission the expected behavior would be to get an unauthorized error but i get the list of validation errors. When I validate my input and run again than I got unauthorized error.

Is there a solution to make authorization process to have priority? Without required permission, the API must return "user is not authorized...", even if the input is full of error.

Is there a solution?

Reasons:
  • Blacklisted phrase (1): Is there a solution
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: Secler developer