2017-02-24 65 views

回答

1

我相信您可以通過閱讀Authorization in a web app using Azure AD application roles & role claims Azure-AD示例的How to run the sample as a single-tenant app部分來了解如何設置其他聲明(例如角色聲明)的示例。這需要編輯Azure-AD應用程序清單以添加應用程序角色。然後分配不同的角色給目錄中的不同用戶

+0

嗯,我不認爲在角色聲明中說「自定義」是有效的。至於字面上的**自定義**聲明 - 這是不可能實現的。 – user7567234

1

據我所知,Azure AD目前不支持發佈自定義聲明。

作爲解決方法,我們可以使用Azure AD Graph添加directory schema extensions。在此之後,我們可以使用Azure的AD圖來獲取數據擴展並添加自定義的要求時,安全令牌驗證像下面的代碼:

app.UseOpenIdConnectAuthentication(
    new OpenIdConnectAuthenticationOptions 
    { 
     ClientId = clientId, 
     Authority = authority, 
     PostLogoutRedirectUri = postLogoutRedirectUri, 
     Notifications = new OpenIdConnectAuthenticationNotifications 
     { 
      AuthenticationFailed = context => 
      { 
       context.HandleResponse(); 
       context.Response.Redirect("/Error?message=" + context.Exception.Message); 
       return Task.FromResult(0); 
      } 
      , 
      SecurityTokenValidated = context => 
      { 
       //you can use the Azure AD Graph to read the custom data extension here and add it to the claims 
       context.AuthenticationTicket.Identity.AddClaim(new System.Security.Claims.Claim("AddByMe", "test")); 
       return Task.FromResult(0); 
      } 
    }); 

此外,如果你有關於Azure的任何想法或意見,你可以從here提交。

+0

好吧,我明白,這可能是我的選擇。但我正在尋找的是在azure AD發佈的jwt令牌中包含deviceID聲明。我在這裏找到了一些有關它的信息: https://msdn.microsoft.com/en-us/windows/hardware/commercialize/customize/mdm/azure-active-directory-integration-with-mdm 根據主題:「使用協議語義」和「使用Azure AD的管理協議」 這僅適用於BYOD訂閱還是我誤解了這一點? @FeiXue感謝您的答案btw :) – John

+0

@John感謝您與我們分享答案。我建議你撰寫一篇文章並將其標記爲答案,以便其他具有相同問題的人可以很容易地重新整理它,並可以從中受益:) –

+0

對不起,也許我在上面的問題中有點不清楚。我沒有找到解決方案,我只是簡單地要求引用上面的鏈接:我是否能夠將設備ID包含在不記名令牌的聲明中,還是隻能在BYOD訂閱中使用?最好的祝願。 :) – John