2017-09-14 72 views
0

我正在使用azure Active Directory來控制使用組成員身份訪問我的Web應用程序。我有2個組(用戶& admin)。在我的應用程序中,我設置了Microsoft圖形的應用程序權限來讀取用戶配置文件並閱讀所有組。Azure中的應用服務插槽上的Microsoft圖形API訪問問題

然後我在我的應用程序中使用圖形API來獲取所有可用組的列表。這在我的本地開發環境中可以正常工作,並且當我以Azure的形式部署到應用程序時,該過程在那裏也可以正常工作。當我在應用程序服務環境中的2'插槽'中上傳和測試時出現問題。我有兩個即時通訊軟件,一個開發版本和一個QA版本。只要我嘗試訪問圖表API中的任何一個我得到這個錯誤

代碼:Authorization_RequestDenied 消息:沒有足夠的權限來完成操作。

當我最初開始開發時,我得到了這個,但設置和授予應用程序權限解決了它。那麼,爲什麼我在其他2個'應用'中獲得這個?我需要這些來測試(我作爲開發人員和QA的測試團隊) 是否有任何其他步驟需要我的開發人員使用qa插槽以相同的方式工作?

**這是我如何訪問圖形API,它在我的主要的應用程序工作正常,但不能在插槽

GraphServiceClient graphClient = new GraphServiceClient(new AzureAuthenticationProvider()); 
Group group = await graphClient.Groups[admin].Request().GetAsync(); 

**更新

的問題是,在運行的應用程序我的插槽。我的Dev & QA插槽在用戶登錄後沒有在ClaimsIdentity對象中有任何組信息。我通過在Claimsidentity對象中記錄信息來檢查此信息,當我在本地運行它並在Azure的主應用程序中運行時,組信息當我在azure qa & dev環境中運行它時,這些組不存在於Claimsidentity對象中。爲什麼會這樣?插槽是否繼承了活動目錄設置,或者它們是否應單獨設置?我很新的天藍色和安全模式,所以任何幫助將不勝感激。

我已經在Azure中重定向URL設置,並且在我的web.config中,我對每個環境使用適用於每個環境的適當重定向的不同轉換。使用OpenID

林**更新2

當我創建的槽,I基於它們(複製)在我的主應用程序。每個插槽是否應該在其web.config文件中有自己的ClientID和密碼?我是否也需要將每個插槽註冊爲活動目錄中的應用程序?目前只是我的主要的應用程序被註冊

下面是我的每個應用程序的權利,你可以看到QA的應用沒有組在蔚藍

Claim type - ver 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn 
Claim type - http://schemas.microsoft.com/identity/claims/tenantid 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier 
Claim type - onprem_sid 
Claim type - nonce 
Claim type - http://schemas.microsoft.com/identity/claims/objectidentifier 
Claim type - name 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname 
Claim type - ipaddr 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname 
Claim type - http://schemas.microsoft.com/claims/authnmethodsreferences 
Claim type - c_hash 
Claim type - aio 
Claim type - exp 
Claim type - nbf 
Claim type - iss 
Claim type - iat 
Claim type - aud 

認證類型

我的QA槽;餅乾

我主要的應用程序在Azure中

Claim type - ver 
Claim type - http://schemas.microsoft.com/identity/claims/tenantid 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name 
Claim type - http://schemas.microsoft.com/identity/claims/objectidentifier 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier 
Claim type - nonce 
Claim type - name 
Claim type - ipaddr 
Claim type - http://schemas.microsoft.com/identity/claims/identityprovider 
Claim type - groups 
Claim type - groups 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname 
Claim type - http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress 
Claim type - c_hash 
Claim type - http://schemas.microsoft.com/claims/authnmethodsreferences 
Claim type - exp 
Claim type - aio 
Claim type - nbf 
Claim type - iss 
Claim type - iat 
Claim type - aud 

認證類型; Cookies

**好吧,我已經嘗試添加QA應用程序到azure活動目錄作爲註冊的應用程序,我有一個clientID和一個祕密,我給它相同的Azure活動目錄和Microsoft圖作爲我的主要應用程序。我已經在我的web.config轉換中包含了祕密&祕密,所以基本上它的設置與我的主應用程序相同,仍然沒有在Claimsidentity中的組信息。這究竟意味着什麼?授予

***另一個更新

權限

的Windows Azure Active Directory的 - 委託權限:讀取所有羣體,閱讀所有用戶全部資料

微軟圖形 - 應用程序的權限:讀取所有用戶完整配置文件,閱讀所有羣組 - 委派權限:讀取所有羣組,讀取所有用戶完整配置文件,登錄並閱讀用戶配置文件

就像一個測試,我也授予活動目錄和微軟圖形的所有權限,它沒有任何區別。

這對我來說現在已經成爲一個嚴重的問題,我無法看到我能做的其他事情,它在我的主應用程序中運行得非常好,但不在'插槽'中是否存在Azure的一個主要缺陷/錯誤?或者我在這裏做了一些根本性的錯誤?

任何人都可以幫我嗎?

+0

人?這是一個巨大的問題,我不能測試任何圍繞安全的功能在azure我的開發&qa版本:-( – proteus

回答

0

要通過Microsoft Graph讀取組,需要Group.Read.All,Group.ReadWrite.All,Directory.Read.AllDirectory.ReadWrite.All

你有什麼權限授予有此問題的應用程序?還請檢查令牌中的scp聲明,以確保已授予正確的權限。您可以從this link

更多細節關於微軟圖表REST權限解碼訪問令牌,請參考以下鏈接:

Microsoft Graph permissions reference

+0

做'插槽'繼承主應用程序的活動目錄設置?這似乎並非如此,是 – proteus

+0

您是如何與Azure Active Directory互動的?使用OpenID OWIN組件或Easy Auth?如果您使用的是OpenID OWIN組件,它取決於您如何配置它,但大多數代碼不需要修改除重定向網址外。如果您使用Easy Auth,則應該爲部署的插槽再次進行配置。 –

+0

Im使用OpenID,剛剛添加了對我的問題的更新 – proteus