Reputation: 16413
I currently have a Xamarin Forms app correctly logging in and using Microsoft Azure AD for authentication before accessing a web api that is also configured in Azure.
Now I want to add role based authorization like I used to do using IdentityServer 4.0. So within my webapi I put this on my controller:
[Authorize(Roles = "SOMEDOMAIN\\ADGroup")]
So now I'm trying to follow documentation on the web but people aren't being descriptive enough. I have 1 question but let me first explain my setup.
Under "Required Permissions
I edited the Manifest
Under "Required Permissions
I edited the Manifest
1) Within each app above, do I need to enable Read Directory Data
for the Windows Azure Active Directory
permission? If not, which one needs it?
Upvotes: 1
Views: 303
Reputation: 156
In the Application Manifest, the "groupMembershipClaims": "SecurityGroup" should add the groups
claim to the JWT. Then you just need the ObjectId in Azure AD for the Security Group(s) you are trying to target, discussed in detail here. The group information is part of the id_token
, Per the documentation here,
Provides object IDs that represent the subject's group memberships. These values are unique (see Object ID) and can be safely used for managing access, such as enforcing authorization to access a resource. The groups included in the groups claim are configured on a per-application basis, through the "groupMembershipClaims" property of the application manifest. A value of null will exclude all groups, a value of "SecurityGroup" will include only Active Directory Security Group memberships, and a value of "All" will include both Security Groups and Office 365 Distribution Lists.
Also, read there is a very thorough Wiki on the Github repo for the ADAL library here.
Also, here some good resources on that groups
claim and the last one is sample solution:
https://azure.microsoft.com/en-gb/resources/samples/active-directory-dotnet-webapp-groupclaims/
Upvotes: 0