PHPackages                             jimbojsb/laravel-cloudflare-access - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. jimbojsb/laravel-cloudflare-access

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

jimbojsb/laravel-cloudflare-access
==================================

Laravel authentication and authorization via Cloudflare Access

v0.2.1(1mo ago)072↓52.4%MITPHPPHP ^8.3CI passing

Since Dec 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/jimbojsb/laravel-cloudflare-access)[ Packagist](https://packagist.org/packages/jimbojsb/laravel-cloudflare-access)[ RSS](/packages/jimbojsb-laravel-cloudflare-access/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (7)Used By (0)

Cloudflare Access for Laravel
=============================

[](#cloudflare-access-for-laravel)

Authentication via Cloudflare Access JWT validation for Laravel.

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11.0+ or 12.0+

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

[](#installation)

```
composer require jimbojsb/cloudflare-access-laravel
```

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --tag=cloudflare-access-config
```

### Publish Migration (Optional)

[](#publish-migration-optional)

```
php artisan vendor:publish --tag=cloudflare-access-migrations
php artisan migrate
```

The migration creates a `users` table with `id`, `name`, `email`, `groups` (nullable json), and timestamps.

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

[](#configuration)

Add to your `.env`:

```
CLOUDFLARE_ACCESS_SUBDOMAIN=yourcompany
CLOUDFLARE_ACCESS_AUDIENCE=your-application-audience-tag
CLOUDFLARE_ACCESS_POPULATE_GROUPS=false
```

- `CLOUDFLARE_ACCESS_SUBDOMAIN`: Your team domain subdomain (e.g., if your domain is `yourcompany.cloudflareaccess.com`, use `yourcompany`)
- `CLOUDFLARE_ACCESS_AUDIENCE`: The Application Audience (AUD) Tag from Cloudflare Zero Trust dashboard
- `CLOUDFLARE_ACCESS_POPULATE_GROUPS`: Set to `true` to sync groups from Cloudflare Access JWT to the user model (default: `false`)

### User Model

[](#user-model)

Your User model needs `name`, `email`, and `groups` columns. Update `config/cloudflare-access.php` if using a different model:

```
'user_model' => App\Models\User::class,
```

Ensure your model casts groups as an array:

```
protected $casts = [
    'groups' => 'array',
];
```

Usage
-----

[](#usage)

### Add Login Route

[](#add-login-route)

Register the login route in your `routes/web.php`:

```
use Jimbojsb\CloudflareAccess\Http\Controllers\LoginController;

Route::get('/login', [LoginController::class, 'login']);
```

### Authentication Flow

[](#authentication-flow)

1. User visits your app behind Cloudflare Access
2. Cloudflare Access sends a JWT in the `Cf-Access-Jwt-Assertion` header
3. The package validates the JWT against Cloudflare's public keys
4. A user is created or updated with name, email, and groups from the JWT
5. The user is logged into Laravel's session

### Protecting Routes

[](#protecting-routes)

Use Laravel's built-in `auth` middleware:

```
Route::middleware('auth')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index']);
});
```

### Local Development

[](#local-development)

For local development without Cloudflare Access, create a `user.json` file in your project root:

```
{
    "name": "Local Developer",
    "email": "dev@example.com",
    "groups": ["admin"]
}
```

This only works when `APP_ENV` is not `production`. Note that groups will only be populated if `CLOUDFLARE_ACCESS_POPULATE_GROUPS` is set to `true`. For safety, you should add this file to your .gitinore.

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE).

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~22 days

Recently: every ~28 days

Total

6

Last Release

42d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fff234ab9d8ee835e721f4594a9c6521ec0f244bfbd7e700a0d8902e5f22ed1e?d=identicon)[jimbojsb](/maintainers/jimbojsb)

---

Top Contributors

[![jimbojsb](https://avatars.githubusercontent.com/u/107836?v=4)](https://github.com/jimbojsb "jimbojsb (12 commits)")

---

Tags

jwtlaravelAuthenticationaccesscloudflare

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/jimbojsb-laravel-cloudflare-access/health.svg)

```
[![Health](https://phpackages.com/badges/jimbojsb-laravel-cloudflare-access/health.svg)](https://phpackages.com/packages/jimbojsb-laravel-cloudflare-access)
```

###  Alternatives

[benbjurstrom/cognito-jwt-guard

A laravel auth guard for JSON Web Tokens issued by Amazon AWS Cognito

1113.1k](/packages/benbjurstrom-cognito-jwt-guard)

PHPackages © 2026

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