When working with Microsoft Entra (formerly Azure Active Directory), you’ll hear terms like App Registration, Tenant, Client ID, Audience, Scopes, Roles, Tokens, OBO flow, and more. If you’re new, it can feel overwhelming.
This guide breaks down every key term and concept, with definitions, examples, and how they connect when you onboard and consume a new API.
🔹 1. Tenant
- Definition: A tenant in Entra ID is your organization’s dedicated, isolated instance of Microsoft Entra.
- Think of it like: Your company’s identity directory.
- Example:
contoso.onmicrosoft.comis a tenant for Contoso Ltd.
🔹 2. App Registration
- Definition: The process of registering an application in Entra to give it an identity and permission to use Microsoft identity platform.
- Why needed: Without registration, Entra doesn’t know about your app.
- What it creates:
- Application (Client) ID – unique identifier for your app
- Directory (Tenant) ID – your organization’s ID
- Types of apps:
- Web API (backend, receives tokens)
- Web App / SPA (frontend, requests tokens)
- Daemon/service (background jobs, uses client credentials)
🔹 3. Client ID
- Definition: A globally unique GUID assigned to your registered app.
- Use: Identifies the app when requesting tokens.
- Example:
12345678-abcd-4321-efgh-9876543210ab.
🔹 4. Tenant ID
- Definition: Unique GUID representing your organization’s Entra tenant.
- Use: Used in token endpoints (
https://login.microsoftonline.com/{tenantId}).
🔹 5. Instance
- Definition: The login endpoint base URL for Entra.
- Example:
https://login.microsoftonline.com/
🔹 6. Audience (aud claim)
- Definition: The intended recipient of the token.
- In practice: The token must have
aud = api://{API_CLIENT_ID}or your custom URI. - If mismatch: API rejects the token (401 Unauthorized).
🔹 7. Application ID URI
- Definition: The unique identifier (URI) that represents your API in Entra.
- Default:
api://{clientId} - Custom:
https://contoso.com/myapi - Use: Appears in tokens as the
aud(audience).
🔹 8. Scopes (Delegated Permissions)
- Definition: A named permission your API exposes that clients can request.
- Delegated means: “Acting on behalf of a user.”
- Stored in:
scpclaim of the token. - Example:
- Scope:
access_as_user - Token claim:
"scp": "access_as_user"
- Scope:
- Use: API checks that the scope is present before granting access.
🔹 9. Roles (Application Permissions)
- Definition: Permissions granted to an application itself (not a user).
- Stored in:
rolesclaim of the token. - Use case: Background services, daemons, or APIs calling other APIs without user context.
🔹 10. Delegated Flow (Authorization Code Flow)
- Definition: User signs in → app gets an authorization code → exchanges for access token.
- When to use: SPAs, web apps.
- Result: Token includes
scpclaim (scopes).
🔹 11. Client Credentials Flow (App-Only)
- Definition: App authenticates with client ID + secret/certificate.
- When to use: Background services / daemons.
- Result: Token includes
rolesclaim.
🔹 12. On-Behalf-Of (OBO) Flow
- Definition: API A receives a user token → exchanges it for a new token → calls API B.
- When to use: Multi-tier architecture (frontend → API → downstream API).
- Token claims: Still delegated (
scppresent).
🔹 13. Tokens
a) ID Token
- Purpose: Proves user identity to the client app.
- Claims: Name, email,
oid(object ID). - NOT for APIs.
b) Access Token
- Purpose: Grants access to an API.
- Claims:
aud,scporroles, expiry. - APIs validate this.
c) Refresh Token
- Purpose: Long-lived; used to get new access tokens silently.
- Where used: Client apps with long sessions.
🔹 14. MSAL (Microsoft Authentication Library)
- Definition: Official library to authenticate and acquire tokens.
- Flavors:
MSAL.NET(C#)MSAL.js(JavaScript/React/Angular)
- Why use: Handles token caching, refresh, OBO, multi-account scenarios.
🔹 15. Microsoft.Identity.Web
- Definition: ASP.NET Core extension library that simplifies validating JWTs issued by Entra.
- Features:
- Easy token validation
- Scope/role validation helpers
- Built-in OBO support
- Example helper:
HttpContext.VerifyUserHasAnyAcceptedScope("access_as_user");
🔹 16. AppSettings.json Config
- Why: Stores Entra settings.
- Example:
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "11111111-2222-3333-4444-555555555555",
"ClientId": "API_CLIENT_ID",
"Audience": "api://API_CLIENT_ID"
}
🔹 17. Authentication Middleware
- Definition: Middleware in ASP.NET Core that validates tokens.
- Code:
builder.Services.AddAuthentication("Bearer")
.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"));
🔹 18. Authorization Policy
- Definition: Rules that enforce which scopes/roles are required.
- Example:
options.AddPolicy("ApiScope", policy =>
policy.RequireAuthenticatedUser()
.RequireClaim("scp", "access_as_user"));
🔹 19. Claims
- Definition: Key-value pairs in a JWT token.
- Examples:
aud→ Audience (API identifier)scp→ Scopesroles→ App rolesexp→ Expiration
🔹 20. Consent
- Definition: When a user/admin agrees that a client can call an API with specific scopes.
- Types:
- User consent → For delegated scopes, if allowed.
- Admin consent → Required for app-only permissions.
🛠️ How They Fit Together
Imagine this flow:
- Register API → creates identity (
API_CLIENT_ID) and exposes scope (access_as_user). - Register Client App → requests that scope.
- User signs in (delegated flow) or App authenticates (client credentials).
- Token issued by Entra → contains
aud,scporroles. - .NET API middleware validates the token.
- Controller enforces authorization with
VerifyUserHasAnyAcceptedScope. - If API calls another API → uses OBO flow to get downstream token.
✅ Conclusion
By now, you should understand every key concept in Microsoft Entra API onboarding:
- Tenant, App registration, Client ID, Tenant ID
- Scopes vs Roles
- Access tokens, ID tokens, Refresh tokens
- Delegated vs App-only flows
- On-Behalf-Of (OBO) for multi-tier calls
- Middleware and policies in ASP.NET Core
👉 With this foundation, you can securely expose APIs, register clients, and enforce least-privilege access using Entra ID and .NET.
Comments
Post a Comment