将login_hint与OpenID一起使用 [英] Use login_hint with OpenID
问题描述
我正在尝试将login_hint
添加到用于Azure AD身份验证的OpenID登录请求中.
I am trying to add the login_hint
to the OpenID sign-in request for Azure AD authentication.
将login_hint
添加为属性对我来说不起作用:
It is not working for me, to add login_hint
as a property:
var properties = new AuthenticationProperties();
properties.RedirectUri = "someCallbackUrl";
properties.Dictionary.Add("login_hint ", "SomeUsername");
AuthenticationManager.Challenge(properties, OpenIdConnectAuthenticationDefaults.AuthenticationType);
手动将login_hint添加到查询字符串...&login_hint=SomeUsername
至少向我证明了这种功能的存在:-)
Adding the login_hint manually to the query string ...&login_hint=SomeUsername
at least proves to me, that such functionality exists :-)
我了解,如果我要使用GoogleOAuth2AuthenticationProvider
,则必须像那样覆盖自身.我尝试采用的方法是否需要类似的东西?
I understand that if I were to use GoogleOAuth2AuthenticationProvider
that I would have to override itself like so. Is something similar needed for the approach that I am trying to take?
推荐答案
原来,我不得不将RedirectToIdentityProvider
添加到app.UseOpenIdConnectAuthentication
:
It turns out that I had to add the RedirectToIdentityProvider
to app.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);
}
}
这篇关于将login_hint与OpenID一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!