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

This package is auto-updated.

Last update: 2025-08-31 21:19:43 UTC


README

  1. To install the package use the following command:
  composer require jhonhuanuco-dev/security-pe
  1. Register the service provider in the bootstrap/providers.php file:
return [
  /*
    * Package Service Providers...
    */

  Jhonhdev\SecurityPe\SecurityPeServiceProvider::class,
];
  1. Publish the configuration file config/securitype.php with the following command:
  php artisan vendor:publish --provider="Jhonhdev\SecurityPe\SecurityPeServiceProvider"
  1. Remove the following migrations to avoid conflicts, as Security.pe migrations will be used by default:
  • users
  • personal_access_tokens
  1. 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;
}
  1. Add a default connection string for your database in config/database.php called default.:
return [
  'connections' => [
    //...

    'default' => [
      //...
    ]
  ]
];
  1. Register the middleware of ActivityUserRequest in the bootstrap\app.php.:
->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        //...
        'activity' => \Jhonhdev\SecurityPe\Http\Middleware\ActivityUserRequest::class,
    ]);
})
  1. Update your configuration file config/securitype.php according to your needs before running the migrations..

  2. 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.