承接 elzdave/benevolent 相关项目开发

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

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

elzdave/benevolent

Composer 安装命令:

composer require elzdave/benevolent

包简介

A custom user provider to authenticate users to REST API within Laravel framework.

README 文档

README

Latest Version on Packagist Total Downloads Build Status StyleCI

Use Case

Imagine you built a Laravel-powered website, which needs to communicates to your external API server using REST API. Some of the HTTP requests needs to be authenticated by including access token to the Authorization header. To get the access token, you first authenticate the user to the API server, and then the server return the access token and user data in exchange. You store the access token to use it on every authenticated HTTP requests. All is well until you realize, that default Laravel authentication middleware cannot authenticate user to another server leveraging REST API, and you need to write new authentication logics to cover those requirements...

That's why this package exist. Just install this package, set the config, and you all done!

Installation

Laravel

Require this package in the project.

$ composer require elzdave/benevolent

Publish the config after installation.

$ php artisan vendor:publish --tag=benevolent-config

Usage

User Authentication

  1. At the config/auth.php, change the provider entry on guards.web to benevolent
  2. Add the new entry on .env and .env.example, change <your-external-API-base-URI> to your authentication server's base URI, eg: https://server.api/v1
EXT_API_BASE_URI=<your-external-API-base-URI>
  1. Optional: adjust some settings to suit your API server design at config/benevolent.php

Making Authenticated HTTP Request using Authorization header

If you want to make authenticated HTTP requests using the user's access token, use the Elzdave\Benevolent\Http\Http facade with useAuth() method

<?php

use Elzdave\Benevolent\Http\Http;

$data = [
    'data' => 'some-data-to-store'
];

$apiRelativeUrl = 'path/relative/to/base-uri';
$apiResponse = Http::useAuth()->post($apiRelativeUrl, $data);

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email the author instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固