.net core IdentityServer4重定向到包含客户端信息的登录操作

.net core IdentityServer4重定向到包含客户端信息的登录操作,.net-core,identityserver4,asp.net-core-identity,.net Core,Identityserver4,Asp.net Core Identity,有没有一种方法可以管理重定向到登录页面,并将客户机参数保留在查询字符串中 我在Identity server上创建了一个忘记密码页面,并插入重定向到登录页面 <a asp-action="Login" asp-controller="Account">Go Log in</a> 登录 如果我尝试转到此页面,然后单击此按钮返回登录页面。当我登录时,重定向url不起作用,我仍在identity server上。不确定这是否有助于您,但这是我的答案 我将隐式流与客户端凭据一

有没有一种方法可以管理重定向到登录页面,并将客户机参数保留在查询字符串中

我在Identity server上创建了一个忘记密码页面,并插入重定向到登录页面

<a asp-action="Login" asp-controller="Account">Go Log in</a>
登录

如果我尝试转到此页面,然后单击此按钮返回登录页面。当我登录时,重定向url不起作用,我仍在identity server上。

不确定这是否有助于您,但这是我的答案

我将隐式流与客户端凭据一起使用,并在客户端上进行以下设置

Startup.cs

services.AddAuthentication(option => {
                option.DefaultScheme = "Cookies";
                option.DefaultChallengeScheme = "oidc";

            }).AddCookie("Cookies")
            .AddOpenIdConnect("oidc", options => {
                options.SignInScheme = "Cookies";
                options.Authority = Configuration["Authentication:Authority"];
                options.RequireHttpsMetadata = false;
                options.ClientId = Configuration["Authentication:ClientId"];
                options.SaveTokens = true;
                options.GetClaimsFromUserInfoEndpoint = true;
                options.ClientSecret = "secret";
                options.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost;
            });
在控制器上,您试图保护的对象具有[Authorize]属性

在我的客户端应用程序中,我有这个

        [Authorize]
        public IActionResult performlogin()
        {
            return RedirectToAction("index", "home");
        }
这会将您重定向到identity server进行登录

我登录identity server的方法签名如下

public async Task<IActionResult> Login(string returnUrl){
 // do login code and redirect
 // returnUrl should have the redirect path with query string.
}
公共异步任务登录(字符串返回URL){
//执行登录代码和重定向
//returnUrl应该具有带有查询字符串的重定向路径。
}
成功登录后,重定向


我希望这对你有帮助。我不确定这是否对你有帮助,但这是我的答案

我将隐式流与客户端凭据一起使用,并在客户端上进行以下设置

Startup.cs

services.AddAuthentication(option => {
                option.DefaultScheme = "Cookies";
                option.DefaultChallengeScheme = "oidc";

            }).AddCookie("Cookies")
            .AddOpenIdConnect("oidc", options => {
                options.SignInScheme = "Cookies";
                options.Authority = Configuration["Authentication:Authority"];
                options.RequireHttpsMetadata = false;
                options.ClientId = Configuration["Authentication:ClientId"];
                options.SaveTokens = true;
                options.GetClaimsFromUserInfoEndpoint = true;
                options.ClientSecret = "secret";
                options.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost;
            });
在控制器上,您试图保护的对象具有[Authorize]属性

在我的客户端应用程序中,我有这个

        [Authorize]
        public IActionResult performlogin()
        {
            return RedirectToAction("index", "home");
        }
这会将您重定向到identity server进行登录

我登录identity server的方法签名如下

public async Task<IActionResult> Login(string returnUrl){
 // do login code and redirect
 // returnUrl should have the redirect path with query string.
}
公共异步任务登录(字符串返回URL){
//执行登录代码和重定向
//returnUrl应该具有带有查询字符串的重定向路径。
}
成功登录后,重定向

我希望这有助于

查看我答案中的参考信息。查看我答案中的参考信息。