jhonhuanuco-dev / security-pe
Security-pe proporciona un sistema de autenticación y seguridad para APIs simples.
1.0.6
2025-07-31 21:04 UTC
Requires
- php: ^8.2
- laravel/framework: ^12.0
- laravel/sanctum: ^4.0
- spatie/laravel-permission: ^6.17
- symfony/http-foundation: ^7.2.0
README
- To install the package use the following command:
composer require jhonhuanuco-dev/security-pe
- Register the service provider in the
bootstrap/providers.php
file:
return [ /* * Package Service Providers... */ Jhonhdev\SecurityPe\SecurityPeServiceProvider::class, ];
- Publish the configuration file
config/securitype.php
with the following command:
php artisan vendor:publish --provider="Jhonhdev\SecurityPe\SecurityPeServiceProvider"
- Remove the following migrations to avoid conflicts, as Security.pe migrations will be used by default:
users
personal_access_tokens
- Modify your
app/Models/User.php
model.
namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Notifications\Notifiable; use Jhonhdev\SecurityPe\Models\Schemas\Security\Users; class User extends Users { use HasFactory, Notifiable; }
- Add a default connection string for your database in
config/database.php
called default.:
return [ 'connections' => [ //... 'default' => [ //... ] ] ];
- Register the middleware of
ActivityUserRequest
in thebootstrap\app.php
.:
->withMiddleware(function (Middleware $middleware) { $middleware->alias([ //... 'activity' => \Jhonhdev\SecurityPe\Http\Middleware\ActivityUserRequest::class, ]); })
-
Update your configuration file
config/securitype.php
according to your needs before running the migrations.. -
Execute the following command to run the migrations:
php artisan migrate
Usage
Log-in
Authenticate your application users and register the encrypted token in the database.
POST /securitype/auth/login
Parameter | Type | Description |
---|---|---|
username |
string |
Required. User name registered in the database. |
password |
string |
Required. Password of the user registered in the database. |
{ "status": true, "message": "Bienvenido John Smith", "user": { "branch_id": 1, "username": "jhsm", "name": "John", "last_name": "Smith", "email": "example@company.com", "extension": 102, "state": true }, "token": { "key": "1|iplxuLz78Ff9nS1ECDalNv2wJUFJMFVLemBOQJvz", "expired": "2024-05-16 22:30:09" } }
Log-out
Removes the session token of the authenticated user.
GET /securitype/auth/logout
Parameter | Type | Description |
---|---|---|
Bearer |
string |
Automatic. Bearer token |
{ "status": true, "message": "Hasta pronto.", }
Validate Token.
Validate if the token is valid and/or has not expired. The user must be authenticated and the bearer token must be included in the request header.
POST /securitype/auth/validatetoken
Parameter | Type | Description |
---|---|---|
Bearer |
string |
Automatic. Bearer token |
{ "status": true, "message": "Ok.", }
Authors
License
Security.pe is open-sourced software licensed under the MIT license.