Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNAUTHENTICATED error code #121

Open
EbrahimMajdey opened this issue Mar 3, 2021 · 3 comments · May be fixed by #128
Open

UNAUTHENTICATED error code #121

EbrahimMajdey opened this issue Mar 3, 2021 · 3 comments · May be fixed by #128
Assignees
Labels
question Further information is requested
Milestone

Comments

@EbrahimMajdey
Copy link

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");
@joemcbride
Copy link
Member

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.

@joemcbride joemcbride added the needs confirmation The problem is most likely resolved and requires verification by the author label Mar 22, 2021
@sungam3r
Copy link
Member

Relates to graphql-dotnet/server#480 and may be fixed in v4.

@sungam3r sungam3r linked a pull request Mar 23, 2021 that will close this issue
@sungam3r
Copy link
Member

@EbrahimMajdey see readme.md from #128. I expect to publish v4 soon.

@sungam3r sungam3r added question Further information is requested and removed needs confirmation The problem is most likely resolved and requires verification by the author labels Mar 23, 2021
@sungam3r sungam3r self-assigned this Mar 23, 2021
@sungam3r sungam3r added this to the 4.0 milestone Mar 23, 2021
@sungam3r sungam3r modified the milestones: 4.0, 4.1 Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants