jhonhuanuco-dev/security-pe
最新稳定版本:1.0.6
Composer 安装命令:
composer require jhonhuanuco-dev/security-pe
包简介
Security-pe proporciona un sistema de autenticación y seguridad para APIs simples.
关键字:
README 文档
README
- To install the package use the following command:
composer require jhonhuanuco-dev/security-pe
- Register the service provider in the
bootstrap/providers.phpfile:
return [ /* * Package Service Providers... */ Jhonhdev\SecurityPe\SecurityPeServiceProvider::class, ];
- Publish the configuration file
config/securitype.phpwith 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:
userspersonal_access_tokens
- Modify your
app/Models/User.phpmodel.
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.phpcalled default.:
return [ 'connections' => [ //... 'default' => [ //... ] ] ];
- Register the middleware of
ActivityUserRequestin thebootstrap\app.php.:
->withMiddleware(function (Middleware $middleware) { $middleware->alias([ //... 'activity' => \Jhonhdev\SecurityPe\Http\Middleware\ActivityUserRequest::class, ]); })
-
Update your configuration file
config/securitype.phpaccording 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.
统计信息
- 总下载量: 94
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-04