mbvanderleest / cfx-laravel-auth
CFX.re OAuth provider for Laravel Socialite
Package info
github.com/mbvanderleest/laravel-12-cfx-login
pkg:composer/mbvanderleest/cfx-laravel-auth
dev-main
2025-12-29 14:20 UTC
Requires
- php: ^8.2
- ext-json: *
- ext-openssl: *
- laravel/framework: ^12.0
- laravel/socialite: ^5.5
- phpseclib/phpseclib: ^3.0
This package is auto-updated.
Last update: 2026-03-29 01:13:44 UTC
README
A simple Laravel 12 package for logging in with CFX.re (FiveM/RedM) using Socialite.
Requirements
- PHP 8.2+
- Laravel 12.x
- Laravel Socialite 5.5+
Installation
composer require mbvanderleest/cfx-laravel-auth php artisan cfx:generate-keys
Add this to your .env:
CFX_APP_NAME="My App" CFX_CLIENT_ID=your_client_id CFX_REDIRECT_URL=http://your-domain.com/auth/cfx/callback CFX_AVATAR_SIZE=128
Basic Setup
Add these routes in routes/web.php:
use Laravel\Socialite\Facades\Socialite; Route::get('/auth/cfx', fn() => Socialite::driver('cfx')->redirect()); Route::get('/auth/cfx/callback', function () { $user = Socialite::driver('cfx')->user(); return $user; // $user->getId(), $user->getNickname(), etc. });
Optional Controller
class AuthController extends Controller { public function redirectToCfx() { return Socialite::driver('cfx')->redirect(); } public function handleCfxCallback() { $cfx = Socialite::driver('cfx')->user(); $user = User::firstOrCreate(['cfx_id' => $cfx->getId()], [ 'name' => $cfx->getNickname(), 'email' => $cfx->getEmail(), 'avatar' => $cfx->getAvatar(), ]); auth()->login($user); return redirect('/dashboard'); } }
Notes
- Keep your private key safe
- HTTPS is required in production
- Email may not always be available
License
MIT License