node-link/cakephp-remember-me
Composer 安装命令:
composer require node-link/cakephp-remember-me
包简介
CakePHP plugin that performs Remember-me authentication with the new cookie algorithm of version 3.5 or later
README 文档
README
CakePHP plugin that performs Remember-me authentication with the new cookie algorithm of version 3.5 or later.
Requirements
- CakePHP 3.5 or later
- PHP 5.6 or later
Installation
1. Install plugin
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require node-link/cakephp-remember-me
2. Load plugin
Please load the plugin manually as follows:
<?php // In src/Application.php. Requires at least 3.6.0 use Cake\Http\BaseApplication; class Application extends BaseApplication { public function bootstrap() { parent::bootstrap(); // Load the plugin $this->addPlugin('NodeLink/RememberMe'); } }
Prior to 3.6.0, you should use Plugin::load():
<?php // In config/bootstrap.php use Cake\Core\Plugin; Plugin::load('NodeLink/RememberMe', ['bootstrap' => true]);
Or, use bin/cake to load the plugin as follows:
bin/cake plugin load -b NodeLink/RememberMe
3. Set up AuthComponent
In the AppController.php of your application, set up AuthComponent.
<?php namespace App\Controller; use Cake\Controller\Controller; class AppController extends Controller { public function initialize() { parent::initialize(); $this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'userModel' => 'Users', 'fields' => ['username' => 'username', 'password' => 'password'], ], 'NodeLink/RememberMe.Cookie' => [ 'userModel' => 'Users', // Please set the same as 'Form'. 'fields' => ['token' => 'remember_token'], // Specify the column where you want to save the token for Remember-me authentication. ], ], ]); // ... } }
4. Updating database and models
Please update database and models as necessary.
ALTER TABLE `users` ADD `remember_token` VARCHAR(64) NULL DEFAULT NULL;
<?php namespace App\Model\Entity; use Cake\ORM\Entity; class User extends Entity { protected $_hidden = [ 'password', 'remember_token', // Add ]; }
5. Edit login template
Add the following to your login template:
<?= $this->Form->control('remember_me', ['type' => 'checkbox', 'label' => __('Remember me')]); ?> Or <?= $this->Form->checkbox('remember_me'); ?> <?= $this->Form->label('remember_me', __('Remember me')); ?>
Configuration
Edit config/.env or config/app.php.
The full default configuration is as follows:
<?php return [ 'Security' => [ 'cookieKey' => env('SECURITY_COOKIE_KEY', env('SECURITY_SALT', '__SALT__')), ], 'RememberMe' => [ 'field' => 'remember_me', 'cookie' => [ 'name' => 'remember_me', 'expires' => '+1 year', 'path' => '', 'domain' => '', 'secure' => false, 'httpOnly' => true, ], ], ];
It is recommended to set random string to SECURITY_COOKIE_KEY of config/.env, or 'Security.cookieKey' of config/app.php.
Reporting Issues
If you have a problem with the RememberMe plugin, please send a pull request or open an issue on GitHub.
Also, I would appreciate it if you contribute to updating README.md file.
node-link/cakephp-remember-me 适用场景与选型建议
node-link/cakephp-remember-me 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34.81k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 09 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「Authentication」 「cakephp」 「cookie」 「authenticate」 「remember」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 node-link/cakephp-remember-me 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 node-link/cakephp-remember-me 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 node-link/cakephp-remember-me 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Provide a way to secure accesses to all routes of an symfony application.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
It's a barebone security class written on PHP
统计信息
- 总下载量: 34.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-27