2017-08-22 8 views
0

Azure ADを使用して認証を実装しようとしています。アプリケーション設定では、返信URLをhttps://example.com/myapp/login.aspxと設定しています。 私がログインするとhttps://example.comにリダイレクトされ、指定されていないURL https://example.com/myapp/login.aspxAzure Active Directoryの返信URLがルートにリダイレクト

どのように適切なURLでリダイレクトされることを確認できますか?以下はスタートアップのコードです。

public void Configuration(IAppBuilder app) 
{ 
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); 

    app.UseCookieAuthentication(new CookieAuthenticationOptions()); 

    app.UseOpenIdConnectAuthentication(
     new OpenIdConnectAuthenticationOptions 
     { 
      ClientId = ConfigurationManager.AppSettings["owin:ClientId"].ToString(), 
      Authority = "https://login.microsoftonline.com/yz5036e3-2951-4c11-af4d-da019fa6a57d", 
      RedirectUri = ConfigurationManager.AppSettings["RedirectUri"].ToString() 
     }); 
} 

答えて

2

ログインフローをどのようにトリガーしますか?サンプルを追跡し、https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect/blob/master/WebApp-OpenIDConnect-DotNet/Controllers/AccountController.csに示すようにChallengeを呼び出してサインインを開始する場合は、AuthenticationPropertiesのRedirectUriが最終的に(認証後に)着陸するURLを指していることを確認するとよいでしょう。 OIDCオプションのRedirectUriプロパティは、authプロトコルで使用するリダイレクト、認証トークンを受け取るリダイレクト、そしてAuthenticationPropertiesのRedirectUriプロパティはローカルURLですアイデンティティプロバイダとの取引が成功裏に完了した後にリダイレクトされたい牧草地は歴史的な理由から同じ名前です。

0

私の場合、ウェブサイトは仮想ディレクトリ(アプリケーションで変換)の下にありました。ログインURLの場合http://example.com/myapp/login.aspx、それはユーザをhttp://example.comにリダイレクトしていました。 RedirectUriをmyapp/AfterLogin.aspxとして設定すると、それはうまくいきました。

HttpContext.Current.GetOwinContext().Authentication.Challenge(
      new AuthenticationProperties { RedirectUri = "myapp/AfterLogin.aspx", }, 
      OpenIdConnectAuthenticationDefaults.AuthenticationType); 
関連する問題