esanj / managers
The **Manager** package is responsible for handling OAuth2-based authentication and managing admin-level permissions.
Installs: 3
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:CSS
Requires
- php: ^8.2|^8.3|^8.4
- esanj/auth-bridge: *
- firebase/php-jwt: *
- illuminate/support: ^10.0|^11.0|^12.0
README
π A simple and secure OAuth-based Manager Panel Authentication system for Laravel 12 β built with SOLID principles, and manager permission control.
β¨ Features
β
OAuth-based authentication via Accounting Bridge
β
Manager role & permission management
β
Dedicated route prefixes for panel & API
β
Web UI for managing managers
β
Admin role with full access
β
Auth & Permission middlewares
β
Artisan command to create admin managers
β
Easily publishable configs, views, assets, etc.
βοΈ Requirements
- PHP ^8.2 | ^8.3 | ^8.4
- Laravel ^10.0 | ^11.0 | ^12.0
- firebase/php-jwt *
- esanj/auth-bridge *
π Make sure all dependencies are installed via Composer.
βοΈ Installation & Setup
π₯ Step 1: Install the package
composer require esanj/ms-package-managers
π₯ Step 2: Run the installer
php artisan manager:install
π οΈ Environment Configuration
Update your .env file with the following parameters:
ACCOUNTING_BRIDGE_CLIENT_ID=your-client-id-from-accounting ACCOUNTING_BRIDGE_CLIENT_SECRET=your-client-secret-from-accounting ACCOUNTING_BRIDGE_BASE_URL=https://accounting-service.test ACCOUNTING_BRIDGE_SUCCESS_REDIRECT=https://your-app.test/oauth/success MANAGER_SUCCESS_REDIRECT=/admin/dashboard MANAGER_ACCESS_DENIED_REDIRECT=/no-permission MANAGER_PANEL_ROUTE_PREFIX=admin MANAGER_API_ROUTE_PREFIX=api/admin
π Explanation
Key Description
ACCOUNTING_BRIDGE_CLIENT_ID
Client ID from the accounting service
ACCOUNTING_BRIDGE_CLIENT_SECRET
Client Secret from the accounting service
ACCOUNTING_BRIDGE_BASE_URL
Microservice base URL
ACCOUNTING_BRIDGE_SUCCESS_REDIRECT
Redirect after successful OAuth login
MANAGER_SUCCESS_REDIRECT
Redirect after successful token validation
MANAGER_ACCESS_DENIED_REDIRECT
Redirect when manager has no permission
MANAGER_PANEL_ROUTE_PREFIX
Web route group prefix (e.g., /admin)
MANAGER_API_ROUTE_PREFIX
API route group prefix (e.g., /api/admin)
π¦ Publishable Files
You can customize the package via these publish commands:
π§ What Command
Config file: php artisan vendor:publish --tag=manager-config
Blade views: php artisan vendor:publish --tag=manager-views
Language files: php artisan vendor:publish --tag=manager-lang
Database migrations: php artisan vendor:publish --tag=manager-migrations
Front-end assets (JS/CSS): php artisan vendor:publish --tag=manager-assets
π Middlewares
Middleware Purpose
CheckAuthManagerMiddleware
Ensures a manager is authenticated
CheckManagerPermissionMiddleware
Validates managerβs permission on routes
Use these to protect your web routes and API endpoints.
π§βπ» Artisan Commands
β Create a New Manager
php artisan manager:create
This command creates a manager user with the Admin role, which includes all permissions by default.
πͺ Route Access
To access the Manager Panel UI:
route('managers.index')
This route is available after the package is installed.