esanj/managers

The **Manager** package is responsible for handling OAuth2-based authentication and managing admin-level permissions.

v0.2.1 2025-07-26 08:53 UTC

This package is auto-updated.

Last update: 2025-07-29 06:34:48 UTC


README

Latest Version License

πŸ” 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.