2017-08-21 25 views
2

Azureマルチファクタ認証で認証され、Graph APIとPower BIにアクセスするAzure Webアプリケーションがあります。 Azure App登録に必要な権限を設定しました。 Redisキャッシュを使用して、NaiveSessionCacheにトークンの詳細を格納しています。ユーザーがログインしようとすると、いくつかのユーザーのために、我々は次のエラーを取得しているAzure Webアプリケーションへのログインは「AADSTS50079:ユーザーはマルチファクタ認証を使用する必要があります。」

AADSTS50079:ユーザーがマルチファクタを使用する必要があります:ユーザーが

「AADSTS50079多要素認証を使用する必要があります相関ID:3f12d4b1-d401-4d99-be30-36bf972d74a5 \ r \ nTimestamp:2017-08-21 14:21:59Z "、"認証ID:63c180a9-6951-4a8a-96ca-e1ff38fc4400 \ r \ "parsedStack":[{"assembly": "Microsoft.IdentityModel.Clients.ActiveDirectory、Version = 3.13.9.1126、Culture =ニュートラル、PublicKeyToken = 31bf3856ad364e35"、 "メソッド": "Microsoft.IdentityModel.Clients.ActiveDirectory.AdalHttpClient + d__21 1.MoveNext","level":0,"line":0},{"assembly":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":1,"line":0},{"assembly":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":2,"line":0},{"assembly":"Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.13.9.1126, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.IdentityModel.Clients.ActiveDirectory.AdalHttpClient+<GetResponseAsync>d__20 「メソッド」:「System.Runti」、「System.Runti」、「System.Runti」、「System.Runti」、「System.Runti」、「System.Runti」、「System.Runti」、 "mscorlib、バージョン= 4.0.0.0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089"、 "メソッド": "mscorlib、バージョン= 4.0.0.0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089"、 " 5、 "line":0}、{"assembly": "Microsoft.IdentityModel.Clients.ActiveDirectory、Version = 3.13.9.1126、Culture = neutral、PublicKeyToken =" System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification " "レベル":6、 "ライン":0}、{"アセンブリ": "mscorlib、バージョン= 4.0.0.0、"} "メソッド": "Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase + d__67.MoveNext" "class" = "中"、PublicKeyToken = b77a5c561934e089 "、"メソッド ":" System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess "、"レベル ":7、"行 ":0}、{"アセンブリ ":" mscorlib、バージョン= 4.0。 "class" = "8"、 "line":0}、{"assembly": "Microsoft.IdentityModel.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification" Clients.ActiveDirectory、Version = 3.13.9.1126、 "レベル":9、 "行":0}、{"アセンブリ": "mscorlib、" = "mscorlib"、 " "level":10、 "line":0}、{"assembly": "version"、 "class = 4.0.0.0、Culture = neutral、PublicKeyToken = b77a5c561934e089"、 "method": "System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess" "レベル":11、 "行":0}、{"アセンブリ"、 "mscorlib、Version = 4.0.0.0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089"、 "メソッド": "System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification" : "mscorlib、Version = 4.0.0.0、Culture = neutral、PublicKeyToken = b77a5c561934e089"、 "method": "System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd"、 "level":12、 "line":0}、{ Microsoft.IdentityModel.Clients.ActiveDirectory、Version = 3.13.9.1126、Culture =ニュートラル、PublicKeyToken = 31bf3856ad364e35 "、"メソッド ":" Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase + d__55.MoveNext "、" level " :13、 "line":0}、{"assembly" "レベル":14、 "行":0}、{"mscorlib、Version = 4.0.0.0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089"、 "メソッド": "System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess"アセンブリ ":" mscorlib、Version = 4.0.0.0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089 "、"メソッド ":" System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification "、" level ":15、" line ":0} {"assembly": "Microsoft.IdentityModel.Clients.ActiveDirectory、Version = 3.13.9.1126、Culture =ニュートラル、PublicKeyToken = 31bf3856ad364e35"、 "メソッド": "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext + d__48.MoveNext"、 " 16、 "line":0}、{"assembly": "mscorlib、バージョン= 4.0.0.0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089"、 "メソッド": "System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess" 、 "level":17、 "line":0}、{"assembly": "mscorlib、Version = 4.0.0.0、Culture = neutral、PublicKeyToken = b77a5c561934e089"、 "method": "System.Runtime.CompilerServices.TaskAwaiter。 HandleNonSuccessAndDebuggerNotification "、 "method": "Microsoft.IdentityModel"、Microsoft.IdentityModel、Microsoft.IdentityModel、Microsoft.IdentityModel、Microsoft.IdentityModel、Microsoft Knowledge Baseに含まれている情報は、 "mscorlib、バージョン= 4.0.0.0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089"、 "メソッド"、 "メソッド"、 "メソッド"、 "メソッド" ":" System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess "、" level ":20、" line ":0}、{"アセンブリ ":" mscorlib、バージョン= 4.0.0。0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089 "、"メソッド ":" System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification "、" level ":21、" line ":0}、{アセンブリ": "アセンブリ、バージョン= 「レベル」:22、「行」:68、「ファイル名」:「App_Start \ Startup」のいずれかを選択すると、 .Auth.cs "}]、" タイプ ":" Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException」、 "ID": "52129856"

ここでは、認証コードをrecieveingに使用startup.csファイルである

public void ConfigureAuth(IAppBuilder app){ try {

  app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); 

      app.UseCookieAuthentication(new CookieAuthenticationOptions()); 

      app.UseOpenIdConnectAuthentication(
       new OpenIdConnectAuthenticationOptions 
       { 
        ClientId = clientId, 
        Authority = Authority, 
        PostLogoutRedirectUri = postLogoutRedirectUri, 
        AuthenticationMode = AuthenticationMode.Active, 
        Notifications = new OpenIdConnectAuthenticationNotifications() 
        { 
         // If there is a code in the OpenID Connect response, redeem it for an access token and refresh token, and store those away. 
         AuthorizationCodeReceived = async (context) => 
         { 
          try { 
           IConnectionString _connectionString = new RedisConnectionString(ConfigurationReader.RedisCacheConfig as string); 

           ICacheManager cacheManager = new RedisCacheManager(_connectionString); 
           var code = context.Code; 
           ClientCredential credential = new ClientCredential(clientId, appKey); 
           string signedInUserID = context.AuthenticationTicket.Identity.FindFirst(Constants.OBJECT_IDENTIFIER).Value; 

           AuthenticationContext authContext = new AuthenticationContext(Authority, new NaiveSessionCache(signedInUserID)); 
           //Getting Power BI token 
           AuthenticationResult result = await authContext.AcquireTokenByAuthorizationCodeAsync(
            code, new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path)), credential, pbiResourceID); 

           //Getting Graph token 
           AuthenticationResult graphResult = await authContext.AcquireTokenByAuthorizationCodeAsync(
            code, new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path)), credential, graphResourceId); 
           UserTokenCache cache = new UserTokenCache 
           { 
            GraphAccessToken = graphResult.AccessToken, 
            PBIAccessToken = result.AccessToken, 
            PBITokenExpires = result.ExpiresOn, 
            GraphTokenExpires = graphResult.ExpiresOn 
           }; 

           string encryptedCache = CryptographyUtility.Encrypt(JsonConvert.SerializeObject(cache)); 

           cacheManager.set(signedInUserID, encryptedCache); 
          } catch (Exception ex) 
          { 
           ExceptionLogger.LogInApplicationInsight(ex); 
          } 
         }, 
         AuthenticationFailed = async (context) => 
         { 
          ExceptionLogger.LogInApplicationInsight(context.Exception); 
          await Task.FromResult(0); 
         } 

        } 
       }); 
     } 
     catch (SystemException sx) 
     { 
      ExceptionLogger.LogInApplicationInsight(sx); 
     } 
     catch (ApplicationException ax) 
     { 
      ExceptionLogger.LogInApplicationInsight(ax); 
     } 
     catch (Exception ex) 
     { 
      ExceptionLogger.LogInApplicationInsight(ex); 
     } 
    } 

