我正在使用带有sitefinity客户端的身份服务器4。我正在构造一个指向安全api的url,并在查询字符串中传递自定义值。(例如:http://localhost:60876/Sitefinity?code=CfDJ8GIUky)。我试图在重定向到ID4之前捕获代码的值,但是该值消失了。下面是我的通知设置:
Notifications = new OpenIdConnectAuthenticationNotifications()
{
RedirectToIdentityProvider = n =>
{
// trying to intercept the request to catch the query string value!
return Task.FromResult(0);
}
}
任何帮助都将不胜感激。谢谢
发布于 2018-07-26 07:33:34
经过两天的研究,我得出了以下结论
1-我创建了一个可公开访问的端点来捕获查询字符串并保留它
public ActionResult Index(string code)
{
return new ChallengeResult("OpenIdConnect", "http://localhost:60876", code);
}
2- ChallengeResult接受代码并将其添加到AuthenticationProperties
var properties = new AuthenticationProperties() { RedirectUri = RedirectUri };
if (Code != null)
{
properties.Dictionary["AccessCode"] = Code;
}
context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
3-在中间件RedirectToIdentityProvider中
Notifications = new OpenIdConnectAuthenticationNotifications()
{
SecurityTokenValidated = context => SecurityTokenValidatedInternal(context),
RedirectToIdentityProvider = context =>
{
var code = context.OwinContext.Authentication.AuthenticationResponseChallenge.Properties.Dictionary["AccessCode"];
context.ProtocolMessage.SetParameter("Code", code);
return Task.FromResult(0);
}
}
但是,字典条目并不存在。我是不是遗漏了什么?
https://stackoverflow.com/questions/51509858
复制相似问题