какая-то конфигурация неверна в конфигурации IndentityServer4? - PullRequest
0 голосов
/ 24 мая 2019

Страница согласия продолжает перенаправлять обратно на страницу входа в Indentityserver4 asp.net core 2.2

Я пробовал разные конфигурации на Identityservice и клиенте MVC, но напрасно

Я загрузил код наgithub ниже url https://github.com/Dheerajmentor/IdentityServer4-Problem

Запуск клиента MVC

public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            services.AddAuthentication(options => {
                options.DefaultScheme = "Cookies";
                options.DefaultChallengeScheme = "oidc";
            })
             .AddCookie("Cookie")
             .AddOpenIdConnect("oidc",options=> {
                 options.Authority = "https://localhost:44398/";
                 options.RequireHttpsMetadata = false;
                 options.ClientId = "mvc";
                 options.SaveTokens = true;
             });
        }

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseAuthentication();
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
    }
}

Запуск сервера идентификации

public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddIdentityServer()
                .AddInMemoryClients(APPConfigure.GetClients())
                .AddInMemoryIdentityResources(APPConfigure.GetIdentityResource())
                .AddInMemoryApiResources(APPConfigure.GetAPIResources())
                .AddTestUsers(APPConfigure.GetUsers())
                .AddDeveloperSigningCredential();


        }

Я ожидал, что после успешного входа он будет перенаправлен на согласие.

Ответы [ 2 ]

0 голосов
/ 25 мая 2019

Попробуйте поставить app.UseHttpsRedirection ();в остальной части app.UseHttpsRedirection () гарантирует, что вы всегда будете перенаправлены на https, а в разработке вы запускаете по http.

if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
                app.UseHttpsRedirection()
            }
            app.UseAuthentication();
0 голосов
/ 25 мая 2019

Я только что столкнулся с подобной проблемой.Я работаю в режиме отладки, используя https.Удаление app.UseHttpsRedirection ();работал на меня.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...