c# - 将 login_hint 与 OpenID 结合使用

标签 c# azure-active-directory openid openid-connect

我正在尝试将 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);
     }
}

关于c# - 将 login_hint 与 OpenID 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48544880/

相关文章:

c# - 如何根据旋转缩放图像

openid - 是否有 OpenID 消费者的 node.js 实现?

c# - 在同一应用程序项目上对 API 使用 Bearer Token 身份验证,对 MVC 使用 OpenId 身份验证

带有 openid 的 Facebook

c# - MVC4 : How to show Group of checkboxes with header checkbox?

c# - 在 C# 中合并两个 .CS 文件以生成一个新类

Azure AD 企业应用程序 - 回复 URL?

azure - 在返回的 JWT 中找不到 approles

azure - 如何获取Azure Active Directory应用程序的权限?

C# - 两个日期之间的差异?