PHPackages                             teraone/laravel-cloudflare-zero-trust-middleware - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. teraone/laravel-cloudflare-zero-trust-middleware

ActiveLibrary[Security](/categories/security)

teraone/laravel-cloudflare-zero-trust-middleware
================================================

Middleware to secure certain routes with Cloudflare Zero Trust

1.3.1(1y ago)6120.9k↓72.2%6[5 issues](https://github.com/teraone/laravel-cloudflare-zero-trust-middleware/issues)[5 PRs](https://github.com/teraone/laravel-cloudflare-zero-trust-middleware/pulls)MITPHPPHP ^8.3CI passing

Since Feb 1Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/teraone/laravel-cloudflare-zero-trust-middleware)[ Packagist](https://packagist.org/packages/teraone/laravel-cloudflare-zero-trust-middleware)[ Docs](https://github.com/teraone/laravel-cloudflare-zero-trust-middleware)[ RSS](/packages/teraone-laravel-cloudflare-zero-trust-middleware/feed)WikiDiscussions dev Synced 3d ago

READMEChangelog (6)Dependencies (16)Versions (11)Used By (0)

Laravel Route Middleware For [Cloudflare Zero Trust](https://developers.cloudflare.com/cloudflare-one/)
=======================================================================================================

[](#laravel-route-middleware-for--cloudflare-zero-trust)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a7cdacdc4dc0fbd6aab5b5bbd171899cbc4668de06870013ecc3f23d1151b5e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746572616f6e652f6c61726176656c2d636c6f7564666c6172652d7a65726f2d74727573742d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teraone/laravel-cloudflare-zero-trust-middleware)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c3076741d25ac83763bdea4f7685d0c8309bb34048353b575705951ba4f2dfa5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746572616f6e652f6c61726176656c2d636c6f7564666c6172652d7a65726f2d74727573742d6d6964646c65776172652f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/teraone/laravel-cloudflare-zero-trust-middleware/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/77ba836b24df3089d081ace7b89b653bbc320565957525d7234bba4b0cc2c42c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746572616f6e652f6c61726176656c2d636c6f7564666c6172652d7a65726f2d74727573742d6d6964646c65776172652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d6173746572266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/teraone/laravel-cloudflare-zero-trust-middleware/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/f8666b14d5443ec2c773c868532caf5818f597f123d4ee4ac13896c1a21ead56/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746572616f6e652f6c61726176656c2d636c6f7564666c6172652d7a65726f2d74727573742d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teraone/laravel-cloudflare-zero-trust-middleware)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require teraone/laravel-cloudflare-zero-trust-middleware
```

Configuration
-------------

[](#configuration)

Publish the config file with:

```
php artisan vendor:publish --tag="cloudflare-zero-trust-middleware-config"
```

This is the content of the published config file:

```
return [
    /*
     |--------------------------------------------------------------------------
     | Cloudflare Team Name
     |--------------------------------------------------------------------------
     |
     | Here you should define the name of your Cloudflare Team Account.
     | Not sure? Open https://one.dash.cloudflare.com/
     | It will be the name on which you click.
     |
     */
    'cloudflare_team_name' => env('CLOUDFLARE_TEAM_NAME'),

    /*
     |--------------------------------------------------------------------------
     | Cloudflare Zero Trust / Application Audience Tag
     |--------------------------------------------------------------------------
     |
     | Please enter the Application Audience Tag which you want to protect.
     | Open the Zero Trust Dashboard at https://one.dash.cloudflare.com/:
     | Access > Applications: Select "Configure" for your application.
     | On the overview tab, copy the "Application Audience (AUD) Tag".
     |
     */
    'cloudflare_zero_trust_application_audience_tag' => env('CLOUDFLARE_ZERO_TRUST_APPLICATION_AUDIENCE_TAG'),

    /*
     |--------------------------------------------------------------------------
     | Use certificate cache
     |--------------------------------------------------------------------------
     |
     | Should it cache the cloudflare certificates.
     |
     */
    'cache' => true,

    /*
     |--------------------------------------------------------------------------
     | Certificate cache TTL
     |--------------------------------------------------------------------------
     |
     | How long should we cache your public cloudflare certificates? In seconds.
     | The certificate cache will be flushed when a new certificate is detected.
     |
     */
    'cache_ttl' => 60 * 60 * 24,

    /*
     |--------------------------------------------------------------------------
     | Disable the middleware on these environments
     |--------------------------------------------------------------------------
     |
     | Most likely you do not have cloudflare available during development.
     | Use this setting to bypass the middleware for specific environments.
     |
     */
    'disabled_environments' => [
        'local',
    ],
];
```

Usage
-----

[](#usage)

Add the middleware to the routes you want to protect.

```
// with shorthand alias
Route::get('/protected', function(){ return 'Protected by Cloudflare Zero trust ✅';})
    ->middleware('cloudflare-zero-trust');

// OR: Use Class directly
Route::get('/also-secure', function(){ return 'Also protected by Cloudflare Zero trust ✅';})
    ->middleware(\Teraone\ZeroTrustMiddleware\ZeroTrustMiddleware\ZeroTrustMiddleware::class);

```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stefan R.](https://github.com/teraone)
- [Tyler Trushin](https://github.com/ttrushin)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Support Spatie
--------------

[](#support-spatie)

[![](https://camo.githubusercontent.com/cc68ecf382fd37767edfdd3861848840ec61be75824bbf6a3c0588c05760870e/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d636c6f7564666c6172652d7a65726f2d74727573742d6d6964646c65776172652e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-cloudflare-zero-trust-middleware)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance49

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~154 days

Recently: every ~193 days

Total

6

Last Release

477d ago

Major Versions

0.1 → 1.02023-02-01

PHP version history (3 changes)0.1PHP ^8.1

1.2PHP ^8.2

1.3PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/34bb3ed24e78987d5f89cff121c51fd55070a90f2887eba16583a78cb77acb50?d=identicon)[teraone](/maintainers/teraone)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![pk-informatics](https://avatars.githubusercontent.com/u/1331770?v=4)](https://github.com/pk-informatics "pk-informatics (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")[![rechl](https://avatars.githubusercontent.com/u/3943836?v=4)](https://github.com/rechl "rechl (4 commits)")[![ttrushin](https://avatars.githubusercontent.com/u/10791881?v=4)](https://github.com/ttrushin "ttrushin (4 commits)")

---

Tags

laravelcloudflareteraonelaravel-cloudflare-zero-trust-middlewarecloudflare zero trustcloudflare access

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/teraone-laravel-cloudflare-zero-trust-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/teraone-laravel-cloudflare-zero-trust-middleware/health.svg)](https://phpackages.com/packages/teraone-laravel-cloudflare-zero-trust-middleware)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M167](/packages/spatie-laravel-health)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[nativephp/mobile

NativePHP for Mobile

1.1k75.1k97](/packages/nativephp-mobile)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
