keenops/auth-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

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 login
  • GET /auth/callback - Handle callback from auth server
  • POST /auth/logout - Logout and revoke token
  • POST /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
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-07