randohinn/userfile
Composer 安装命令:
composer require randohinn/userfile
包简介
Adds file-based user login functionality to Laravel's Auth flow.
README 文档
README
UNMAINTAINED AND OF UNKNOWN WORKING STATUS
Userfile is a Laravel package that allows storing user data in yaml files. It also supports Bearer type API authentication.
Usage
Installation
Generate Laravel's default auth scafffolding. php artisan make:auth.
You can install the package by running
composer require randohinn/userfile
Laravel will auto-detect and register the neccessary provider and auth configuration.
Next, run
php artisan vendor:publish
This will create a config/userfile.php file in your app.
Setup
Userfile uses the default Laravel user model. Therefore, it is necessary to make these changes to the model.
Add public $incrementing = false; to the model. This enables the use of string-based uuids, that Userfile generates for your users.
Add id and api_token to the $fillable array of the model. This allows the package to populate those fields on your model instances. It is in this array where you will later define any custom fields you would like to store in the user file.
Configuration
By default, Userfile expects to find a userfile folder in your storage folder. You can change this, by creating a custom filesystem disk in the filyesystem config, and editing config/userfile.php to state the name of the new disk, instead of userfile. In this file, you can also define a subfolder or your user files, if that is what you want.
The last part, is to set your config/auth.php to contain 'guard' => 'userfile', instead of the default 'guard' => 'web'. You may the delete unnecessary auth controllers.
Creating users
Userfile expects to find files in your configured disk's configured subfolder. Filenames go by the standard of user-email.yaml. For example rando@randohinn.com.yaml.
At the bare minimum, when creating a new user file, it needs to contin the user's email, name and password (in plaintext). The password will be encrypted on first log-in!
For example:
name: 'Rando Hinn' email: rando@randohinn.com password: qwerty
After you log in with the first user, for the first time, several things will happen:
- The user will be generated a uuid and an api key
- The user's password will be encryped and the encrypted hash stored instead of plaintext
- An
id_mapping.yamlandapi_mapping.yamlfile will be created next to the user file. These files hold the mapping of id's and API tokens back to user e-mails, to facilitate faster lookups, and should not be deleted.
As a result, your user file may look something like this:
name: 'Rando Hinn' email: rando@randohinn.com password: $2y$10$RHOsWnmZjAQ2o1fceqZ.Nu.Isa6XBIdFAXmEGlb7SZEWfU/cfTScq id: fb4ac678-0802-473b-be64-dcba94b40e8a api_token: UmikrAAteG8KWneIREBnp4sQRCbA0HDFjWAUsrQ59m5e5b6RWtS72uQzdiQT
Should you want to add any fields, just add them to this file, and define them in the model's $fillable array, like you normally would.
License
The MIT License. See License.md for more information.
Contributing
All contributions welcome. Before you start working on something, please create an issue for it.
If you find a security-related bug, please write directly to rando@randohinn.com . Do not create a GitHub issue!
randohinn/userfile 适用场景与选型建议
randohinn/userfile 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 07 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 randohinn/userfile 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 randohinn/userfile 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-29