authorization
authorization copied to clipboard
UNAUTHENTICATED error code
I just need to know how to get the error code UNAUTHENTICATED because when I use .AuthorizeWith I am getting a VALIDATION_ERROR.
here is a bit of startup.cs
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer();
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.TryAddSingleton<IAuthorizationEvaluator, AuthorizationEvaluator>();
services.AddTransient<IValidationRule, AuthorizationValidationRule>();
services.AddTransient((c) =>{
var authSettings = new AuthorizationSettings();
authSettings.AddPolicy("authenticated",p=>p.RequireClaim(ClaimTypes.Name));
return authSettings;
);
app.UseAuthentication();
app.UseAuthorization();
app.UseGraphQL<MySchema>("/api");
These authorization rules for the GraphQL Schema are done through a GraphQL Validation rule, so you will only get validation errors. You will not get unauthenticated error codes as this framework is designed to work within the GraphQL context.
Relates to https://github.com/graphql-dotnet/server/pull/480 and may be fixed in v4.
@EbrahimMajdey see readme.md from #128. I expect to publish v4 soon.