小编Ali*_*sei的帖子

Owin,在身份验证请求中传递自定义查询参数

我们有自己的OpenID Connect Provider.我们希望使用Owin中间件在身份验证请求中传递自定义查询参数.我们无法找到使用Microsoft.Owin.Security.OpenIdConnect程序集实现此方法的方法.甚至我们也找不到如何向Authentication Request添加标准请求参数(例如" login_hint parameter").

例如,Google有" login_hint "和" hd "参数(https://developers.google.com/accounts/docs/OAuth2Login#sendauthrequest),我们希望拥有几乎相同的参数.但我们甚至找不到如何使用Owin将这些参数发送给Google.试过这段代码:

var googleOptions = new GoogleOAuth2AuthenticationOptions()
{
    ClientId = "...",
    ClientSecret = "...",
};
app.UseGoogleAuthentication(googleOptions);

...

public ActionResult ExternalLogin(string provider)
{
    var ctx = Request.GetOwinContext();
    var properties = new AuthenticationProperties();
    properties.Dictionary.Add("login_hint ", "myemail@gmail.com");
    properties.Dictionary.Add("hd", "hd");
    ctx.Authentication.Challenge(properties, provider);
    return new HttpUnauthorizedResult();
}
Run Code Online (Sandbox Code Playgroud)

但是生成身份验证请求网址时将不使用" login_hint "和" hd "参数.

非常感谢任何帮助解决这个问题.

c# asp.net-mvc owin katana openid-connect

15
推荐指数
1
解决办法
6764
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

katana ×1

openid-connect ×1

owin ×1