将login_hint与OpenID一起使用

jrn*_*jrn 1 c# openid azure-active-directory openid-connect

我正在尝试向login_hintAzure AD身份验证的OpenID登录请求中添加。

添加login_hint为属性对我来说不起作用:

var properties = new AuthenticationProperties();

properties.RedirectUri = "someCallbackUrl";

properties.Dictionary.Add("login_hint ", "SomeUsername");

AuthenticationManager.Challenge(properties, OpenIdConnectAuthenticationDefaults.AuthenticationType);
Run Code Online (Sandbox Code Playgroud)

手动向查询字符串...&login_hint=SomeUsername中添加login_hint 至少向我证明了这种功能的存在:-)

我知道,如果要使用GoogleOAuth2AuthenticationProvider它,就必须像这样覆盖自身。我尝试采用的方法是否需要类似的东西?

jrn*_*jrn 5

原来,我必须将添加RedirectToIdentityProviderapp.UseOpenIdConnectAuthentication

Notifications = new OpenIdConnectAuthenticationNotifications()
{
    RedirectToIdentityProvider = (context) =>
    {
        string login_hint = context.OwinContext.Authentication.AuthenticationResponseChallenge.Properties.Dictionary["login_hint"];
        context.ProtocolMessage.LoginHint = login_hint;
        return Task.FromResult(0);
     }
}
Run Code Online (Sandbox Code Playgroud)