Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
External tenants (learn more)
In this article, you learn how to configure Cloudflare Web Application Firewall (Cloudflare WAF) to protect your organization from attacks, such as distributed denial of service (DDoS), malicious bots, Open Worldwide Application Security Project (OWASP) Top-10 security risks, and others.
Prerequisites
To get started, you need:
- An external tenant.
- A Microsoft Azure Front Door (AFD) configuration. Traffic from the Akamai WAF routes to Azure Front Door, which then routes to the external tenant.
- An Cloudflare Web Application Firewall (WAF) that manages traffic sent to the authorization server.
- A custom ___domain in your external tenant that’s enabled with Azure Front Door (AFD).
Learn about tenants and securing apps for consumers and customers with Microsoft Entra External ID.
Scenario description
- Microsoft Entra External ID tenant – The identity provider (IdP) and authorization server that verifies user credentials with custom policies defined for the tenant.
- Azure Front Door – Enables custom URL domains for Microsoft Entra External ID. Traffic to custom URL domains goes through Cloudflare WAF, it then goes to AFD, and then to the Microsoft Entra External ID tenant.
- Cloudflare WAF – Security controls to protect traffic to the authorization server.
Cloudflare setup steps
First you need to set up Cloudflare WAF to protect your custom URL domains for Microsoft Entra External ID. Follow these steps to configure Cloudflare WAF.
Enable custom URL domains
The first step is to enable custom domains with AFD. Use the instructions in, Enable custom URL domains for apps in external tenants.
Create a Cloudflare account
- Go to Cloudflare.com/plans to create an account.
- To enable WAF, on the Application Services tab, select Pro.
Configure the ___domain name server (DNS)
Enable WAF for a ___domain.
- In the DNS console, for CNAME, enable the proxy setting.
Note
Azure Front Door-managed certificates aren't automatically renewed if your custom ___domain’s CNAME record points to a DNS record other than the Azure Front Door endpoint’s ___domain (for example, when using a third-party DNS service like Cloudflare). To renew the certificate in such cases, follow the instructions in the Renew Azure Front Door-managed certificates article.
Cloudflare security controls
For optimal protection, we recommend you enable Cloudflare security controls.
DDoS protection
- Go to the Cloudflare dashboard.
- Expand the Security section.
- Select DDoS.
- A message appears.
Bot protection
- Go to the Cloudflare dashboard.
- Expand the Security section.
- Under Configure Super Bot Fight Mode, for Definitely automated, select Block.
- For Likely automated, select Managed Challenge.
- For Verified bots, select Allow.
Firewall rules: Traffic from the Tor network
We recommend you block traffic that originates from the Tor proxy network, unless your organization needs to support the traffic.
Note
If you can't block Tor traffic, select Interactive Challenge, not Block.
Block traffic from the Tor network
- Go to the Cloudflare dashboard.
- Expand the Security section.
- Select WAF.
- Select Create rule.
- For Rule name, enter a relevant name.
- For If incoming requests match, for Field, select Continent.
- For Operator, select equals.
- For Value, select Tor.
- For Then take action, select Block.
- For Place at, select First.
- Select Deploy.
Note
You can add custom HTML pages for visitors.
Firewall rules: Traffic from countries or regions
We recommended strict security controls on traffic from countries or regions where business is unlikely to occur, unless your organization has a business reason to support traffic from all countries or regions.
Note
If you can't block traffic from a country or region, select Interactive Challenge, not Block.
Block traffic from countries or regions
For the following instructions, you can add custom HTML pages for visitors.
- Go to the Cloudflare dashboard.
- Expand the Security section.
- Select WAF.
- Select Create rule.
- For Rule name, enter a relevant name.
- For If incoming requests match, for Field, select Country/Region or Continent.
- For Operator, select equals.
- For Value, select the country/region or continent to block.
- For Then take action, select Block.
- For Place at, select Last.
- Select Deploy.
OWASP and managed rulesets
- Select Managed rules.
- For Cloudflare Managed Ruleset, select Enabled.
- For Cloudflare OWASP Core Ruleset, select Enabled.
Set up a web application firewall (WAF) in External ID
After you set up your Cloudflare account, connect it to Microsoft Entra External ID. Use your Cloudflare API token and Zone ID to complete the connection. You can do this in the admin center or by using Microsoft Graph API.
WAF provider configuration
- Sign in to the Microsoft Entra admin center as at least a Security Reader.
- If you have access to multiple tenants, use the Settings icon
in the top menu to switch to the external tenant you created earlier from the Directories + subscriptions menu. - Browse to Entra ID > Security Store.
- Select the Protect apps from DDoS with WAF tile by selecting Get started.
- Under Choose a WAF Provider select Cloudflare and then select Next.
- Under Configure Cloudflare WAF, you can select an existing configuration or create a new one. If you're creating a new configuration add the following information:
- Configuration name: A name for the WAF configuration.
- API token: The API token from your Cloudflare dashboard.
- Zone ID: The Zone ID for your ___domain, from your Cloudflare dashboard.
- Select Next to save your changes.
Domain verification
Select the custom URL domains that are enabled through Azure Front Door (AFD) to verify and connect them to your Cloudflare WAF configuration. This step ensures that the selected domains are protected with advanced security features.
- Select Verify ___domain to start the verification process.
- Select the custom URL domains you want to protect with Cloudflare WAF and then select Verify.
- After verification, select Done.
Test the configuration
Once you’ve connected Cloudflare WAF with Microsoft Entra External ID, it’s important to test the configuration to ensure everything is working as expected.
Troubleshooting
The following table lists common issues you might encounter when integrating Cloudflare WAF with Microsoft Entra External ID, along with their details and resolutions.
| Issue | Details | Resolution |
|---|---|---|
| Bad Request Response | "The provided API Key has insufficient permissions. Please reauthenticate and try again.\r\n CloudFlare Request ID: {CF-Ray-value}\r\nCorrelation ID: random-id-entry-value\r\nTimestamp: 2024-08-25 21:32:40Z" |
Check the permission level mentioned in the above steps. |
| Couldn't reach the external tenant's well-known endpoint | "Could not reach the tenant's well-known endpoint via custom ___domain. Please check that your custom ___domain has been properly configured to route traffic."At the Graph level, you might see HTTP 200 OK with status failure when Cloudflare returns error code 403. This check is performed on our side before any API calls to Cloudflare. |
Disable the captcha on the Cloudflare portal (change the wildcard to disable), then rerun the POST request. |
Additional resources
- Cloudflare WAF Get started guide: Includes recommendations on how to best configure WAF and what basic protection and rules can be deployed.
- FAQ related to External Tenant Overview - Microsoft Entra External ID | Microsoft Learn for other best practices and considerations.
- Check traffic results in the Cloudflare dashboard: Security Analytics · Cloudflare Web Application Firewall (WAF) docs
- Azure Front Door additional best practices Domains in Azure Front Door | Microsoft Learn
- API Troubleshooting · Cloudflare Fundamentals docs
- Troubleshooting · Cloudflare Support docs