2

標準の MVC Auth の例 ( http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and- openid-sign-on ) を使用して、Thinktecture IdentityServer のインスタンス ( https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/Simplest%20OAuth2%20Walkthrough ) への OpenID Connect 認証を使用します。

IdentityServer のスコープに「openid」スコープを追加しました。https://github.com/IdentityServer/IdentityServer3.Samples/blob/master/source/MVC%20Authentication/EmbeddedMvc​​/Startup.csのサンプル コードを使用して、余分な呼び出しを userinfo エンドポイントに追加しました。

認証ミドルウェア チェーンの上位には (MVC Auth の例のように)UseCookieAuthenticationUseExternalSignInCookie.

にブレークポイントを設定すると、OpenIdConnectAuthenticationNotifications.SecurityTokenValidatedすべてのクレームが適切に受信されていることがわかります。したがって、IdentityServer との通信は正しく行われています。

しかし、私がAccountController.ExternalLoginCallback電話に出たとき

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

常に null を返します。

Google OAuth2 でログインすると null になりません。

UseOpenIdConnectAuthenticationCookie 情報を設定する (または設定しない) 方法と、UseCookieAuthenticationそれを抽出する方法に不一致があると思われます。しかし、私はこれを解決する方法がわかりません。

4

2 に答える 2