定制 mbvanderleest/cfx-laravel-auth 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mbvanderleest/cfx-laravel-auth

最新稳定版本:1.0.1

Composer 安装命令:

composer require mbvanderleest/cfx-laravel-auth

包简介

CFX.re OAuth provider for Laravel Socialite

README 文档

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

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-13