1

IdentityServer3 및 External Providers에서 이상한 동작이 나타납니다. 나는 누군가가 내가 놓친 명백한 것을 지적 할 수 있기를 바라고있다.IdentityServer3, Azure Active Directory 외부 공급자, 메시지 = '작업이 반환되었습니다.'System.Web.Http.Results.Unauthorized ''

요약

먼저 외부 로그인 요청은 요청 만 기록을 통해 볼 수 아래의 오류를 반환하고 결과를 기다리지 브라우저를 설정합니다. 브라우저에서 요청을 취소하고 즉시 버튼을 다시 누르면 의도 한대로 작동하고 브라우저가 외부 로그인 화면으로 전송됩니다.


나는 푸른 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' 

브라우저는 계속해서 로컬 호스트에서 무기한 대기합니다. 요청을 중지하고 즉시 단추를 다시 누르면 모든 것이 의도 한대로 작동합니다.

+0

오류가 라인 (330) 직전 context.Authentication에서 IDSrv3 AuthenticatioinController.cs에서 일어나는 것으로 보이는 OpenIdAuthenticationOptions에 관리자를 추가

 var manager = new SyncConfigurationManager(new ConfigurationManager < OpenIdConnectConfiguration > (Settings.AADAuthority + "/.well-known/openid-configuration")); 

OpenIdConnectConfiguration

을 대체

https://github.com/IdentityServer/IdentityServer3/blob/master/source/Host.Configuration/Extensions/SyncConfigurationManager.cs

.Challenget (authProp, provider)이 메서드는 Unauthorized()를 즉시 반환합니다. –

답변

0

Katana OIDC MW의 교착 상태 버그와 관련된 문제가 나타납니다. 해결 방법은 사용자 지정 IConfigurationManager를 만들고 시작할 때 메타 데이터를 수동으로 가져 오는 것입니다. Thinktecture에서 제안한 것과 유사합니다. 그런 다음



    var aad = new OpenIdConnectAuthenticationOptions 
       { 
        AuthenticationType = "AzureAd", 
        Caption = "Marquis Azure AD", 
        SignInAsAuthenticationType = signInAsType, 
        PostLogoutRedirectUri = Settings.LogoutRedirect, 
        Authority = Settings.AADAuthority, 
        ClientId = Settings.AADClientId, 
        RedirectUri = Settings.AADRedirectUrl, 
        ConfigurationManager = manager 
       }; 

1

OpenIdConnectAuthenticationOptions을 기반으로 작성된 코드는 정확합니다. 나는 또한 IdentityServer3 푸른와 AD 계정을 로그인 아래 코드를 사용하고 그리고 그것은 나를 위해 잘 작동합니다

public class Startup 
{ 
    public void Configuration(IAppBuilder app) 
    { 
     Log.Logger = new LoggerConfiguration() 
      .MinimumLevel.Debug() 
      .WriteTo.Trace() 
      .CreateLogger(); 

     var users = new List<InMemoryUser>() 
     { 
      new InMemoryUser 
      { 
       Username="Jack", Password="Jack", 
       Claims= new List<Claim> 
       { 
        new Claim("name","Jack"), 
        new Claim("email","[email protected]"), 
        new Claim("role","Admin"), 
       } 
      } 
     }; 

     var clients = new Client[] 
     { 
      new Client 
      { 
       ClientId="mvc", 
       ClientName="MVC Demo Client", 
       Flow=Flows.Implicit, 
       RedirectUris=new List<string> 
       { 
        "http://localhost:9000", 
        "http://localhost:1409/" 
       }, 
       AllowedScopes=new List<string> 
       { 
        "openid","email","profile","roles" 
       } 
      } 
     }; 

     var scopes = new Scope[] 
      { 
       StandardScopes.OpenId, 
       StandardScopes.ProfileAlwaysInclude, 
       StandardScopes.EmailAlwaysInclude, 
       new Scope 
       { 
        Name="roles", 
        Claims=new List<ScopeClaim> 
        { 
         new ScopeClaim("role") 
        }, 
        Type=ScopeType.Identity 
       } 
      }; 

     var factory = new IdentityServerServiceFactory(); 
     factory.UseInMemoryClients(clients); 
     factory.UseInMemoryScopes(scopes); 
     factory.UseInMemoryUsers(users); 

     var cert = LoadCertificate(); 

     app.UseIdentityServer(new IdentityServerOptions 
     { 
      SiteName = "NDC Demo", 
      SigningCertificate = cert, 
      Factory = factory, 
      AuthenticationOptions = new AuthenticationOptions 
      { 
       IdentityProviders = ConfigureAdditionalIdentityProviders, 
       EnableAutoCallbackForFederatedSignout = true 
      } 
     }); 
    } 

    public static void ConfigureAdditionalIdentityProviders(IAppBuilder app, string signInAsType) 
    { 
     app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions 
     { 
      AuthenticationType = "aad", 
      Caption = "Azure AD", 
      SignInAsAuthenticationType = signInAsType, 

      Authority = "https://login.microsoftonline.com/04e14a2c-0e9b-42f8-8b22-3c4a2f1d8800", 
      ClientId = "eca61fd9-f491-4f03-a622-90837bbc1711", 
      RedirectUri = "https://localhost:44333/core/aadcb", 
     }); 
    } 

    static X509Certificate2 LoadCertificate() 
    { 
     var baseFolder = AppDomain.CurrentDomain.BaseDirectory; 
     string certificatePath = $"{baseFolder}\\Certificates\\mycompanyname.pfx"; 
     return new X509Certificate2(certificatePath, "", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet); 
    } 
} 

그런 다음 우리는 아래의 요청에 IdentityServer3와 상호 작용할 수 :

https://localhost:44333/connect/authorize?response_type=id_token&client_id=mvc&redirect_uri=http://localhost:9000&scope=openid+email+profile+roles&nonce=123

하세요 도움이되는지 여부를 알려주세요.

+0

login.windows.net/[tenantID]를 사용한다는 점을 제외하고는 현재 구성되지 않은 구성이 없습니다.나가 말한대로, 그것은 작동한다, 그러나 나가 첫번째 요구를 취소하는 경우에. 나는 IDSrv3가 문제의 뿌리라고 생각합니다. 노력에 감사드립니다. –