Entra ID Authentication and Authorization

Entra ID, formerly known as Azure Active Directory (Azure AD), is Microsoft’s cloud-based identity and access management (IAM) service. It provides secure authentication, authorization, and management for users, applications, and resources across the Microsoft ecosystem and beyond. With Entra ID, you can manage user identities, secure applications, control access to resources, and store sensitive information securely.

Here’s a beginner-friendly guide to understanding the key authentication and authorization methods, along with how to configure, manage, and monitor keys, secrets, and certificates in Entra ID.


1. Overview of Entra ID Authentication and Authorization

Key Concepts

  • Authentication: Verifying the identity of a user, device, or application trying to access a system. Entra ID supports methods like passwords, multi-factor authentication (MFA), and passwordless options.
  • Authorization: Granting permissions to authenticated users or applications to access specific resources.
  • Access Control: Using Entra ID’s role-based access control (RBAC) to assign roles and permissions, controlling what actions users or applications can perform.

Main Authentication Methods in Entra ID

  1. Password-Based Authentication: Standard username and password login.
  2. Multi-Factor Authentication (MFA): Adds an extra layer of security by requiring a second form of verification, such as an SMS code or authenticator app.
  3. Passwordless Authentication: Uses modern, secure methods like biometrics (e.g., fingerprint or facial recognition) or FIDO2 keys instead of passwords.
  4. Single Sign-On (SSO): Allows users to access multiple applications with a single login, improving security and user convenience.

Key Authorization Methods in Entra ID

  1. Role-Based Access Control (RBAC): Defines roles for managing permissions, like “User”, “Contributor”, or “Owner” roles for resources.
  2. Conditional Access: Applies security policies to manage access based on conditions like location, device compliance, or risk level.
  3. Access Reviews: Periodic checks to ensure that users and applications still need the permissions they have.

2. Setting Up Authentication Methods in Entra ID

Step 1: Enable Multi-Factor Authentication (MFA)

  1. Navigate to MFA in Entra ID:
  • In the Azure portal, go to Entra ID > Security > Multi-Factor Authentication.
  1. Configure MFA Settings:
  • Define which users require MFA (e.g., all users, certain groups).
  • Set up preferred verification methods (SMS, Authenticator app, phone call).
  1. User Registration for MFA:
  • Users can register for MFA by providing their phone number or setting up an authenticator app, adding an additional layer of security.

Step 2: Enable Passwordless Authentication

Passwordless authentication is a modern security method that eliminates the need for traditional passwords.

  1. Go to Security Settings in Entra ID:
  • Go to Security > Authentication Methods > Passwordless Authentication.
  1. Select Passwordless Methods:
  • Options include Microsoft Authenticator App or FIDO2 Security Keys.
  • Enable these methods and assign them to specific users or groups.
  1. User Enrollment:
  • Users can enroll by downloading the Microsoft Authenticator app or setting up a FIDO2 key for login, improving security and reducing the risk of password-based attacks.

3. Configuring Role-Based Access Control (RBAC)

Role-based access control in Entra ID allows you to assign roles to users, applications, and groups to manage access to resources.

Step 1: Define and Assign Roles

  1. Navigate to Entra ID Roles:
  • Go to Entra ID > Roles and Administrators.
  1. Choose a Role:
  • Select a predefined role (e.g., User Administrator, Security Administrator).
  • You can also create custom roles with specific permissions if needed.
  1. Assign Users to Roles:
  • Under each role, click + Add assignment and select the user or group you want to assign.
  • This assignment grants them permissions to manage certain Entra ID resources.

Step 2: Use Conditional Access Policies

  1. Navigate to Conditional Access:
  • In the Security section, select Conditional Access.
  1. Create a Policy:
  • Define conditions under which users can access resources (e.g., requiring MFA for users outside the corporate network).
  • Choose actions such as requiring MFA or blocking access based on conditions.
  1. Assign Policy to Users or Groups:
  • Apply the policy to specific users or groups to enforce security policies based on risk or location.

4. Storing and Managing Keys, Secrets, and Certificates

Entra ID integrates closely with Azure Key Vault to store and manage sensitive information like cryptographic keys, secrets, and certificates securely.

Keys: For Data Encryption and Decryption

  1. Create and Store a Key in Azure Key Vault:
  • In the Azure portal, go to Key Vaults and select your vault.
  • Under Keys, choose + Generate/Import to create a new key.
  • Specify a name, key type (e.g., RSA), and size (e.g., 2048 bits).
  1. Using the Key for Encryption:
  • You can use the key to encrypt data, either programmatically or by integrating it with applications like Azure Storage.

