---
title: Identity, Entra Agent Identities & RBAC Matrix
summary: Reference for Microsoft Entra ID app registrations, Agent Identities for OBO token exchange, and per-service Managed Identity RBAC assignments.
owners:
  - platform-engineering-team
badges:
  - content: Security & IAM
    backgroundColor: purple
    textColor: purple
---

Microsoft Entra ID authenticates users and AI agents across BookWorm, while user-assigned Managed Identities authorize service-to-resource access in Azure without static passwords or connection keys. Frontends maintain user sessions with Better Auth backed by Entra ID, and AI agents exchange user assertions via On-Behalf-Of (OBO) federated credentials.

## Identity, Agent OBO, and RBAC Boundaries

<MermaidFileLoader file="mermaids/004-identity-and-rbac-matrix-diagram-1.mmd" />

## Component & Responsibility

| Component                  | Role                                        | Protocol / Interface            | Persistence / State             | Notes                                                    |
| :------------------------- | :------------------------------------------ | :------------------------------ | :------------------------------ | :------------------------------------------------------- |
| [[service\|oauth-api]]     | Primary user and API identity provider      | OAuth 2.0 / OIDC / JWT Bearer   | External tenant                 | Local dev cert in run mode; federated MI in publish mode |
| **Entra Agent Identities** | Federated OBO agent blueprints & identities | Token Exchange FIC              | External tenant (single-tenant) | Provisioned in publish mode only                         |
| **Frontend Sessions**      | Browser session & OAuth2 callback handling  | Better Auth + Entra ID          | Cookie / session state          | Commerce shares the Storefront session                   |
| **Quartz Dashboard Auth**  | Administrative UI authentication            | OpenID Connect (`/signin-oidc`) | Session cookie                  | Requires Entra ID `admin` app role                       |
| **Managed Identities**     | Passwordless service-to-Azure RBAC          | Azure Workload Identity         | Azure RBAC assignments          | Environment identity holds `AcrPull`                     |

## Configuration & Operational Defaults

### App Roles & OAuth2 Scopes

| Role value      | Display name | Allowed member types  | Description                              |
| :-------------- | :----------- | :-------------------- | :--------------------------------------- |
| `admin`         | Admin        | `User`, `Application` | Manages all aspects of the application   |
| `business_user` | BusinessUser | `User`, `Application` | Manages books and catalog reference data |
| `customer`      | Customer     | `User`, `Application` | Browses and purchases books              |

Each protected .NET API registers read and write scopes (12 total):

| Service                  | Read scope      | Write scope      |
| :----------------------- | :-------------- | :--------------- |
| [[service\|catalog-api]] | `catalog_read`  | `catalog_write`  |
| [[service\|mcp-server]]  | `mcptools_read` | `mcptools_write` |
| [[service\|basket-api]]  | `basket_read`   | `basket_write`   |
| [[service\|order-api]]   | `ordering_read` | `ordering_write` |
| [[service\|chat-api]]    | `chatting_read` | `chatting_write` |
| [[service\|rating-api]]  | `rating_read`   | `rating_write`   |

### Managed Identity RBAC Matrix

| Service                                                                | PostgreSQL                        | Azure Managed Redis | Cosmos DB                      | Azure Storage                 | Microsoft Foundry       | Other                  |
| :--------------------------------------------------------------------- | :-------------------------------- | :------------------ | :----------------------------- | :---------------------------- | :---------------------- | :--------------------- |
| [[service\|catalog-api]]                                               | [[container\|catalog-database]]   | Yes                 | —                              | Storage Blob Data Contributor | Cognitive Services User | —                      |
| [[service\|catalog-ingestion]]                                         | [[container\|catalog-database]]   | —                   | —                              | Storage Blob Data Owner       | Cognitive Services User | —                      |
| [[service\|basket-api]]                                                | —                                 | Yes                 | —                              | —                             | —                       | —                      |
| [[service\|order-api]]                                                 | [[container\|order-database]]     | Yes                 | —                              | —                             | —                       | —                      |
| [[service\|order-orchestration]]                                       | —                                 | —                   | —                              | Storage Blob Data Owner       | —                       | Durable Task Scheduler |
| [[service\|chat-api]]                                                  | —                                 | —                   | —                              | Storage Blob Data Contributor | Cognitive Services User | —                      |
| [[service\|rating-api]]                                                | —                                 | Yes                 | [[container\|rating-database]] | —                             | Cognitive Services User | —                      |
| [[service\|notification-api]]                                          | —                                 | Yes                 | —                              | —                             | —                       | —                      |
| [[service\|scheduler-service]]                                         | [[container\|scheduler-database]] | —                   | —                              | —                             | —                       | —                      |
| [[service\|mcp-server]], Gateway, Frontends, [[service\|presidio-api]] | —                                 | —                   | —                              | —                             | —                       | —                      |
| Environment identity                                                   | —                                 | —                   | —                              | —                             | —                       | `AcrPull` on ACR       |

