restricted/authchain
Composer 安装命令:
composer require restricted/authchain
包简介
Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)
README 文档
README
WARNING: Project no longer maintaned!
Supports native database, LDAP, IMAP and IP address multi-domain authentication for single sign-on.
For LDAP and IMAP authentication you need to have ldap and imap php extensions.
Installation
Installing this package through Composer. Edit your project's composer.json file to require restricted/authchain.
"require": {
"laravel/framework": "4.2.*",
"restricted/authchain": ">=1.0.6"
}
Update Composer from the Terminal:
composer update
Once this operation completes, the next step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.
'providers' => [ // Your Laravel providers here... 'Restricted\Authchain\AuthchainServiceProvider' ]
Create example configuration file from terminal:
php artisan config:publish restricted/authchain
Change default authentication provider to authchain.
Open app/config/auth.php and change driver section to authchain.
return array(
'driver': 'authchain'
// Related stuff...
);
Please see app/config/packages/restricted/authchain/config.php for full configuration instructions.
You need to create User model in app/models and create migration.
For details on models and migrations you can see vendor/restricted/authchain/quickstart
You can simply copy contents of folder vendor/restricted/authchain/quickstart/models/ to app/models.
Example migration can be executed by command
php artisan migrate --package="restricted/authchain".
NOTE: migration does`t include timestamps.
If you don't use ip address authentication, set ['defaults']['ip'] to false in app/config/packages/restricted/authchain/config.php.
Quickstart
Install laravel (see http://laravel.com/docs/quick)
composer create-project laravel/laravel your-project-name --prefer-dist
Install authchain provider (see Installation)
Configure your domains in app/config/packages/restricted/authchain/config.php
Copy files from
cp -r vendor/restricted/authchain/quickstart/models/* app/models
cp -r vendor/restricted/authchain/quickstart/controllers/* app/controllers/
cp -r vendor/restricted/authchain/quickstart/views/* app/views
Replace auth route filter in your file app/filters.php with contents from vendor/restricted/authchain/quickstart/filters.php
cat vendor/restricted/authchain/quickstart/filters.php >> app/filters.php
Add to your app/routes.php contents from vendor/restricted/authchain/quickstart/routes.php
cat vendor/restricted/authchain/quickstart/routes.php >> app/routes.php
Serve your application from terminal: php artisan serve
Go to http://localhost:8000/ and enjoy!
Need community feedback
- Need to implement oAuth2 ?
- Other providers?
Contribute
Any suggestions are welcome
You can easily write your own authentication provider for authchain:
Custom provider example (see in src/Restricted/Authchain/Provider/Domain/CustomProviderExample):
namespace Restricted\Authchain\Provider\Domain; use Restricted\Authchain\Config\Loader; use Restricted\Authchain\Provider\Provider; use Restricted\Authchain\Provider\ProviderInterface; class CustomProviderExample extends Provider implements ProviderInterface { // Authentication logic // $this->username is username provided by user // $this->password is password from form // @return UserInterface|null public function authenticate() { // Loading users from config for domain $this->domain $users = Loader::domain($this->domain)['users']; // If user not found in array, return null if (!isset($users[$this->username])) { return null; } // Grab user password from config $password = $users[$this->username]; // Check password if (\Hash::check($this->password, $password)) { $newUser = $this->model(); $newUser->{Loader::username()} = $this->username; $newUser->{Loader::password()} = \Hash::make($password); $newUser->enabled = true; $newUser->save(); return $newUser; } return null; } // Must return name of the provider, for example 'custom' // In app/config/packages/restricted/authchain/config.php // you can regiter new provider in 'providers' array and pass config variables to it public function provides() { return 'custom'; } }
Create config for custom provider in app/config/packages/restricted/authchain/config.php:
Register custom provider in section providers:
'providers' => array(
// ...
'Restricted\Authchain\Provider\Domain\CustomProviderExample',
)
In section domains:
'localhost' => array(
'provider' => 'custom', // See method provides()
'users' => array(
'demo@localhost' => '$2y$10$/Ij0dzDL49OaODli.1GcveefSdEapt2vgb8shplVI7RIJadPmL6km' // Encrypted password
)
)
Now, all users with domain localhost authenticates over custom provider and native provider (Eloquent).
- For questions, create issue with your question.
- For request features, create issue with detailed explanation of a feature.
License
Distributed under the terms of the MIT license.
restricted/authchain 适用场景与选型建议
restricted/authchain 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 100 次下载、GitHub Stars 达 5, 最近一次更新时间为 2013 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「Authentication」 「ldap」 「auth」 「imap」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 restricted/authchain 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 restricted/authchain 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 restricted/authchain 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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.
LDAP user provider bundle for Symfony 6.4
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
统计信息
- 总下载量: 100
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-12-06