Roles & Permissions in Azure Active Directory for Application Use - azure

I'm relatively new to Azure Active Directory & trying to understand some best practices or guidelines for administering custom roles & permissions for application use.
For instance, I might want to create a Role of "Technician" & they have permissions such as "firmware.upgrade" or "product.view" to be enforced within application & endpoints.
Would "Technician" actually be an Azure AD Group then & I could assign custom roles "firmware.upgrade" & "product.view" to that group? Can it even work that way?
Also, I could consider Application Roles, but "Technician" (and others) would be a role used across several applications. So I wasn't sure if an Application Role makes sense to use.

You're on the right track.
You will start by creating app roles like "firmware.upgrade" and "product.view" in your Azure AD application. Please note that these roles are specific to your Azure AD application only and the logic for what a user with these roles can do will be defined in your application code.
Next you would create an Azure AD groups (e.g. "Technicians", "Users" etc.) and start assigning other users in your Azure AD in these groups.
Then you would assign these groups app roles. For example, you can choose to assign "firmware.upgrade" and "product.view" roles to "Technicians" group while "product.view" role to "Users" group.
When a user authenticates/authorizes against Azure AD for your application, the claims will include all the app roles assigned to them either directly or through group membership. Based on the app roles in the claim, you would then grant access to certain parts of your application to these users.
Please do note that while groups are for entire Azure AD, your application roles are specific to an application only. For each application in your Azure AD, you will need to create new application roles.

I can see the other answer is not but an automated answer.. Anyways Azure Active Directory B2C (Business-to-Consumer) does not have the concept of groups and thus group-based assignments of enterprise applications is not possible.
Instead of using groups, you can use custom attributes to assign roles and permissions to B2C users. Custom attributes are user-specific properties that you can define and store on a user's identity. You can use these attributes to store information such as the user's role or permissions.
You can then use these custom attributes to control access to your applications. For example, you can configure your application to check the value of a custom attribute, such as "role", to determine whether a user has the necessary permissions to access a specific feature or resource.
But you also, you need to handle the management and assignment of these attributes yourself, whereas with groups, Azure AD handles that for you.

Related

How to restrict deletion of security group in Azure?

Is there any Azure policy can be in place which will restict users so that they Can NOT delete any of the Security groups in Azure? even if they can PIM up below roles:
User Admin
Privileged auth admin
Application admin
Conditional access admin
Privillaged role admin
Identity Governance admin
Security Admin
Thanks.
• For now, no such policy can be applied that prevents security group deletion in Azure. But there is a way through which you can prevent security group deletion through assigned Azure AD roles in Azure. For this purpose, you will have to ensure that you don’t assign Azure AD built-in roles like ‘User Administrator, Privileged authentication administrator, etc.’ directly with the default assigned permissions to these roles to any of the user or a group of users in your Azure AD tenant.
Then, create custom Azure AD roles according to your specific requirement with the required permissions only as described in the documentation link as below: -
https://learn.microsoft.com/en-us/azure/role-based-access-control/custom-roles
https://learn.microsoft.com/en-us/azure/active-directory/roles/custom-create
• Once the custom required Azure PIM specific roles are created, then assign these PIM roles to the required users or a group of users as you deem correct. But do ensure that ‘microsoft.directory/groups/delete’ and ‘microsoft.directory/accessReviews/definitions.groups/delete’ permissions are not assigned to any of these custom PIM roles created and also bar from assigning the built-in Azure AD roles under Privileged Identity Management to any of the users, as these permissions only give the assigned role/user the rights to delete a security group.
In this way, you can restrict the users of PIM and other custom roles or default roles, maybe for that matter, to prevent deleting any security groups in Azure.
Short answer is no, there is no such built-in policy. You would have to rely on custom RBAC roles instead of the built-in roles.
For example, you want to use the NotAction and add this action to it microsoft.directory/groups/delete.
https://learn.microsoft.com/en-us/azure/active-directory/roles/permissions-reference
You can try to use Azure Resources Lock which will protect your resources from accidental deletion, no matter the user permissions. Check this link for more details about Azure resource locks:
https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/lock-resources?tabs=json

How to prevent outside tenants from giving themselves an app's roles in Azure AD?

I am working on an application, and its registration in Azure AD must allow Accounts in any organizational directory to sign-in. We built this with the thought that we could manage the roles for the app within Azure, so we made a few roles. The roles would also be only assignable and used by employees within our organization.
The whole time we thought that these roles can only be assigned within the Azure AD of the organization that owns the app's registration. We now found that when a user from another tenant signs into our app, they can find the app in their Azure's Enterprise Applications and just assign themselves roles. This means that they'd be able to view data that was never meant to be accessible to them. We don't want any other organization to have access to assigning these roles.
So is there any way to disable other tenants' ability to assign themselves a role in their Azure's Enterprise Application? I just want them to be able to log into the app, not give themselves any roles.
Is this even the appropriate way to achieve what we want? If not, what would be the proper way to do this?
At least I am not aware of any mechanism that will prevent admins from other tenants to assign roles to user (it works by design).
If you want to use the application roles only within your tenant, I would suggest that you use the tenantid that is also part of the claims when you doing authorization within your application...

