首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >保留查询字符串

保留查询字符串
EN

Stack Overflow用户
提问于 2018-07-25 10:06:34
回答 1查看 131关注 0票数 1

我正在使用带有sitefinity客户端的身份服务器4。我正在构造一个指向安全api的url,并在查询字符串中传递自定义值。(例如:http://localhost:60876/Sitefinity?code=CfDJ8GIUky)。我试图在重定向到ID4之前捕获代码的值,但是该值消失了。下面是我的通知设置:

代码语言:javascript
复制
Notifications = new OpenIdConnectAuthenticationNotifications()
{
    RedirectToIdentityProvider = n =>
    {
        // trying to intercept the request to catch the query string value!
        return Task.FromResult(0);
    }
}

任何帮助都将不胜感激。谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-07-26 07:33:34

经过两天的研究,我得出了以下结论

1-我创建了一个可公开访问的端点来捕获查询字符串并保留它

代码语言:javascript
复制
public ActionResult Index(string code)
{
    return new ChallengeResult("OpenIdConnect", "http://localhost:60876", code);
}

2- ChallengeResult接受代码并将其添加到AuthenticationProperties

代码语言:javascript
复制
var properties = new AuthenticationProperties() { RedirectUri = RedirectUri };
if (Code != null)
{
    properties.Dictionary["AccessCode"] = Code;
}
context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);

3-在中间件RedirectToIdentityProvider中

代码语言:javascript
复制
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);
    }
}

但是,字典条目并不存在。我是不是遗漏了什么?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51509858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档