Azure Scope is a powerful tool for managing access and permissions in your organization. It's essential to follow best practices to ensure your Azure Scope is secure and efficient.
To start, it's crucial to understand the concept of scope in Azure. A scope is a container that holds a collection of resources, and it's used to define access control and management boundaries.
Here are some key best practices to keep in mind when working with Azure Scope authorization and security:
Limit the number of scopes in your organization to reduce complexity and improve manageability. This can be achieved by creating a hierarchy of scopes that reflect your organization's structure.
Always use role-based access control (RBAC) to manage access to resources within a scope. This approach ensures that users have the necessary permissions to perform specific tasks without over-privileging them.
By following these best practices, you can ensure that your Azure Scope is secure, efficient, and easy to manage.
Azure Role Definition
Azure role definition is a collection of permissions that specifies the actions that can be performed. It's typically just called a role, and it can be high-level, like owner, or specific, like virtual machine reader.
A role definition lists the actions that can be performed, such as read, write, and delete. It can also list the actions that are excluded from allowed actions or actions related to underlying data.
The following table describes what the role properties mean:
Azure includes several built-in roles that you can use. For example, the Virtual Machine Contributor role allows a user to create and manage virtual machines. If the built-in roles don't meet the specific needs of your organization, you can create your own Azure custom roles.
A role definition can be displayed using Azure PowerShell, Azure CLI, or the Azure REST API. The display will show the properties of the role definition, including the name, ID, actions, and not actions.
Privileged administrator roles are roles that grant privileged administrator access, such as the ability to manage Azure resources or assign roles to other users. If a built-in or custom role includes any of the following actions, it is considered privileged:
- Create and manage resources of all types.
- Delete resources of all types.
- Write resources of all types.
- Delete a deny assignment at the specified scope.
- Create a deny assignment at the specified scope.
- Delete a role assignment at the specified scope.
- Create a role assignment at the specified scope.
- Delete the specified custom role definition.
- Create or update a custom role definition with specified permissions and assignable scopes.
Azure Role Format
Azure role format is crucial to understand when working with Azure scope. Azure role format is a string that has a specific format: {Company}.{ProviderName}/{resourceType}/{action}. This format is used to specify the type of actions you can perform on a resource type.
The {action} portion of an action string specifies the type of actions you can perform on a resource type. For example, you can see the following substrings in {action}: *, read, write, action, and delete.
The wildcard character (*) grants access to all actions that match the string. This means that if you specify *, you'll have access to all actions for a particular resource type. The read action enables read actions (GET), while the write action enables write actions (PUT or PATCH). The action substring enables custom actions like restart virtual machines (POST), and the delete action enables delete actions (DELETE).
Here's a summary of the action substrings:
Azure Role Scopes
A role scope is the set of resources that the access applies to. You can specify a scope at four levels: management group, subscription, resource group, or resource. These scopes are structured in a parent-child relationship, allowing you to assign roles at any of these levels of scope.
To limit the actions allowed, you can further define a scope when assigning a role. This is helpful if you want to make someone a Website Contributor, but only for one resource group. By specifying a scope, you can grant access to specific resources while keeping others off-limits.
Here are some examples of valid assignable scopes:
Data Example
In Azure Role Scopes, data actions play a crucial role in controlling access to resources. Data actions are used to grant access to data within an object, such as reading blobs or messages within a storage account.
To understand data actions, let's consider an example. Alice has been assigned the Owner role at the subscription scope, which has a wildcard (*) action. This means her permissions inherit down, enabling her to perform all control plane actions. However, she can't perform data plane actions without taking additional steps, such as retrieving storage access keys to access blobs.
A key concept in Azure Role Scoping is the NotDataActions permission, which specifies the data plane actions that are subtracted or excluded from the allowed DataActions. This permission is useful when you want to define a set of allowed data actions by subtracting from DataActions that have a wildcard (*).
Here's a table illustrating how NotDataActions work:
By using NotDataActions, you can create a set of allowed data actions by excluding specific actions from the DataActions wildcard (*). This is particularly useful when you want to grant access to specific data actions while preventing access to others.
In summary, data actions are a crucial part of Azure Role Scoping, enabling you to control access to data within resources. By understanding data actions and using NotDataActions, you can create a secure and granular access control model for your Azure resources.
RBAC Works
Azure Role-Based Access Control (RBAC) is a powerful tool that helps you manage access to your Azure resources. It's based on roles, which are collections of permissions that define what actions can be performed on a resource.
To understand how RBAC works, let's break it down into three key elements: security principal, role definition, and scope. The security principal is the user or service principal that's trying to access the resource, the role definition is the set of permissions that define what actions can be performed, and the scope is the resource or group of resources that the role is being applied to.
Here's an example of how RBAC determines if a user has access to a resource:
1. A user (or service principal) acquires a token for Azure Resource Manager. The token includes the user's group memberships (including transitive group memberships).
2. The user makes a REST API call to Azure Resource Manager with the token attached.
3. Azure Resource Manager retrieves all the role assignments and deny assignments that apply to the resource upon which the action is being taken.
4. If a deny assignment applies, access is blocked. Otherwise, evaluation continues.
5. Azure Resource Manager narrows the role assignments that apply to this user or their group and determines what roles the user has for this resource.
6. Azure Resource Manager determines if the action in the API call is included in the roles the user has for this resource. If the roles include Actions that have a wildcard (*), the effective permissions are computed by subtracting the NotActions from the allowed Actions.
Here's a step-by-step summary of the RBAC evaluation process:
This process ensures that only authorized users have access to the resources they need, and that access is granted based on the roles they've been assigned. By using RBAC, you can create a secure and scalable Azure environment that meets the needs of your organization.
Azure Role Assignment
Azure Role Assignment is a crucial aspect of Azure Scope, allowing you to control access to your resources and services. You can define custom roles with specific permissions, making it easier to manage access and ensure that only authorized users can perform certain actions.
AssignableScopes determine where a role definition can be assigned, and you can specify management groups, subscriptions, or resource groups. This means you can make a custom role available for assignment in only the scopes that require it.
Custom roles can have multiple AssignableScopes, but built-in roles have AssignableScopes set to the root scope, making them available for assignment in all scopes.
Here are some valid examples of AssignableScopes:
It's worth noting that creating a custom role with a resource instance in AssignableScopes is not recommended, as it can potentially exhaust your available custom roles.
In addition to AssignableScopes, you can also use Azure Policy to evaluate compliance and determine which resources to include or exclude. This is done through the use of assignment scopes, which can include or exclude specific resources or resource hierarchies.
Azure RBAC uses an additive model, so your effective permissions are the sum of your role assignments. If you have multiple overlapping role assignments, the sum of the permissions will determine your effective permissions.
Azure Role Security
Azure role security is a crucial aspect of managing access to your resources. Privileged administrator roles grant access to manage Azure resources and assign roles to other users.
To determine if a role is privileged, look for actions like * (create and manage resources of all types), */delete (delete resources of all types), or */write (write resources of all types). These actions are considered privileged and require careful management.
You can define app roles in the app registration for your API, specifying the allowed member types. For example, the app roles ApiAdmin and ApiUser can only be assigned to users and groups, while the app role Document.Read.Updates can only be assigned to applications.
To assign app roles to a user, go to the Enterprise Application page for your API and assign the desired roles. This can also be done for groups of users, making it a convenient way to manage access.
Here are the key actions that are considered privileged:
Security Principal
A security principal is an object that represents a user, group, service principal, or managed identity requesting access to Azure resources.
You can assign a role to any of these security principals, as seen in Example 3, where app roles are assigned to Azure AD users on the Enterprise Application page for an API.
A security principal can be a user, group, service principal, or managed identity, and each one has its own specific use case. For instance, a user might need access to certain resources, while a group might need access to multiple resources.
You can define app roles in the app registration for your API, specifying the allowed member types, as shown in Example 2. This is crucial in determining which security principals can be assigned to which roles.
In an app-only access scenario, the application calls the API under its own identity, and the API should check if the assigned app roles match the requested action, as described in Example 1.
Not vs Deny Assignments
NotActions are a convenient way to subtract specific actions from a wildcard (*) action. They serve a different purpose than deny assignments, which block users from performing specific actions even if a role assignment grants them access.
Deny assignments are more restrictive and require careful consideration, as they can block users from performing actions that they need to perform their job. NotActions, on the other hand, provide a way to limit access to specific actions while still allowing users to perform other actions.
Here's a key difference between NotActions and deny assignments:
NotActions are a useful tool for fine-tuning access control, but deny assignments should be used with caution and only when necessary.
Frequently Asked Questions
What is the difference between role and scope?
Role-based access controls user actions within an application, while scopes define what external applications can access via an exposed API, determining the level of access and data visibility
What is the difference between permission and scope?
Scopes define broad categories of actions, while permissions control specific operations within those categories, providing a layered approach to access control
Sources
- https://learn.microsoft.com/en-us/azure/role-based-access-control/role-definitions
- https://learn.microsoft.com/en-us/azure/governance/policy/concepts/scope
- https://cloudfirstapproach.com/understanding-oauth-scopes-and-roles-in-azure-ad/
- https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal
- https://learn.microsoft.com/en-us/azure/role-based-access-control/overview
Featured Images: pexels.com