使Identity Server 4将查询参数传递给登录控制器 [英] Make Identity Server 4 pass a query parameter to the login controller

查看:63
本文介绍了使Identity Server 4将查询参数传递给登录控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我去授权控制器时(在Identity Server 4中实现):

When I go to authorize controller(implemented in Identity Server 4):

(*)abc.com/authorize?par1=val1&par2=val2

我被重定向到:

(**)abc.com/login?ReturnUrl=abc.com/abc.com%2Fauthorize%3Fpar1%3Dval1%26par2%3Dval2"

人们可以注意到ReturnUrl等于(*),但只是经过html编码. 我想将par2值作为第二个参数添加到(**)url示例中:

One can notice that ReturnUrl equals the (*) but just being html encoded. I would like to add par2 value as a second parameter to the (**) url example:

abc.com/login?ReturnUrl=abc.com/abc.com%2Fauthorize%3Fpar1%3Dval1%26par2%3Dval2&par2=val2"

如何配置IdentityServer来实现这一目标?

How to configure IdentityServer to achieve that?

推荐答案

IdentityServer是经过认证的OpenId Connect协议实现,它将您的(*)请求作为标准

IdentityServer is a certified OpenId Connect protocol implementation, and it handles your (*) request as a standard Authorization request, which has predefined structure.

仅有两个不受规范限制的参数是state,它由客户端使用,应按原样发送回去;以及acr_values,其专门用于向服务器发送其他参数.

The only two parameters with no limitation by the spec are the state which is used by clients and should be sent back with response as it is, and acr_values which is specially aimed for sending additional parameters to the server.

您可以通过以下方式出于您的目的使用acr_values:&acr_values=par2:val2,然后在

You can involve acr_values for your purposes the following way: &acr_values=par2:val2 and then in BuildLoginViewModelAsync(string returnUrl) method of the AccountController you can access them as context?.AcrValues. You can extend LoginViewModel to bring the value to the layout.

这篇关于使Identity Server 4将查询参数传递给登录控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