developer-unijaya / rms-spid
eRMS-SPID Packages (API + SSO)
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 1 056
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- spatie/laravel-package-tools: ^1.11.0
Requires (Dev)
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
README
Requirements
- PHP ^8.0
- Laravel ^8.0
- Laravel Sanctum
Installation
You can install the package via composer:
composer require developer-unijaya/rms-spid
Publish and run the migrations with:
php artisan vendor:publish --tag="rms-spid-migrations"
php artisan migrate
Publish the views file with:
php artisan vendor:publish --tag="RmsSpidView-views"
Publish the config file with:
php artisan vendor:publish --tag="rms-spid-config"
Add the following SPID_* variables in .env
SPID_BASE_URL=
SPID_USERNAME=
SPID_PASSWORD=
SPID_SUBSYSTEM=
SPID_KEY=
SPID_ENC_KEY=
SPID_LOG=true
The above SPID_* config value will be provided by SPID later.
Add following route to VerifyCsrfToken Exception in App\Http\Middleware\VerifyCsrfToken.php
class VerifyCsrfToken extends Middleware { protected $except = [ "spid/*" ]; }
Check and Locate your Auth Provider User Model config\auth.php
'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, // <= Your Auth Provider User Model ], ],
Add Laravel Sanctum HasApiTokens Trait to your Auth Provider User Model
use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { use HasApiTokens; }
You can add HasUserSpid Trait to your Auth Provider User Model
use DeveloperUnijaya\RmsSpid\Traits\HasUserSpid; class User extends Authenticatable { use HasUserSpid; }
Add VerifySpidKey Middleware in $routeMiddleware at App\Http\Kernel.php You can optionally Enable or Disable the middleware on the published Config File in spid_key property
protected $routeMiddleware = [ // ... 'verifyspidkey' => \DeveloperUnijaya\RmsSpid\Middleware\VerifySpidKey::class, ];
Usage
Register new User to SPID: Add following code to App\Http\Controllers\Auth\RegisterController.php
use Illuminate\Http\Request; use DeveloperUnijaya\RmsSpid\Helpers\SpidHelper; public function registered(Request $request, $user) { SpidHelper::regUserSpid($user->id); }
Update user Registration Status:
use DeveloperUnijaya\RmsSpid\Helpers\SpidHelper; // Using SpidHelper // Approve SpidHelper::updateRegStatus($user_id, true); // Reject SpidHelper::updateRegStatus($user_id, false); // Using Trait // Approve $user->approveSpidReg(); // Reject $user->rejectSpidReg();
Delete user:
use DeveloperUnijaya\RmsSpid\Helpers\SpidHelper; // Using SpidHelper SpidHelper::deleteUserSpid($user_id);
Commands:
To clear all log datas:
php artisan spid:clear-log
To clear all expired redirect token:
php artisan spid:reset-expired-token
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.