将 login_hint 与 OpenID 结合使用
Use login_hint with OpenID
我正在尝试将 login_hint
添加到用于 Azure AD 身份验证的 OpenID 登录请求。
我不适合添加 login_hint
作为 属性:
var properties = new AuthenticationProperties();
properties.RedirectUri = "someCallbackUrl";
properties.Dictionary.Add("login_hint ", "SomeUsername");
AuthenticationManager.Challenge(properties, OpenIdConnectAuthenticationDefaults.AuthenticationType);
手动将 login_hint 添加到查询字符串 ...&login_hint=SomeUsername
至少向我证明了这样的功能存在:-)
我明白,如果我要使用 GoogleOAuth2AuthenticationProvider
,我将不得不自行覆盖 like so。我尝试采用的方法是否需要类似的东西?
事实证明我必须将 RedirectToIdentityProvider
添加到 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
添加到用于 Azure AD 身份验证的 OpenID 登录请求。
我不适合添加 login_hint
作为 属性:
var properties = new AuthenticationProperties();
properties.RedirectUri = "someCallbackUrl";
properties.Dictionary.Add("login_hint ", "SomeUsername");
AuthenticationManager.Challenge(properties, OpenIdConnectAuthenticationDefaults.AuthenticationType);
手动将 login_hint 添加到查询字符串 ...&login_hint=SomeUsername
至少向我证明了这样的功能存在:-)
我明白,如果我要使用 GoogleOAuth2AuthenticationProvider
,我将不得不自行覆盖 like so。我尝试采用的方法是否需要类似的东西?
事实证明我必须将 RedirectToIdentityProvider
添加到 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);
}
}