Azure Entra ID (formerly Azure Active Directory) is Microsoft’s cloud-based identity and access management (IAM) service. It helps secure apps, APIs, and services by managing authentication (who you are) and authorization (what you can do).
🔹 1. Key Concepts
- Tenant: A dedicated instance of Entra ID for your organization.
- App Registration: Register apps to integrate with Entra ID for authentication.
- Authentication: Verifying user or service identity (via username, password, certificate, token).
- Authorization: Granting permissions (roles/scopes) after authentication.
- Tokens:
- ID Token → User identity (used in login).
- Access Token → Grants access to APIs.
- Refresh Token → Get new tokens without logging in again.
🔹 2. Authentication Flows
- Authorization Code Flow (with PKCE) – Secure for web & mobile apps.
- Client Credentials Flow – Service-to-service authentication (no user).
- Device Code Flow – Used on devices without browsers (IoT, CLI).
- Implicit Flow (legacy) – Browser-based apps (now replaced by Auth Code + PKCE).
🔹 3. Integration in .NET
Add Entra authentication in ASP.NET Core API:
// Program.cs
builder.Services.AddAuthentication("Bearer")
.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"));
Configure in appsettings.json
:
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "yourdomain.onmicrosoft.com",
"TenantId": "xxxx-xxxx-xxxx",
"ClientId": "xxxx-xxxx-xxxx"
}
🔹 4. Authorization with Policies
builder.Services.AddAuthorization(options =>
{
options.AddPolicy("ApiScope", policy =>
policy.RequireAuthenticatedUser()
.RequireClaim("scp", "access_as_user"));
});
🔹 5. Security Features
- Conditional Access → Enforce MFA, device compliance.
- Identity Protection → Detect risky sign-ins.
- Role-Based Access Control (RBAC) → Assign roles like Reader, Contributor, Admin.
- App Roles & Scopes → Fine-grained access control for apps.
🔹 6. Common Use Cases
✅ Single Sign-On (SSO) for apps
✅ API protection with OAuth 2.0 & OpenID Connect
✅ B2C (Business-to-Consumer) authentication
✅ Enterprise federation with external providers (Google, Facebook, etc.)
🔹 7. Best Practices
- Always use Authorization Code + PKCE for SPAs.
- Use Managed Identities for Azure resources (no secrets).
- Regularly rotate client secrets or use certificates.
- Enable MFA + Conditional Access for stronger security.
✨ In short: Azure Entra Auth secures your applications with modern identity standards (OAuth 2.0, OpenID Connect). It supports users, apps, and services with SSO, tokens, roles, and conditional access to build enterprise-grade secure solutions.
Comments
Post a Comment