PostgreSQL assigns each service principal as a Flexible Server administrator. Redis uses the default database access policy. Cosmos DB assigns the built-in Data Contributor role at the account scope.

<AccordionGroup>
	<Accordion title="OAuth2 Redirect URIs & Quartz OIDC">
		| Client | Callback path |
		| :----- | :------------ |
		| **Storefront** | `/api/auth/oauth2/callback/microsoft-entra-id` (via Gateway) |
		| **Backoffice** | `/backoffice/api/auth/oauth2/callback/microsoft-entra-id` (via Gateway) |
		| **Commerce** | — (shares Storefront session) |
		| **Quartz Dashboard** | `/signin-oidc` (via Quartz Dashboard host) |

    	In local run mode, the gateway's local HTTP endpoint is also registered as a redirect URI. Quartz Dashboard uses OpenID Connect against the tenant v2.0 authority and restricts access to the `admin` role.
    </Accordion>
    <Accordion title="Entra Agent Identities & Azure Role GUIDs">
    	Each Federated Identity Credential (FIC) trusts the parent Entra ID service principal (`api://AzureADTokenExchange` audience) and is scoped to the deployment environment.

    	| Identity | Purpose | Assigned workload |
    	| :------- | :------ | :---------------- |
    	| **BookWorm Agent Identity Blueprint** | Parent agent identity blueprint | Platform-wide |
    	| **BookWorm Chat Agent** | OBO token exchange for conversational discovery | [[service\|chat-api]] |
    	| **BookWorm Rating Agent** | OBO token exchange for review intelligence | [[service\|rating-api]] |

    	| Azure built-in role | Role definition GUID | Assigned to |
    	| :------------------ | :------------------- | :---------- |
    	| AcrPull | `7f951dda-4ed3-4680-a7ca-43fe172d538d` | Environment identity |
    	| Cognitive Services User | `a97b65f3-24c7-4388-baec-2e87135dc908` | [[service\|catalog-api]], [[service\|catalog-ingestion]], [[service\|chat-api]], [[service\|rating-api]] |
    	| Storage Blob Data Owner | `b7e6dc6d-f1e8-4753-8033-0f276bb0955b` | [[service\|catalog-ingestion]], [[service\|order-orchestration]] |
    	| Storage Blob Data Contributor | `ba92f5b4-2d11-453d-a403-e96b0029c9fe` | [[service\|catalog-api]], [[service\|chat-api]] |
    </Accordion>
    <Accordion title="Non-Entra Secrets Inventory">
    	| Secret | Consumers | Origin |
    	| :----- | :-------- | :----- |
    	| **HMAC signing key** | [[service\|basket-api]], [[service\|order-api]], [[service\|notification-api]] | Generated (min length 32, alphanumeric) |
    	| **Better Auth secret** | Storefront, Backoffice | Generated (min length 32, alphanumeric) |
    	| **Kafka credentials** | Kafka consumers and producers | External |
    	| **Qdrant Cloud credentials** | [[service\|catalog-api]], [[service\|catalog-ingestion]] | External |
    	| **SMTP password** | [[service\|notification-api]] | External ([[service\|sendgrid-api]]) |
    </Accordion>

</AccordionGroup>

## Guardrails & Constraints

<Admonition type="warning" title="Rotate Non-Entra Secrets Regularly">
	HMAC signing keys, Better Auth secrets, and external provider credentials (Kafka, Qdrant Cloud,
	and SMTP) sit outside Managed Identity coverage. Rotate them per
	[[doc|operational/004-security-hardening-checklist]].
</Admonition>

<Admonition type="info" title="Notification Identity Boundary">
	[[service|notification-api]] has a Managed Identity binding only for Azure Managed Redis. It
	authenticates to Kafka and the SendGrid SMTP relay using external credentials.
</Admonition>

## Related Documentation

- [[doc|platform/001-platform-overview]] — Ingress boundary and Entra ID proxy route.
- [[doc|platform/002-compute-and-container-apps]] — Workloads and their auth configuration.
- [[doc|platform/003-data-ai-and-messaging-resources]] — Resources protected by these role assignments.
- [[doc|operational/003-incident-response-and-runbooks]] — RBAC and On-Behalf-Of (OBO) failure runbooks.

<NodeGraph id="identity-provider" version="1.0.0" type="system" maxHeight="28" />
