keenops/auth-client
最新稳定版本:1.0.1
Composer 安装命令:
composer require keenops/auth-client
包简介
OAuth2 SSO client SDK for integrating Laravel applications with the Central Authentication Server
README 文档
README
OAuth2 SSO client SDK for integrating Laravel applications with the Central Authentication Server.
Installation
Install via Composer:
composer require keenops/auth-client
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=auth-client-config
Add the following environment variables to your .env file:
AUTH_SERVER_URL=https://your-auth-server.com AUTH_CLIENT_ID=your-client-id AUTH_CLIENT_SECRET=your-client-secret AUTH_REDIRECT_URI=https://your-app.com/auth/callback AUTH_SCOPES=read-user AUTH_BACKCHANNEL_LOGOUT_SECRET=your-backchannel-secret
Usage
SSO Authentication
The package automatically registers the following routes:
GET /auth/redirect- Redirect to auth server for loginGET /auth/callback- Handle callback from auth serverPOST /auth/logout- Logout and revoke tokenPOST /auth/backchannel-logout- Backchannel logout webhook
Protecting Routes
Use the provided middleware to protect routes:
// Require authentication Route::middleware('auth.server')->group(function () { Route::get('/dashboard', DashboardController::class); }); // Require specific permissions Route::middleware(['auth.server', 'server.permission:manage_users'])->group(function () { Route::get('/admin/users', UserController::class); });
Accessing the Authenticated User
use Illuminate\Support\Facades\Auth; $user = Auth::guard('auth-server')->user(); // Check roles if ($user->hasRole('admin')) { // ... } // Check permissions if ($user->hasPermission('create_post')) { // ... }
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-07