blaspsoft/keysmith-vue
Composer 安装命令:
composer require blaspsoft/keysmith-vue
包简介
A Vue & Inertia-powered API key management system for Laravel 12 Vue Starterkit, with secure token generation, revocation, and authentication.
关键字:
README 文档
README
Keysmith Vue - Laravel 12 Vue Starterkit API Token Management
Keysmith Vue is a Laravel 12 Vue Starterkit package that provides Vue.js components for managing API keys and tokens in your application. It offers a clean, user-friendly interface for creating, viewing, and revoking API keys with customizable permissions based on the implementation from Laravel Breeze.
Features
- 🔑 Easy API token generation and management
- 🔒 Built on Laravel Sanctum's secure token authentication
- 🎨 Pre-built Vue components for quick integration
- 📱 Responsive and user-friendly interface
- ⚙️ Flexible installation options (page or settings templates)
- 🛠️ Customizable permissions system
Requirements
- PHP 8.2 or higher
- Laravel 12.x
- Vue 3.x
- Laravel Sanctum
Installation
You can install the package via composer:
composer require blaspsoft/keysmith-vue
Choose your preferred installation template:
Page Template
Install this option to add a dedicated API tokens page at pages/api-tokens/index.vue. This provides a standalone interface for managing your API tokens.
Settings Template
Choose this option to integrate API token management within your Laravel Vue Starterkit settings at pages/settings/APITokens.vue. This keeps token management alongside your other application settings.
Run one (or both) of the following commands based on your choice:
php artisan keysmith:install page
or
php artisan keysmith:install settings
Configure Inertia Middleware
Add the following to your HandleInertiaRequests.php middleware's share method to handle API token flash messages:
'flash' => [ 'api_token' => fn () => session()->get('api_token'), ],
public function share(Request $request): array { [$message, $author] = str(Inspiring::quotes()->random())->explode('-'); return [ ...parent::share($request), 'name' => config('app.name'), 'quote' => ['message' => trim($message), 'author' => trim($author)], 'auth' => [ 'user' => $request->user(), ], 'flash' => [ 'api_token' => fn () => session()->get('api_token'), ], ]; }
This configuration is required to display newly created API tokens to users.
Add navlinks to starterkit templates
Dependent of which template you decide to use 'page" or "settings" (or both). You may want to add links to the app sidebar and settings navigations.
For the page update js/components/AppSidebar.vue
const mainNavItems: NavItem[] = [ { title: "Dashboard", href: "/dashboard", icon: LayoutGrid, }, { title: "API Tokens", href: "/api-tokens", icon: KeyRound, }, ];
For the settings update js/layouts/settings/Layout.vue
const sidebarNavItems: NavItem[] = [ { title: "Profile", href: "/settings/profile", }, { title: "Password", href: "/settings/password", }, { title: "Appearance", href: "/settings/appearance", }, { title: "API Tokens", href: "/settings/api-tokens", }, ];
Publish config [optional]
php artisan vendor:publish --tag=keysmith-vue-config --force
This command will publish a configuration file at config/keysmith.php, where you can customize keysmith settings.
Dependencies
This package requires Laravel Sanctum for API token authentication. Before using Keysmith Vue, make sure to:
- Install Laravel Sanctum:
composer require laravel/sanctum
- Publish and run Sanctum's migrations:
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider" --tag="sanctum-migrations" php artisan migrate
- Add the HasApiTokens trait to your User model:
use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { use HasApiTokens; // ... existing code ... }
Components
Keysmith Vue provides two components that are installed in your /components directory:
CreateApiTokenForm.vue: Form component for generating new API tokensManageApiTokens.vue: Component for viewing and managing existing tokens
These components are utilized in both the page and settings templates.
Routes
Keysmith Vue provides two sets of routes depending on your installation choice:
Page Template Routes
If you installed using the page template (keysmith:install page), these routes are available:
Route::get('/api-tokens', [TokenController::class, 'index'])->name('api-tokens.index'); Route::post('/api-tokens', [TokenController::class, 'store'])->name('api-tokens.store'); Route::put('/api-tokens/{token}', [TokenController::class, 'update'])->name('api-tokens.update'); Route::delete('/api-tokens/{token}', [TokenController::class, 'destroy'])->name('api-tokens.destroy');
Settings Template Routes
If you installed using the settings template (keysmith:install settings), these routes are available:
Route::get('/settings/api-tokens', [TokenController::class, 'index'])->name('settings.api-tokens.index'); Route::post('/settings/api-tokens', [TokenController::class, 'store'])->name('settings.api-tokens.store'); Route::put('/settings/api-tokens/{token}', [TokenController::class, 'update'])->name('settings.api-tokens.update'); Route::delete('/settings/api-tokens/{token}', [TokenController::class, 'destroy'])->name('settings.api-tokens.destroy');
All routes are protected by authentication middleware and handle the following operations:
GET: Retrieve all tokens for the authenticated userPOST: Create a new API tokenPUT: Update token permissionsDELETE: Revoke an existing token
Testing
Keysmith Vue includes test files that are placed in your project's tests/Feature/ApiToken directory:
PageTokenTest.php: Tests for the page template implementationSettingsTokenTest.php: Tests for the settings template implementation
You can run the tests using:
php artisan test
Customizing Permissions
You can customize the available token permissions by modifying the config/keysmith.php file:
return [ 'permissions' => [ 'read', 'create', 'update', 'delete', // Add your custom permissions here ], ];
Screenshots
Security
If you discover any security related issues, please email mike.deeming@blaspsoft.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
blaspsoft/keysmith-vue 适用场景与选型建议
blaspsoft/keysmith-vue 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 244 次下载、GitHub Stars 达 31, 最近一次更新时间为 2025 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「blaspsoft」 「keysmith-vue」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 blaspsoft/keysmith-vue 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 blaspsoft/keysmith-vue 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 blaspsoft/keysmith-vue 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Blasp is a powerful and customisable profanity filter package for Laravel applications
Onym is a lightweight Laravel package designed to generate unique, structured, and meaningful filenames effortlessly.
Doxswap is a simple document conversion package for Laravel which uses LibreOffice to convert documents to a variety of formats.
SocialitePlus is a Laravel package that simplifies social authentication by extending Laravel Socialite. It provides predefined Google, Facebook, GitHub, and LinkedIn login options for seamless integration into Laravel 12 Vue and React Starter Kits
Token Forge brings Laravel Jetstream token management over to Laravel Breeze
A React & Inertia-powered API key management system for Laravel 12 React Starterkit, with secure token generation, revocation, and authentication.
统计信息
- 总下载量: 244
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 36
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-01