1

I am currently trying to set up windows authentication for a graphql endpoint. Currently all my requests are being blocked, even schemas are not getting loaded. I have followed the traditional way of setting up the windows authentication in ASP.NetCore . Further, I tried to add a REST endpoint to my application and verified that I am able to retrieve the authenticated user information. Can someone please help me figure out what I could be doing wrong?

public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(IISDefaults.AuthenticationScheme);

            services.AddAuthorization();

            services.AddControllers();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo { Title = "GraphQLAPIWithAuth", Version = "v1" });
            });

            services.AddGraphQLServer()
                    .AddAuthorization()
                    .AddQueryType<Query>();
        }

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "GraphQLAPIWithAuth v1"));
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapGraphQL();
            });

            //app.UseEndpoints(endpoints =>
            //{
            //    endpoints.MapGraphQL();
            //});
        }

0 Answers0