ここに何か不足していますか?これにより、トークンを取得できないユーザはほとんどありません。電力BIレポートがロードされていません。

答えて

1

このエラーは、ユーザがマルチファクタ認証を登録または実行する必要があることを示しています。

500079:MFA

500076に登録します。ユーザーは、それが同じプロトコルですこれらの両方を解決するには

MFA

を実行する必要があります。あなたのアプリは、失敗したリソースを指定する対話的な要求を実行する必要があります。

MFAを必要とするMicrosoft Graphのトーク​​ンを取得しようとしています。すでに別のリソースに対してリフレッシュトークンを付与している場合(またはリソースを要求せずにサインインした場合)、Azure ADにMicrosoft Graphの新しいトークンを問い合わせることができます。この要求は/tokenエンドポイント上にあり、POSTであり、MFAを実行することはできません。あなたのアプリはこのエラーをキャッチして、resource=https://graph.microsoft.comを要求するか、失敗したリソースを要求する新しいリクエスト(AcquireTokenまたはOWIN OpenId Connect Challengeを使用)を実行する必要があります。

+0

上記のコードスニペットでは、パワーBIとグラフトークンの両方に対してTokensを順番に取得しようとしています。あなたが言ったように、パワーBIトークンは正常に生成されていますが、グラフトークンを取得すると例外が発生しています。また、AcquireTokenを使用してグラフトークンを取得するには、UserAssertionが必要です。どのトークンを使用してUserAssertionを作成しますか? –

+0

[ここにある](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-conditional-access-developer)何が起こっているのかについてのより多くの概念情報。実際にこれをコーディングする際のヘルプについては、同様のケースを扱います(この例のミドルウェアハンドル(Azure AD v2.0エンドポイント用に構築されているため、v1.0のスコープではなくリソースを使用します)(https: //github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect-v2/blob/master/WebApp/Utils/OAuth2CodeRedeemerMiddleware.cs)... –

+0

...最も役立つセクションは[ GenerateAuthorizationUrl](https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect-v2/blob/master/WebApp/Utils/OAuth2CodeRedeemerMiddleware.cs#L186)、ミドルウェアが新しいリクエストを作成します –

関連する問題