2017-09-28 3 views
0

私はローカルログインフォームを使用して、外部プロバイダ(Azure Active Directory)に対してユーザーの資格情報を認証しようとしています。IdentityServer4 - 外部プロバイダでローカルログインフォームを使用できますが、往復はできませんか?

クライアントごとにローカルログインを有効にすることができます。それは本当に設定されているように、私はローカルのログインフォームを取得しますが、私はまだその外部プロバイダのミドルウェアを起動する方法については不明です。 IDトークンを受け取るためにクライアントの資格情報を外部プロバイダに送信する方法はありますか?現在のコードはMicrosoftログインにリダイレクトされます。私のアイデンティティサーバー、そしてクライアントアプリケーションに戻ります。私は、ユーザーがアイデンティティサーバーを介してログインすることを望んでいるが、実際にAzureに対して本当に認証していることは知らない。

は、ここに私のスタートアップだ:

 var schemeName = "Azure-AD"; 
     var dataProtectionProvibder = app.ApplicationServices.GetRequiredService<IDataProtectionProvider>(); 
     var distributedCache = app.ApplicationServices.GetRequiredService<IDistributedCache>(); 
     var dataProtector = dataProtectionProvider.CreateProtector(
      typeof(OpenIdConnectMiddleware).FullName, 
      typeof(string).FullName, schemeName, 
      "v1"); 
     var dataFormat = new CachedPropertiesDataFormat(distributedCache, dataProtector); 

     /// 
     /// Azure AD Configuration 
     /// 
     var clientId = Configuration["AzureActiveDirectory:ClientId"]; 
     var tenantId = Configuration["AzureActiveDirectory:TenantId"]; 
     Redirect = Configuration["AzureActiveDirectory:TenantId"]; 

     app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
     { 
      AuthenticationScheme = schemeName, 
      DisplayName = "Azure-AD", 
      SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme, 
      ClientId = clientId, 
      Authority = $"https://login.microsoftonline.com/{tenantId}", 
      ResponseType = OpenIdConnectResponseType.IdToken, 
      StateDataFormat = dataFormat, 
     }); 

     app.UseIdentity(); 
     app.UseStaticFiles(); 
     app.UseMvcWithDefaultRoute(); 

これはログインです。私の意見で

[HttpGet] 
public async Task<IActionResult> ExternalLogin(string provider, string returnUrl) 
{ 
    var context = this.HttpContext.Authentication; 
    List<AuthenticationDescription> schemes = context.GetAuthenticationSchemes().ToList(); 

    returnUrl = Url.Action("ExternalLoginCallback", new { returnUrl = returnUrl }); 

    // start challenge and roundtrip the return URL 
    var props = new AuthenticationProperties 
    { 
     RedirectUri = returnUrl, 
     Items = { { "scheme", provider } } 
    }; 

    //await HttpContext.Authentication.ChallengeAsync(provider, props); 

    return new ChallengeResult(provider, props);   
} 

答えて

0

、我々は直接セキュリティ実装.ANDでもAzureのADは、グラント・リソース所有者のパスワードの資格情報をサポートして、それだけで利用可能です認証のためのAzure ADに他のIdpのから直接ユーザ名/パスワードを渡すべきではありませんネイティブクライアント。私はあなたが通常の方法を保ち、それらを混ぜないことをお勧めします。

+0

よろしくお願いいたします。私は多くを考え出した。 –

関連する問題