upbond/laravel-auth
Composer 安装命令:
composer require upbond/laravel-auth
包简介
Laravel plugin that helps authenticate with the upbond auth service
README 文档
README
This package is inspired by Auth0
Documentation
Please see the Laravel webapp quickstart for a complete guide on how to install this in an existing project or to download a pre-configured sample project. Additional documentation on specific scenarios is below.
Setting up
$this->app->bind(
\Upbond\Auth\Login\Contract\AuthUserRepository::class,
\Upbond\Auth\Login\Repository\AuthUserRepository::class
);
Setting up a JWKs cache
In the register method of your AppServiceProvider add:
// app/Providers/AppServiceProvider.php use Illuminate\Support\Facades\Cache; // ... public function register() { // ... $this->app->bind( '\Auth\SDK\Helpers\Cache\CacheHandler', function() { static $cacheWrapper = null; if ($cacheWrapper === null) { $cache = Cache::store(); $cacheWrapper = new LaravelCacheWrapper($cache); } return $cacheWrapper; }); }
Setting up for lumen
$app->register(Upbond\Auth\Login\LoginServiceProvider::class);
Update .env for your env default to api.upbond.io
UPBOND_API_URI=api.dev.upbond.io
You can implement your own cache strategy by creating a new class that implements the Auth\SDK\Helpers\Cache\CacheHandler contract, or just use the cache strategy you want by picking that store with Cache::store('your_store_name');
Storing users in your database
You can customize the way you handle the users in your application by creating your own UserRepository. This class should implement the Auth\Login\Contract\AuthUserRepository contract. Please see the Custom User Handling section of the Laravel Quickstart for the latest example.
Using auth guard
To protect APIs using an access token generated by Auth, there is an upbond API guard provided (Laravel documentation on guards). To use this guard, add it to config/auth.php with the driver upbond:
'providers' => [
'users' => [
'driver' => 'upbond',
],
],
Once that has been added, add the guard to the middleware of any API route and check authentication during the request:
// get user
auth('upbond')->user();
// check if logged in
auth('upbond')->check();
// protect routes via middleware use
Route::group(['middleware' => 'auth:upbond'], function () {});
Route::get( '/auth/callback', '\Upbond\Auth\Login\AuthController@callback' )->name( 'auth-callback' );
env file
UPBOND_API_URI
UPBOND_AUTH_DOMAIN
UPBOND_AUTH_CLIENT_ID
UPBOND_AUTH_CLIENT_SECRET
Installation
Install this plugin into a new or existing project using Composer:
$ composer require upbond/laravel-auth
Additional steps to install can be found in the quickstart.
Contributing
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
Support + Feedback
Include information on how to get support. Consider adding:
What is Auth?
Auth helps you to easily:
- implement authentication with multiple identity providers, including social (e.g., Google, Facebook, Microsoft, LinkedIn, GitHub, Twitter, etc), or enterprise (e.g., Windows Azure AD, Google Apps, Active Directory, ADFS, SAML, etc.)
- log in users with username/password databases, passwordless, or multi-factor authentication
- link multiple user accounts together
- generate signed JSON Web Tokens to authorize your API calls and flow the user identity securely
- access demographics and analytics detailing how, when, and where users are logging in
- enrich user profiles from other data sources using customizable JavaScript rules
License
The Auth Laravel Login plugin is licensed under MIT - LICENSE
upbond/laravel-auth 适用场景与选型建议
upbond/laravel-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.91k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 08 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 upbond/laravel-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 upbond/laravel-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-05