antarctica/laravel-token-auth
Composer 安装命令:
composer require antarctica/laravel-token-auth
包简介
Enables use of API tokens as a form of stateless authentication within Laravel
README 文档
README
Enables use of API tokens as a form of stateless authentication within Laravel.
This package is designed not to rely on any particular Token or Token Blacklist implementation, however by default the tymondesigns/jwt-auth package is used to provide a JWT based Token implementation and the antarctica/laravel-token-blacklist package is used to provided a default Token Blacklist implementation.
It is possible to provide your own implementations for managing tokens and/or blacklisting them. See the custom implementations section for details.
Installing
Require this package in your composer.json file:
{
"require": {
"antarctica/laravel-token-auth": "0.1.*"
}
}
Run composer update.
Register the service provider in the providers array of your app/config/app.php file:
'providers' => array( Antarctica\LaravelTokenAuth\LaravelTokenAuthServiceProvider, )
This package uses a Repository through which users can be retrieved. There is NO default implementation for this repository included in this package. You MUST therefore provide an implementation that implements the provided interface through this package's config file.
To publish the config file run:
php artisan config:publish antarctica/laravel-token-auth
Then edit the user_repository key.
Usage
To support both standard session based and token based authentication this package provides an auth.combined filter.
To enable this filter add the following to your app/filters.php file:
/* |-------------------------------------------------------------------------- | Custom Authentication Filters |-------------------------------------------------------------------------- | | The "combined" filter is a custom filter which allows session and token | based authentication to be combined. This means a user can be authenticated | using either an active session (i.e. being logged in) or by providing a | token (i.e. using the Authorization header). | */ Route::filter('auth.combined', 'Antarctica\LaravelTokenAuth\Filter\AuthFilter');
To use the filter on a route:
Route::get('/secret', array('before' => 'auth.combined', function() { return Response::json(['message' => 'Yay you get to know the secret']); }));
Contributing
This project welcomes contributions, see CONTRIBUTING for our general policy.
Developing
To aid development and keep your local computer clean, a VM (managed by Vagrant) is used to create an isolated environment with all necessary tools/libraries available.
Requirements
- Mac OS X
- Ansible
brew install ansible - VMware Fusion
- Vagrant
brew cask install vmware-fusion vagrant - Host manager and Vagrant VMware plugins
vagrant plugin install vagrant-hostmanager && vagrant plugin install vagrant-vmware-fusion - You have a private key
id_rsaand public keyid_rsa.pubin~/.ssh/ - You have an entry like [1] in your
~/.ssh/config
[1] SSH config entry
Host bslweb-* ForwardAgent yes User app IdentityFile ~/.ssh/id_rsa Port 22
Provisioning development VM
VMs are managed using Vagrant and configured by Ansible.
$ git clone ssh://git@stash.ceh.ac.uk:7999/basweb/laravel-token-auth.git $ cp ~/.ssh/id_rsa.pub laravel-token-auth/provisioning/public_keys/ $ cd laravel-token-auth $ ./armadillo_standin.sh $ vagrant up $ ssh bslweb-laravel-token-auth-dev-node1 $ cd /app $ composer install $ logout
Committing changes
The Git flow workflow is used to manage development of this package.
Discrete changes should be made within feature branches, created from and merged back into develop (where small one-line changes may be made directly).
When ready to release a set of features/changes create a release branch from develop, update documentation as required and merge into master with a tagged, semantic version (e.g. v1.2.3).
After releases the master branch should be merged with develop to restart the process. High impact bugs can be addressed in hotfix branches, created from and merged into master directly (and then into develop).
Issue tracking
Issues, bugs, improvements, questions, suggestions and other tasks related to this package are managed through the BAS Web & Applications Team Jira project (BASWEB).
Clean up
To remove the development VM:
vagrant halt vagrant destroy
The laravel-token-auth directory can then be safely deleted as normal.
License
Copyright 2015 NERC BAS. Licensed under the MIT license, see LICENSE for details.
antarctica/laravel-token-auth 适用场景与选型建议
antarctica/laravel-token-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 76 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 antarctica/laravel-token-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 antarctica/laravel-token-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 76
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 21
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-08