Example: Encrypting Data with a Key (Python SDK)

from azure.identity import DefaultAzureCredential
from azure.keyvault.keys import KeyClient
from azure.keyvault.keys.crypto import CryptographyClient, EncryptionAlgorithm

# Set up Key Vault and Key
vault_url = "https://<your-key-vault-name>.vault.azure.net"
credential = DefaultAzureCredential()
key_client = KeyClient(vault_url=vault_url, credential=credential)
key = key_client.get_key("encryptionKey")

# Encrypt data
crypto_client = CryptographyClient(key, credential=credential)
plaintext = b"Hello, secure world!"
encrypt_result = crypto_client.encrypt(EncryptionAlgorithm.rsa_oaep, plaintext)
print("Encrypted data:", encrypt_result.ciphertext)
  1. Rotate Keys:
  • Regularly rotate keys for security and compliance. Key Vault lets you set up policies to rotate keys periodically.

Secrets: Secure Storage for Sensitive Data

  1. Create and Store a Secret:
  • Go to Key Vaults > Secrets > + Generate/Import.
  • Give the secret a name (e.g., APIKey) and set the value (e.g., an API key or database connection string).
  1. Retrieve a Secret:
  • Applications can retrieve secrets from Key Vault to avoid hardcoding sensitive data.

Example: Retrieving a Secret (Python SDK)

from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient

vault_url = "https://<your-key-vault-name>.vault.azure.net"
credential = DefaultAzureCredential()
secret_client = SecretClient(vault_url=vault_url, credential=credential)

# Retrieve the secret
secret_name = "APIKey"
retrieved_secret = secret_client.get_secret(secret_name)
print("Secret value:", retrieved_secret.value)

Certificates: Managing SSL/TLS Certificates

  1. Store a Certificate in Key Vault:
  • In Key Vault > Certificates > + Generate/Import.
  • Define the certificate type (e.g., SSL/TLS), validity period, and set auto-renewal if supported.
  1. Retrieve and Use Certificates:
  • Applications can retrieve certificates for SSL/TLS purposes to secure data in transit.

Example: Retrieving a Certificate (Python SDK)

from azure.identity import DefaultAzureCredential
from azure.keyvault.certificates import CertificateClient

vault_url = "https://<your-key-vault-name>.vault.azure.net"
credential = DefaultAzureCredential()
cert_client = CertificateClient(vault_url=vault_url, credential=credential)

# Retrieve the certificate
cert_name = "mySSLCertificate"
certificate = cert_client.get_certificate(cert_name)
print("Certificate details:", certificate)
  1. Certificate Renewal and Expiry Alerts:
  • Configure Key Vault to automatically renew certificates before they expire, and set up alerts for administrators.

5. Monitoring and Auditing in Entra ID

Entra ID includes built-in tools for monitoring and auditing activities, which are essential for security and compliance.

Activity Logs and Audit Logs

  1. View Logs:
  • Go to Entra ID > Audit logs or Sign-in logs to monitor activities like login attempts, user activity, and administrative actions.
  1. Set Up Alerts:
  • In Azure Monitor, set up alerts for specific activities, such as multiple failed login attempts or unauthorized access to sensitive resources.

Conditional Access Reporting

  1. Conditional Access Insights:
  • View insights on the usage of Conditional Access policies in Conditional Access Insights. This helps ensure that policies are effectively protecting resources.
  1. Risky Sign-Ins:
  • Entra ID identifies risky sign-ins based on factors like unfamiliar locations or devices, allowing administrators to respond to suspicious activity.

6. Usage Example: Securely Accessing a Database Connection String

  1. Store the Connection String as a Secret in Key Vault:
  • Store the database connection string as a secret named dbConnectionString in Azure Key Vault.
  1. **Retrieve and Use the Secret in Your Application**:
  • Your application retrieves the connection string securely using the Azure Key Vault SDK.
  1. Monitor Secret Access:
  • Set up alerts in Azure Monitor to notify you if there’s unusual access to the secret.

By implementing Entra ID for authentication and authorization, you ensure that only authorized users and applications have access to sensitive resources while securely managing keys, secrets, and certificates. With access policies, RBAC, and monitoring, you can maintain a secure, compliant, and well-managed identity and access environment in Azure.

Author: tonyhughes