承接 erjanmx/laravel-api-auth 相关项目开发

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

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

erjanmx/laravel-api-auth

最新稳定版本:v1.0.1

Composer 安装命令:

composer require erjanmx/laravel-api-auth

包简介

Dead simple Laravel api authorization middleware

README 文档

README

Build Status Latest Stable Version Total Downloads

Laravel Api Auth

Laravel gives easy ways to handle api authorization using user based tokens, but sometimes you need to use a single token to give access to your application, especially when you're developing two apps that need to be connected, or perhaps you're in need of connecting Telegram-bot to your app endpoint using webhooks

Laravel-api-auth makes that easy as breathe, no migrations, no models

Installing package

If you're using Laravel prior to 5.5, consider using v0.1 branch

$ composer require erjanmx/laravel-api-auth

Publish the Package configuration

$ php artisan vendor:publish --provider="Apiauth\Laravel\CAuthServiceProvider"

Using package

Step 1

Change defaults in config/apiauth.php

<?php return [ 'services' => [ 'MY_APP' => [ // this is the name of the middleware of route group to be protected 'tokenName' => 'api_token', // name of key that will be checked for secret value 'token' => env('MY_APP_TOKEN'), // secret value that is retrieved from env vars and needs to be passed in requests in order to get access to your protected urls 'allowJsonToken' => true, 'allowBearerToken' => true, 'allowRequestToken' => true, ] ], ];

Step 2

  • Add your secret value in .env file
// .env ...your other variables MY_APP_TOKEN=my-secret 

Step 3

  • Add group with middleware in your routes file
Route::group(['prefix' => 'api', 'middleware' => ['apiauth:MY_APP']], function () { // note the `MY_APP` that should match the name in your config we changed above Route::any('/', function () { return 'Welcome!'; }); });

That's it

Your urls within your group are accessible only if valid token provided

  • In GET or POST request

image image

  • In request header as Authorization Bearer (tokenName is ignored in this case)

image

  • In json raw body

image

You're free to change token name (api_token by default) in configuration file as well as authorization methods to be checked. Also you can set as many services as you want.

统计信息

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

GitHub 信息

  • Stars: 19
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固