承接 dsdevbe/ldap-connector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dsdevbe/ldap-connector

最新稳定版本:4.0.1

Composer 安装命令:

composer require dsdevbe/ldap-connector

包简介

Easily authenticate with LDAP in Laravel

关键字:

README 文档

README

I've created this project during my internship for an easy authentication between various applications within my company. The scope of the ldap-connector was only to authenticate with Laravel to the LDAP server.

In case you're looking for a replacement please checkout Adldap2-Laravel. They have also created the awesome library Adldap2 which ldap-connector was using.

I'll stop maintaining this project but would like to thank all the people that contributed or used this project.

Ldap-connector

Build Status Latest Stable Version Total Downloads License

Provides an solution for authentication users with LDAP for Laravel 5.x. It uses ADLDAP library on Adldap2 to create a bridge between Laravel and LDAP

Installation

Laravel 5.1 - 5.0

  1. Install this package through Composer by adding the following line to composer.json

        "dsdevbe/ldap-connector": "3.0.*"

    or you could use command-line

    composer require "dsdevbe/ldap-connector:3.0.*"
  2. Add the service provider in the app configuration by opening config/app.php, and add a new item to the providers array.

    Dsdevbe\LdapConnector\LdapConnectorServiceProvider::class
    
  3. Change the authentication driver in the Laravel config to use the ldap driver. You can find this in the following file config/auth.php

    'driver' => 'ldap',
  4. Publish a new configuration file with php artisan vendor:publish in the configuration folder of Laravel you will find config/ldap.php and modify to your needs. For more detail of the configuration you can always check on ADLAP documentation

    return array(
        'plugins' => array(
            'adldap' => array(
                'account_suffix'=>  '@domain.local',
                'domain_controllers'=>  array(
                    '192.168.0.1',
                    'dc02.domain.local'
                ), // Load balancing domain controllers
                'base_dn'   =>  'DC=domain,DC=local',
                'admin_username' => 'admin', // This is required for session persistance in the application
                'admin_password' => 'yourPassword',
            ),
        ),
    );
    

    Please note that the fields 'admin_username' and 'admin_password' are required for session persistance!

Usage

The LDAP plugin is an extension of the Auth class and will act the same as normal usage with Eloquent driver.

if (Auth::attempt(array('username' => $username, 'password' => $password)))
{
    return Redirect::intended('dashboard');
}

You can find more examples on Laravel Auth Documentation on using the Auth:: function.

Use AuthController

If you want to use the authentication controller that ships with Laravel you will need to change the following files. By default App\Http\Controllers\Auth\AuthController checks for the email field if nothing is provided. To overwrite this value add the following line in the AuthController.

protected $username = 'username';

Laravel documentation: Authentication Quickstart

Ldap Groups

  • Auth::user()->getGroups() returns array with groups the current user belongs to.
  • Auth::user()->inGroup('GROUPNAME') returns boolean if user belongs to GROUPNAME

Ldap User Information

  • Auth::user()->getUsername() returns authenticated username.
  • Auth::user()->getFirstname() returns authenticated first name.
  • Auth::user()->getLastname() returns authenticated last name.
  • Auth::user()->getEmail() returns authenticated email address.

Laravel 5.2 - ...

  1. Install this package through Composer by adding the following line to composer.json

    "dsdevbe/ldap-connector": "4.0.*"

    or you could use command-line

    composer require "dsdevbe/ldap-connector:4.0.*"
  2. Add the service provider in the app configuration by opening config/app.php, and add a new item to the providers array.

    Dsdevbe\LdapConnector\LdapConnectorServiceProvider::class
    
  3. Change the authentication driver in the Laravel config to use the ldap driver. You can find this in the following file config/auth.php

    'providers' => [
        'users' => [
            'driver' => 'ldap',
            'adldap' => [
                'account_suffix'=>  '@domain.local',
                'domain_controllers'=>  array(
                    '192.168.0.1',
                    'dc02.domain.local'
                ), // Load balancing domain controllers
                'base_dn'   =>  'DC=domain,DC=local',
                'admin_username' => 'admin', // This is required for session persistance in the application
                'admin_password' => 'yourPassword',
            ],
        ],
    ],

    Please note that the fields 'admin_username' and 'admin_password' are required for session persistance!

Usage

The LDAP plugin is an extension of the Auth class and will act the same as normal usage with Eloquent driver.

if (Auth::attempt(array('username' => $username, 'password' => $password)))
{
    return Redirect::intended('dashboard');
}

You can find more examples on Laravel Auth Documentation on using the Auth:: function.

Use AuthController

If you want to use the authentication controller that ships with Laravel you will need to change the following files. By default App\Http\Controllers\Auth\AuthController checks for the email field if nothing is provided. To overwrite this value add the following line in the AuthController.

protected $username = 'username';

Laravel documentation: Authentication Quickstart

Ldap User Information

Difference with ldap-connector V3 is that now the adLDAP model is directly exposed on the user model. This means that you can fetch all data directly from the user. To access the adldap model you can use now Auth::user()->getAdLDAP().

Examples:

  • Auth::user()->getAdLDAP()->getAccountName()
  • Auth::user()->getAdLDAP()->getFirstName()

To fetch more properties please check adLDAP2 documentation

Contributing

Feel free to contribute to this project for new features or bug fixes. We are open for improvements!

dsdevbe/ldap-connector 适用场景与选型建议

dsdevbe/ldap-connector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.28k 次下载、GitHub Stars 达 100, 最近一次更新时间为 2014 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ldap」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dsdevbe/ldap-connector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dsdevbe/ldap-connector 我们能提供哪些服务?
定制开发 / 二次开发

基于 dsdevbe/ldap-connector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 102
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 100
  • Watchers: 9
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-22