承接 coolcode/authapi 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

coolcode/authapi

最新稳定版本:v1.0.0

Composer 安装命令:

composer require coolcode/authapi

包简介

api authentication using sanctum

README 文档

README

coolcode/authapi is a Laravel package that simplifies API authentication using Laravel Sanctum. This package provides a set of endpoints for user registration, login, and logout functionality with token-based authentication.

Installation

  1. Install the package via Composer:

    composer require coolcode/authapi
  2. Publish the Sanctum migrations:

    php artisan vendor:publish --tag=sanctum-migrations
  3. Run the migrations:

    php artisan migrate
  4. Finally, issue your Laravel Sanctum tokens when users authenticate with your API.

API Endpoints

1. Register

Endpoint: /api/register
Method: POST
Headers:

  • Accept: application/json
  • Content-Type: application/json

Request Body (form-data):

Key Value Type
name test text
email test@gmail.com text
password password text
confirm_password password text

Description:
Registers a new user in the system.

2. Login

Endpoint: /api/login
Method: POST
Headers:

  • Accept: application/json
  • Content-Type: application/json

Request Body (form-data):

Key Value Type
email test@gmail.com text
password password text

Description:
Authenticates the user and issues a Bearer token for future API requests. The token is stored in the environment variable token.

3. Logout

Endpoint: /api/logout
Method: POST
Headers:

  • Accept: application/json
  • Content-Type: application/json
  • Authorization: Bearer {{token}}

Description:
Logs the authenticated user out and invalidates the Bearer token.

Usage

Once you've installed the package and set it up, you can use these endpoints in your Postman collection or any API client to handle user authentication.

Postman Example

  1. Register a user using the Register API.
  2. Login using the Login API to get the Bearer token.
  3. Set the token in your environment variables for future authenticated requests.
  4. Logout the user using the Logout API.

License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-18