Introducing a new way to review your PRs.

Read the announcement

floci-io / floci-az

Light, fluffy, and always free - Local Azure Emulator

View on GitHub

27 documents · Updated Nov 23, 2026

docs / azure-authorization-rbac

Azure authorization and RBAC

Azure authorization and role-based access control (RBAC) provide the local Microsoft.Authorization control-plane surface for built-in role definitions and role assignments. The emulator stores and returns RBAC state for Azure client workflows, but it does not use role assignments to allow or deny other requests.

Microsoft.Authorization control plane

The authorization surface handles the role resources within the shared Microsoft.Authorization namespace. Role definitions describe permissions. Role assignments connect a role to a principal at a scope. Policy resources use the same namespace but remain on the separate Policy service path described in Azure Policy Service.

The surface accepts extension-resource paths at these scopes:

  • Tenant root
  • Management group
  • Subscription
  • Resource group
  • Resource

The scope before the last providers/Microsoft.Authorization segment determines where the role resource belongs. The request keeps its scope casing in returned IDs and assignment properties, while comparisons use case-insensitive scope keys.

References: src/…/AuthorizationArmSurface.java• L15-59 src/…/RbacPath.java• L7-20 src/…/RbacPath.java• L57-129 src/…/RbacHandler.java• L119-145

Role definition catalog

The role definition catalog exposes Azure built-in roles as read-only ARM resources. It is based on the bundled Azure role list, so clients can look up common roles such as Reader, Contributor, Owner, AcrPull, and data-access roles by GUID or display name.

Each definition carries its Azure role name, description, role type, assignable scopes, and control-plane and data-plane permission lists. Role definitions are listed only when their assignable scopes include the requested scope. Name filters are case-insensitive, and type filters can select BuiltInRole or another recorded role type. Custom role definition writes and deletes are not supported.

Role IDs use the subscription form when read inside a subscription. Tenant-root and management-group reads use the provider-level form. Permission conditions appear for API versions from 2022-05-01-preview; role creation and update dates are returned as null because the catalog does not provide them.

References: src/…/RoleDefinitionCatalog.java• L15-26 src/…/RoleDefinitionCatalog.java• L35-60 src/…/RbacHandler.java• L163-267 src/…/role-definitions.json• L1-10

Role assignment lifecycle

Role assignments are stored ARM resources that bind a principal ID to a known built-in role at the request scope. The lifecycle supports create or replace, get, list, and delete. The response preserves the submitted roleDefinitionId and includes all standard assignment properties, with missing values represented as null.

When principalType is absent, the service resolves a known user, group, service principal, or user-assigned identity from the local directory and identity stores. Unknown principals are accepted. A bearer token can supply the createdBy and updatedBy object IDs.

The assignment name must be a GUID. A repeated grant for the same principal, role, and scope under another name returns 409 RoleAssignmentExists. Reusing a name for a different principal or scope returns 400 RoleAssignmentUpdateNotPermitted. An unknown role returns 400 RoleDefinitionDoesNotExist.

The assignment flow connects the request path, role catalog, principal data, and durable assignment state.

flowchart LR
    A[Role assignment request] --> B[Parse scope and GUID name]
    B --> C[Resolve built-in role]
    C --> D[Validate scope resource when strict checks apply]
    D --> E[Resolve principal type when possible]
    E --> F[Check assignment conflicts]
    F --> G[Store ARM assignment]
    G --> H[Return assignment response]

References: src/…/RbacHandler.java• L269-343 src/…/RbacHandler.java• L345-447 src/…/RoleAssignmentStore.java• L18-80 compatibility-tests/…/rbac.bats• L19-60

Assignment storage and scope queries

Assignments use the authorization storage service and are keyed by lowercased ARM ID. The storage mode is therefore controlled by the global storage configuration. Persistent modes keep assignments across restarts. Reset clears them, and deleting a resource group also removes assignments at the group and its child-resource scopes.

Assignment lists reflect the Azure scope hierarchy. Without a filter, a request returns assignments at, above, and below the requested scope. atScope() limits the result to the requested scope and its ancestors. principalId eq '...' and assignedTo('...') select one principal across that same hierarchy; assignedTo does not expand group membership. The hierarchy follows resource, resource-group, subscription, management-group, and tenant-root relationships.

Subscription ownership comes from the directory. Management-group ancestry comes from the management-group hierarchy for that subscription's tenant. Tenant-root and management-group scopes carry tenant context internally because their resource IDs do not name a tenant.

References: src/…/RoleAssignmentStore.java• L18-26 src/…/RoleAssignmentStore.java• L48-85 src/…/RbacHandler.java• L450-535 src/…/ManagementGroupStore.java• L17-22 src/…/AzureDirectory.java• L27-41

Authorization modes and validation

The authorization service is enabled by default through FLOCI_AZ_SERVICES_AUTHORIZATION_ENABLED. Disabling it removes this RBAC handler from the active service path. Enabling it still means storage and response compatibility only; the emulator does not evaluate assignments as authorization rules.

Parity settings control selected Azure refusals. The default compat mode is permissive. parity: strict enables strict checks, and parity-overrides can enable or disable each check independently.

