Access Groups & Authentication
Time Required
15 Minutes
Difficulty
Low
Access Groups
Access groups allow you to add authentication policies against all or part of your site. When a user browses to the address, Cloudflare prompts them to complete an Authentication challenge which they must complete to continue. These challenges are managed via Access Groups
In this example, we're going to create 2 groups. One to only allow people in Australia and another to specific users
Creation of Groups
Log into Cloudflare and click on Zero Trust
Navigate to Access > Access Groups
Click on 'Add a group'
Group name: Email Auth
Under 'Group configuration'
Change the include 'Selector' to 'Emails' and type your email/s in the right hand field
Click on 'Save'
Click on 'Add a group'
Group name: Australia Only
Under 'Group configuration'
Change the include 'Selector' to 'Country' and select 'Australia'
Click on "+Add require"
Change the include 'Selector' to 'Country' and select 'Australia'
Click on Save
Additional Authentication
The default challenge for the 'User Authentication' is a 2FA code sent via email. We can add additional authentication providers, such as GitHub, Google and Facebook
Log into Cloudflare and click on Zero Trust
Click on 'Settings', then select 'Authentication'
Under login methods, click on 'add new'
Follow the steps to configure the relevant auth providers you want to use
How does this work?
The 'Emails' selector, used in the 'User Authentication' access group is also compared against the email address assigned to your authentication providers. For example, if we allowed 'test@email.com' in the rule, that would allow the GitHub account with 'test@email.com' as the email address.
Enabling Authentication
Not all proxied apps you create need to be open to the internet. You can secure them behind authentication, making it so a user has to authenticate with Cloudflare BEFORE accessing the service. This is significantly more secure than enabling authentication in the app (based on the assumption that Cloudflare will have a significantly better security team vs the random app you're deploying)
Please note this will not work without a public hostname being created first
Adding auth and blocking access to subdomain, domain or path
Log into Cloudflare and click on Zero Trust
Navigate to Access > Applications
Click on 'Add an application' and select 'Self hosted'
Fill in the relevant details & click on 'next'
Replicate these settings and click next
Accept the defaults, scroll down and click 'Add application'
Now anyone within the 'Email Auth' access group can access the site
Last updated