Adding Authentication with Cloudflare Access
On this page18 items
On the previous page, you published your NAS to the internet without opening any ports. But as noted at the end, right now anyone who knows the URL can reach the DSM login screen. Stopping port forwarding while still exposing the login screen to the world is only half a defense.
On this page, you’ll place Cloudflare Access in front of it. Once set up, people who don’t pass authentication won’t even see the DSM login screen. From an attacker’s point of view, there’s no way to tell what’s behind that URL.
The concept was explained in Cloudflare Access in Chapter 3. Here you’ll actually configure it. It takes about 10 minutes.
What you’ll learn on this page#
- How to register an application in Access
- How to build policies (who gets in and who gets stopped)
- Authentication with One-time PIN, which works without setting up an IdP
- How to think about “two login screens” after authenticating
- What to do when smartphone apps or APIs stop connecting
What changes when you add Access#
First, let’s compare before and after.

Before: anyone can reach the DSM login screen. Attackers can throw IDs and passwords at it as many times as they like. If a vulnerability is found in DSM, you’re exposed from that moment.
After: people who haven’t authenticated see only Cloudflare’s login screen. Not a single request reaches the NAS software. Even if a vulnerability is found in DSM, attackers can’t reach it in the first place.
This “stop it before it reaches the application” is the essential value of Access.
Step 1: Register the application#
In the Cloudflare dashboard, open Zero Trust (Cloudflare One) → Access controls → Applications, and choose Create new application.
When asked for the type, choose Self-hosted and private (an app you run yourself) and proceed to Add public hostname.
The main settings are:
| Setting | Example | Description |
|---|---|---|
| Application name | NAS Admin | A name for management. Anything works |
| Session Duration | 24 hours | How many hours a single authentication stays valid |
| Public hostname | nas + example.com | The hostname you published on the previous page |
| Identity providers | One-time PIN, etc. | The authentication methods you want to allow |
Session Duration is a tug-of-war between convenience and security. Shorter means frequent re-authentication; longer means more risk if a device is stolen. For a home NAS, 24 hours to a week is a reasonable guideline; for business systems, a few hours to a day.
Wildcards work too in the hostname. Specify *.example.com and you protect all subdomains of that domain at once.
Step 2: Create a policy#
Just registering the app doesn’t let anyone in yet, because Access denies everything by default. The official documentation states explicitly that “all Access applications are deny by default, and users are allowed only when they match an Allow policy.”
So you write the conditions for letting people in. The minimal setup is:
- Action:
Allow - Rule type:
Include - Selector:
Emails - Value: your email address
This means “let in only the owner of this email address.”
For family or team use, these patterns are handy:
| Goal | Selector | Example value |
|---|---|---|
| Let in only a few specific people | Emails | [email protected], [email protected] |
| Let in an entire company domain | Emails ending in | @example.co.jp |
| Allow only from a specific country | Country | Japan |
| Manage by group | Access groups | A group created beforehand |
Combining conditions#
There are three kinds of rules, and the difference is confusing at first.
- Include: passes if any one matches (OR)
- Require: must satisfy all to pass (AND)
- Exclude: blocked if it matches
For example, for “an email address on the company domain, and access from Japan,” put Emails ending in @example.co.jp in Include and Country Japan in Require.
Step 3: Choose authentication methods#
“Authenticating” doesn’t mean Cloudflare holds a password. Access delegates identity verification to an external party, called an IdP (identity provider).
One-time PIN: no setup required#
If you’re trying it out, One-time PIN is the easiest. It needs no IdP configuration at all.
- When the user opens the URL, an email address field appears
- After entering it, a one-time code is sent to that address
- Entering the code lets them through
Entering an address not listed in the policy makes the code meaningless. For how easy it is, it’s solid protection.
Using Google or GitHub accounts#
If you want people to authenticate with accounts they already use, add an IdP. You can configure it under Settings → Authentication, and it supports major services such as Google, Microsoft Entra ID, GitHub, Okta and OneLogin.
With Google accounts set up, users just click “Sign in with Google” to get through. If they’re already signed into Google in their browser, it takes a single click.
About authenticating twice#
Once set up, opening nas.example.com goes like this:
- Cloudflare’s authentication screen appears → you pass it
- The DSM login screen appears → you log in with your NAS ID and password
It might feel like “logging in twice is a hassle,” but this is the correct state. Access protects “whether you can reach it”; it doesn’t take over the NAS’s own login. As defense in depth, having both is safer.
If you want to skip the DSM login, you can combine it with DSM’s SAML-based SSO settings, but at first it’s best to simply leave it as two steps.
Step 4: Verify it works#
Always verify in a private window. In your usual window, an already-authenticated cookie may remain, so you can’t tell whether it’s properly protected.
There are two things to check:
- Opening
https://nas.example.comin a private window shows Cloudflare’s authentication screen, not DSM - An email address not listed in the policy can’t get through
If the first one “shows the DSM login screen,” the hostname is wrong or the settings haven’t taken effect. Wait a few tens of seconds, then check the hostname’s spelling.
Where people get stuck#

