Download the PHP package jimbojsb/laravel-cloudflare-access without Composer
On this page you can find all versions of the php package jimbojsb/laravel-cloudflare-access. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jimbojsb/laravel-cloudflare-access
More information about jimbojsb/laravel-cloudflare-access
Files in jimbojsb/laravel-cloudflare-access
Package laravel-cloudflare-access
Short Description Laravel authentication and authorization via Cloudflare Access
License MIT
Informations about the package laravel-cloudflare-access
Cloudflare Access for Laravel
Authentication via Cloudflare Access JWT validation for Laravel.
Requirements
- PHP 8.3+
- Laravel 11.0+ or 12.0+
Installation
Publish Configuration
Publish Migration (Optional)
The migration creates a users table with id, name, email, groups (nullable json), and timestamps.
Configuration
Add to your .env:
CLOUDFLARE_ACCESS_SUBDOMAIN: Your team domain subdomain (e.g., if your domain isyourcompany.cloudflareaccess.com, useyourcompany)CLOUDFLARE_ACCESS_AUDIENCE: The Application Audience (AUD) Tag from Cloudflare Zero Trust dashboardCLOUDFLARE_ACCESS_POPULATE_GROUPS: Set totrueto sync groups from Cloudflare Access JWT to the user model (default:false)
User Model
Your User model needs name, email, and groups columns. Update config/cloudflare-access.php if using a different model:
Ensure your model casts groups as an array:
Usage
Add Login Route
Register the login route in your routes/web.php:
Authentication Flow
- User visits your app behind Cloudflare Access
- Cloudflare Access sends a JWT in the
Cf-Access-Jwt-Assertionheader - The package validates the JWT against Cloudflare's public keys
- A user is created or updated with name, email, and groups from the JWT
- The user is logged into Laravel's session
Protecting Routes
Use Laravel's built-in auth middleware:
Local Development
For local development without Cloudflare Access, create a user.json file in your project root:
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
License
MIT License. See LICENSE.