2017-09-14 70 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