Smartphone apps and APIs stop connecting#
This is the most common problem. Access assumes authentication in a browser, so access from anything other than a browser can’t display the login screen and is simply rejected.
- Synology mobile apps such as DS file and DS photo
- WebDAV connections
- Webhooks from external services
- API calls from your own scripts
There are three ways to handle this:
- Use a service token: send a client ID and secret issued by Cloudflare in the request headers. Set the policy action to
Service Authand allow that token. Suited to scripts and server-to-server integrations - Bypass only specific paths: only for routes that must be public, such as a webhook endpoint, create a policy with the action
Bypass. But that route is left completely unprotected, so keep the scope to a minimum - Set up a separate hostname for apps: you can also create
app-nas.example.com, leave Access off it, and instead use a private network setup that’s reachable only via WARP
Understand the policy evaluation order#
When there are multiple policies, the order of evaluation is fixed.
- Bypass and Service Auth come first, evaluated from top to bottom
- Then Block and Allow, evaluated from top to bottom
- Evaluation ends as soon as an Allow or Block matches
If “I wrote a Block but it still lets people through,” suspect a broad Bypass above it.
Close off paths that hit the origin directly#
Access protects traffic that goes through Cloudflare. Put the other way, if a path remains that reaches the server directly while bypassing Cloudflare, Access loses its meaning.
With the setup from the previous page, the NAS reaches the outside only via Tunnel, so this isn’t a concern. The reason Tunnel plus Access is the standard combination is that this problem is solved structurally.
On the other hand, if you run on something like a rental server whose IP address is known, you need to also configure the server to reject access from anything other than Cloudflare (such as Authenticated Origin Pulls).
Points beginners should watch out for#
- Don’t lock yourself out: if you mistype the email address in a policy, you won’t be able to get in either. The Cloudflare dashboard itself uses separate authentication, so you can recover, but do your first check in a private window so you don’t panic
- The free tier covers up to 50 users: within Cloudflare One’s Free plan, you can use all of Access’s basic features (as of August 2026). That’s plenty for individuals, households and small teams
- An email address means “the person who authenticated”: it assumes the owner of the listed address can receive mail there. If you forget to remove a departed employee’s address, their access remains
- Don’t make Session Duration too long: it’s convenient, but the session stays alive if a device is lost. For business use, a day or less is recommended
- Get in the habit of checking logs: Access logs record when and who attempted authentication and whether they got through or were rejected. Signs of suspicious access show up here
- Review policies every time you add an app: if you protect broadly with a wildcard, subdomains added later may be included (or left out) unintentionally
Related services#
- What Is Cloudflare Access?: explains how it works (the basis for this page)
- Publishing a Synology NAS with Cloudflare Tunnel: the setup this page builds on
- What Is Zero Trust?: why authenticate per app
- What Is Cloudflare One?: the product suite Access belongs to
- What Is WARP?: an option for non-browser traffic
- What Is Cloudflare Gateway?: controlling outbound traffic
Summary#
- With Access in place, people who don’t authenticate can’t even see the app’s login screen. Attacks stop before they reach the app
- Setup has three stages: “register the application → create a policy → choose authentication methods”
- Access denies everything by default. Only people matching an Allow policy get through
- With One-time PIN, you can start right away without setting up an IdP
- Having both Cloudflare’s authentication and the app’s own login is the correct state. It’s meaningful as defense in depth
- If smartphone apps or APIs stop connecting, use a service token, a limited Bypass, or a separate hostname
- Bypass and Service Auth policies are evaluated first. When “Block doesn’t work,” suspect this
- Tunnel and Access pair well because no direct path to the origin exists, structurally
Together with the previous page, you now have a home server published without open ports, usable only by people who pass authentication. It’s one of the setups where Cloudflare’s features are easiest to appreciate.
The three pages so far have been about protecting things that already exist. From the next page, we move on to building things yourself on Cloudflare, starting with a Workers Hello World.