Okay, you can achieve this using Cloudflare Access Policies within your Cloudflare Zero Trust dashboard. Cloudflare Tunnel relies on Access policies to control who can connect. By default, you likely have a policy enforcing 2FA for everyone. To "whitelist" users, you'll create a new, more permissive policy that targets specific users and place it above the general 2FA policy.
Here’s how to do it:
Understanding the Concept:
- Cloudflare Access: This is the service that provides authentication and authorization for applications protected by Cloudflare Tunnel.
- Policies: You define rules (policies) that determine who can access which applications. Policies are evaluated in order from top to bottom.
- Whitelisting: You'll create a specific policy that allows access for certain users, potentially requiring less authentication (e.g., just their initial login/SSO, bypassing the explicit 2FA step for them), and ensure this policy is evaluated before the general 2FA policy.
Steps:
-
Navigate to Cloudflare Zero Trust:
- Log in to your Cloudflare dashboard.
- Select your account.
- In the left-hand sidebar, go to Zero Trust.
-
Go to Access Policies:
- Under the "Access" section in the sidebar, click on Applications.
- Find the specific application that is configured for your Cloudflare Tunnel and click on it to manage its policies.
-
Review Existing Policies:
- You should see a list of existing policies. Identify the policy that currently enforces 2FA for most users. Note its position in the list.
-
Create a New "Whitelist" Policy:
- Click the "Add a policy" button.
- Policy Name: Give it a descriptive name, like "Whitelist - Admins" or "Bypass 2FA - Specific Users".
- Application: This should be pre-filled with the application you selected.
- Session Duration: Choose an appropriate duration (e.g., 24 hours).
- Rules: This is the critical part.
- Click "Add rule".
- Action: Select "Allow".
- If: Choose the criteria to identify the users you want to whitelist. Common options include:
- Emails: Enter the exact email addresses of the users you want to allow. You can add multiple.
- Emails ending in: Useful for allowing everyone from a specific domain (e.g.,
@yourcompany.com).
- Access Groups: If you have already created an Access Group containing these users, select that group here. This is often the easiest way to manage multiple users.
- (Optional but Recommended) Require: This determines the authentication level.
- If your main policy requires "Two-factor authentication", you might set this new policy to require "One-factor authentication" (just their initial login/SSO) to effectively bypass the additional 2FA step. If you only have one policy that requires 2FA, simply allowing access based on email might be enough if this policy is evaluated first, but explicitly setting a lower requirement is clearer.
- Click "Next" and then "Save policy".
-
Order the Policies:
- Go back to the list of policies for your application.
- Crucially, drag and drop your newly created "Whitelist" policy so it appears above the general 2FA policy. Policies are evaluated top-down, so the whitelist policy needs to be checked first. If a user matches the whitelist policy, they will be allowed access immediately, and the subsequent 2FA policy won't be evaluated for them.
Example Scenario:
- Policy 1 (Top): Name:
Whitelist Admins, Rule: Emails admin1@example.com, admin2@example.com, Require: One-factor authentication.
- Policy 2 (Below): Name:
Require 2FA for All, Rule: Emails * (everyone), Require: Two-factor authentication.
In this setup, admin1@example.com and admin2@example.com will only need their standard login (e.g., Google SSO, GitHub login) because they match Policy 1 first. All other users will fall through to Policy 2 and be required to complete 2FA.
Alternative: IP Address Whitelisting (If that's what you meant)
If you meant allowing access only from specific network locations for certain users (or everyone) instead of bypassing 2FA for specific users, you would modify the rules of a policy:
- Edit an existing policy or create a new one.
- In the Rules section, add a criterion.
- Choose "Source IP".
- Select "In a list" or "Is in / CIDR".
- Enter the specific IP addresses or IP ranges (CIDR notation) that should be allowed access.
- You can combine this with user criteria (e.g., "Allow users in 'Admins' group AND from this specific IP range").
Important Considerations:
- Security: Bypassing 2FA for any user or group reduces the overall security posture. Only do this for trusted users and understand the risks involved.
- Testing: After implementing the changes, thoroughly test access with both a whitelisted user and a non-whitelisted user to ensure the policies are working as expected.
- Access Groups: Using Cloudflare Access Groups makes managing whitelists much easier. You can add/remove users from the group without editing the policy directly.
Choose the method that best suits your definition of "whitelisting" and proceed carefully, prioritizing security.