Azure service principal - API permissions vs. AD Role

I have an application that needs to create AD groups and update their memberships via Graph API. I'll be using a service principal to do so.
I'm trying to understand the difference between:
assigning the service principal to an Azure AD role (for example, "User Administrator": https://learn.microsoft.com/en-us/azure/active-directory/roles/delegate-by-task#groups)
adding API permissions to the service principal (for example, Microsoft Graph API's "Group.ReadWrite.All": https://learn.microsoft.com/en-us/azure/active-directory/roles/delegate-by-task#groups)
What are the differences here? Do they both effectively give the same permissions?
A built-in role is just a collection of permissions so your answer can be yes. If you grant the same permissions in as a built-in role then you will get the same effective permissions. The "User Administrator" role has the following permissions:
https://learn.microsoft.com/en-us/azure/active-directory/roles/permissions-reference#user-administrator
We created built-in roles to make it easier for users to quickly get role based access control in place. If built-in roles don't meet your needs, you can always create a custom role.
I'm mulling over the same question - which approach is better, MS Graph permissions or built-in roles. I'm leaning towards the built in roles for easier visibility and the potential to assign the permissions to groups.
Unless things have changed very recently you can only create AAD custom roles for a subset of "Application Administrator" permissions - not for any permissions.

User and organization management in Azure AD and Azure B2C

After a lot of research I am still confused about using Azure AD. Here is what I want to achieve.
We maintain users in following order in SQL Server
Organization
Team
User
There can be multiple organizations and a user can be belong to multiple organizations but his/her role will be different like Agent or Team leader or Team manager.
I want to move away from this structure and create the same in Azure AD and authenticate users via Identity provider. How to maintain same sort of structure in Azure AD?
I am looking for an solution with minimal code changes. Any thoughts on this??
You can use Groups in AAD to achieve something similar.
Currently, the following scenarios DO support nested groups:
The concept (you can add groups as members of other groups)
Group membership claims (when an app is configured to receive group membership claims in the token, nested groups the signed-in user is a member of are included)
Conditional access (when scoping a conditional access policy to a group)
Restricting access to self-serve password reset
Restricting which users can do Azure AD Join and device registration
The following scenarios DO NOT supported nested groups:
App role assignment (assigning groups to an app is supported, but groups nested within the directly assigned group will not have access), both for access and for provisioning
Group-based licensing (assigning a license automatically to all members of a group)
Office 365 Groups
See the product feedback page and add your suggestions if you need something more complex than what AAD currently supports.

Azure Active Directory - Assign to group

Is it possible to assign an application (as an Application or Service Principal) to a group programatically, via the graph client or API? (Including the app user credentials needed to allow access of the members of the group to the app)
I searched everywhere and couldn't find documentation for it.
Thanks
No, 'Applications' in Azure AD are used to segment authorization and settings within Azure AD. It creates a trust between Azure AD and your application. The Application is not a User.
Users are Azure AD entities that have identity and can be authorized to access resources (like an Application). Users can be added to groups. See the below link for the Azure AD graph API documentation:
https://msdn.microsoft.com/Library/Azure/Ad/Graph/api/groups-operations#AddGroupMembers
And the documentation on what a user entity looks like:
https://msdn.microsoft.com/Library/Azure/Ad/Graph/api/entity-and-complex-type-reference#UserEntity
Thanks for the answer emseetea, but we do have a little more than that.
Back to the original question - can you programmatically "assign a group to an application". The answer is yes, using appRoleAssignments on the service principal. The service principal represents an application instance, that typically gets provisioned as part of a consent grant. On this tenant specific app instance (service principal) you can attach tenant specific permissions and policy. Permissions get created as part of consent, but you can also programmatically assign an application role (defined by the application) to a user or group. If no application role is assigned, then you can make a "default" assignment. You can find a little more on this topic here http://blogs.msdn.com/b/aadgraphteam/archive/2014/12/12/announcing-the-new-version-of-graph-api-api-version-1-5.aspx which describes a little about this with some sample REST API calls.
This same operation is also possible through the client library. You can take a look at https://github.com/Azure-Samples/active-directory-dotnet-graphapi-console. Look at the section titled "#region Assign Direct Permission". This shows how to assign an app role to a user. You can do the same thing on a group too. If your app doesn't specify any app roles, set the appRoleAssignment.Id to a zero GUID.
Hope this helps,

Resources