IdentityServer3と外部プロバイダで異常な動作が見られました。私は誰かが私が逃した明白な何かを指摘できると思っています。IdentityServer3、Azure Active Directory外部プロバイダ、メッセージ= 'アクションが返されました' System.Web.Http.Results.Unauthorized ''
概要
まず外部ログイン要求をのみ、ロギングを通して見える下のエラーで返され、結果される要求を待っているブラウザを設定します。ブラウザで要求を取り消し、直ちにボタンを再度クリックすると、意図したとおりに動作し、ブラウザは外部ログイン画面に送られます。
私はAzureのActive Directoryを活用し、把握することができるよう私もいくつかの参照とドキュメントに従ってIDSrv3設定した
設定。
var wsFedOptions = new WsFederationPluginOptions(options);
wsFedOptions.Factory.Register(new Registration<IEnumerable<RelyingParty>>(RelyingParties.Get()));
wsFedOptions.Factory.RelyingPartyService = new Registration<IRelyingPartyService>(typeof(InMemoryRelyingPartyService));
app.UseWsFederationPlugin(wsFedOptions);
var aad = new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "AzureAd",
Caption = "Azure AD",
SignInAsAuthenticationType = signInAsType,
PostLogoutRedirectUri = Settings.LogoutRedirect,
Authority = Settings.AADAuthority,
ClientId = Settings.AADClientId,
RedirectUri = Settings.AADRedirectUrl
};
app.UseOpenIdConnectAuthentication(aad);
[ログイン]ビューでは、上記のキャプション(Azure AD)として、[外部ログイン]ボタンが表示されます。このボタンを初めてクリックすると、ブラウザはホストの待機を待っています。
ログに次のエラーがあります。
iisexpress.exe Information: 0 : 2017-04-05 08:28:09.708 -05:00 [Information] External login requested for provider: "AzureAd"
iisexpress.exe Information: 0 : 2017-04-05 08:28:09.714 -05:00 [Information] Triggering challenge for external identity provider
LibLog Information: 0 : [2017-04-05T13:28:09.7176576Z] Level=Info, Kind=End, Category='System.Web.Http.Action', Id=800000ad-0002-fb00-b63f-84710c7967bb, Message='Action returned 'System.Web.Http.Results.UnauthorizedResult'', Operation=ReflectedHttpActionDescriptor.ExecuteAsync
LibLog Information: 0 : [2017-04-05T13:28:09.7206611Z] Level=Info, Kind=End, Category='System.Web.Http.Action', Id=800000ad-0002-fb00-b63f-84710c7967bb, Operation=ApiControllerActionInvoker.InvokeActionAsync, Status=401 (Unauthorized)
LibLog Information: 0 : [2017-04-05T13:28:09.7216630Z] Level=Info, Kind=Begin, Category='System.Web.Http.Filters', Id=800000ad-0002-fb00-b63f-84710c7967bb, Message='Action filter for 'LoginExternal(String signin, String provider)'', Operation=NoCacheAttribute.OnActionExecutedAsync, Status=401 (Unauthorized)
LibLog Information: 0 : [2017-04-05T13:28:09.7226640Z] Level=Info, Kind=End, Category='System.Web.Http.Filters', Id=800000ad-0002-fb00-b63f-84710c7967bb, Operation=NoCacheAttribute.OnActionExecutedAsync, Status=401 (Unauthorized)
LibLog Information: 0 : [2017-04-05T13:28:09.7226640Z] Level=Info, Kind=Begin, Category='System.Web.Http.Filters', Id=800000ad-0002-fb00-b63f-84710c7967bb, Message='Action filter for 'LoginExternal(String signin, String provider)'', Operation=SecurityHeadersAttribute.OnActionExecutedAsync, Status=401 (Unauthorized)
LibLog Information: 0 : [2017-04-05T13:28:09.7236655Z] Level=Info, Kind=End, Category='System.Web.Http.Filters', Id=800000ad-0002-fb00-b63f-84710c7967bb, Operation=SecurityHeadersAttribute.OnActionExecutedAsync, Status=401 (Unauthorized)
LibLog Information: 0 : [2017-04-05T13:28:09.7246669Z] Level=Info, Kind=End, Category='System.Web.Http.Controllers', Id=800000ad-0002-fb00-b63f-84710c7967bb, Operation=AuthenticationController.ExecuteAsync, Status=401 (Unauthorized)
LibLog Information: 0 : [2017-04-05T13:28:09.7251836Z] Level=Info, Kind=End, Category='System.Web.Http.MessageHandlers', Id=800000ad-0002-fb00-b63f-84710c7967bb, Operation=PassiveAuthenticationMessageHandler.SendAsync, Status=401 (Unauthorized)
LibLog Information: 0 : [2017-04-05T13:28:09.7261856Z] Level=Info, Kind=End, Category='System.Web.Http.MessageHandlers', Id=800000ad-0002-fb00-b63f-84710c7967bb, Operation=DependencyScopeHandler.SendAsync, Status=401 (Unauthorized)
LibLog Information: 0 : [2017-04-05T13:28:09.7271879Z] Sending response, Status=401 (Unauthorized), Method=GET, Url=https://localhost:44396/identity/external?provider=AzureAd&signin=2d92dd18a6106c9b029eb8742d4117a1, Id=800000ad-0002-fb00-b63f-84710c7967bb, Message='Content-type='none', content-length=unknown'
ブラウザはローカルホスト上で無期限に待機します。 リクエストを停止して直ちにボタンをクリックすると、すべてが意図どおりに機能します。
エラーがライン330直前context.AuthenticationでIDSrv3 AuthenticatioinController.csで何が起こっているように見えるOpenIdAuthenticationOptionsにマネージャを追加
OpenIdConnectConfiguration
を代入https://github.com/IdentityServer/IdentityServer3/blob/master/source/Host.Configuration/Extensions/SyncConfigurationManager.cs
.Challenget(authProp、provider)このメソッドはすぐにUnauthorized()を返します。 –