Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use login_hint with OpenID

I am trying to add the login_hint to the OpenID sign-in request for Azure AD authentication.

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);

Adding the login_hint manually to the query string ...&login_hint=SomeUsername at least proves to me, that such functionality exists :-)

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?

like image 609
jrn Avatar asked Jan 31 '18 14:01

jrn


1 Answers

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);
     }
}
like image 120
jrn Avatar answered Sep 28 '22 01:09

jrn