CheckStrict behaviorConfiguration
Assignment nameReject a non-GUID name with 400 InvalidResourceNamestrict-names
Resource scopeReject an assignment for a missing served resource with 404 ResourceNotFoundstrict-resource-groups
Unknown resource typeAccept the assignment when the emulator cannot check that typeNo separate RBAC switch
Principal existenceAccept unknown principals in all modesNo parity switch
Custom role definition writesReturn 501 NotImplementedNo parity switch

The resource-scope check reads the target through its own ARM handler. It can reject a missing resource when the type is served locally. An unsupported resource type cannot be checked, so the assignment is accepted. This validation is separate from tenant and scope resolution: a known subscription maps to its owning tenant, while a caller token supplies tenant context for tenant-root or management-group operations.

References: src/…/RbacHandler.java• L109-117 src/…/RbacHandler.java• L394-420 src/…/RbacHandler.java• L537-547 src/…/EmulatorConfig.java• L71-79 src/…/EmulatorConfig.java• L121-145 src/…/application.yml• L92-127 src/…/application.yml• L372-381

Tenant and scope validation

Tenant and scope validation keeps role data within the local directory and management-group model. A subscription scope is associated with the tenant that owns the subscription. A management-group or tenant-root assignment is associated with the caller tenant because that scope ID alone does not identify a tenant.

The service preserves this tenant association during updates. A caller from another tenant cannot move a tenant-bound assignment by reusing its ID. Assignment listings also qualify tenant-root and management-group scopes with tenant context, so equal-looking management-group paths from different tenants remain separate.

Scope ancestry determines which assignments a list can see. A resource inherits from its resource group and subscription. The subscription inherits from its management group and its ancestors, then from the tenant root. A subscription without an explicit management-group placement belongs to its tenant root group.

References: src/…/RbacHandler.java• L345-386 src/…/RbacHandler.java• L492-547 src/…/ManagementGroupStore.java• L176-180 src/…/AzureDirectory.java• L120-140

Change checklist

When these files or sections are changed, remember to consider these:

  • If role definition data or API-version shaping changes, keep GUID lookup, assignable-scope filtering, role ID forms, permission conditions, and role-name matching aligned.
  • If assignment properties or conflict rules change, keep create, re-PUT, list, get, delete, and CLI or Terraform response shapes consistent.
  • If tenant or management-group hierarchy rules change, keep assignment qualification, inherited list results, principal lookup, and cross-tenant update checks aligned.
  • If storage behavior changes, preserve lowercased assignment identity, restart behavior, reset behavior, and resource-group cascade deletion.
  • If parity defaults change, keep the service configuration, name validation, missing-resource check, and documented permissive behavior aligned.
  • If the Microsoft.Authorization route changes, keep role paths separate from Policy paths and from provider-specific extension resources.

Important failure modes

TriggerConsequenceGuard
A role assignment names an unknown role GUIDThe request returns 400 RoleDefinitionDoesNotExist and no assignment is storedResolve the role from the built-in catalog first
The same principal, role, and scope are submitted under another assignment nameThe request returns 409 RoleAssignmentExistsReuse the existing assignment ID
An existing assignment name is reused for another principal or scopeThe request returns 400 RoleAssignmentUpdateNotPermittedCreate a new GUID for a distinct grant
Strict resource-group parity is enabled and a served target resource is missingThe assignment returns 404 ResourceNotFoundCreate the target resource or disable the strict override
A role definition write or delete targets a custom roleThe request returns 501 NotImplementedUse a bundled built-in role
A tenant-bound assignment is re-PUT from another tenantThe request is rejected instead of moving the assignmentUse the tenant that owns the original assignment
RBAC is disabled while a client expects the authorization handlerThe role path is not served by the RBAC control planeEnable FLOCI_AZ_SERVICES_AUTHORIZATION_ENABLED

Key files

FileWhy to read it
src/…/RbacHandler.javaDefines role definition reads, assignment lifecycle, filters, conflict rules, principal resolution, and tenant-aware scope behavior
src/…/AuthorizationArmSurface.javaDefines the Microsoft.Authorization role resource types and assignment name rule
src/…/RbacPath.javaDefines extension-resource path parsing and supported scope kinds
src/…/RoleAssignmentStore.javaDefines assignment storage identity, persistence boundary, reset, and resource-group cleanup
src/…/RoleDefinitionCatalog.javaDefines the built-in role catalog loaded from the bundled Azure role list
src/…/role-definitions.jsonProvides the role names, GUIDs, scopes, and permission data returned by the catalog
src/…/ManagementGroupStore.javaDefines tenant-specific management-group ancestry used by RBAC scope queries
src/…/AzureDirectory.javaDefines tenant and subscription ownership used for scope and principal resolution
src/…/application.ymlShows authorization enablement, storage defaults, parity modes, and tenant-scoping settings
docs/azure-platform-services.mdPlaces RBAC beside the emulator's other platform control-plane services
docs/azure-policy-service.mdExplains the separate Policy resources that share the Microsoft.Authorization namespace
docs/azure-policy-insights.mdExplains compliance views that are separate from RBAC assignment storage
docs/azure-resource-graph.mdExplains the resource query view and its current authorization-resource boundary
docs/azure-signalr-service.mdProvides a related platform-service reference for the sibling SignalR surface