2017 © Pedro Peláez
 

library authchain

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

image

restricted/authchain

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

  • Friday, January 30, 2015
  • by restricted
  • Repository
  • 0 Watchers
  • 4 Stars
  • 90 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Laravel 4 chain authentication provider

WARNING: Project no longer maintaned!, (*1)

Supports native database, LDAP, IMAP and IP address multi-domain authentication for single sign-on., (*2)

For LDAP and IMAP authentication you need to have ldap and imap php extensions., (*3)

Installation

Installing this package through Composer. Edit your project's composer.json file to require restricted/authchain., (*4)

"require": {
    "laravel/framework": "4.2.*",
    "restricted/authchain": ">=1.0.6"
}

Update Composer from the Terminal:, (*5)

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., (*6)

'providers' => [
    // Your Laravel providers here...
    'Restricted\Authchain\AuthchainServiceProvider'
]

Create example configuration file from terminal:, (*7)

php artisan config:publish restricted/authchain

Change default authentication provider to authchain., (*8)

Open app/config/auth.php and change driver section to authchain., (*9)

return array(

    'driver': 'authchain'

    // Related stuff...
);

Please see app/config/packages/restricted/authchain/config.php for full configuration instructions., (*10)

You need to create User model in app/models and create migration., (*11)

For details on models and migrations you can see vendor/restricted/authchain/quickstart, (*12)

You can simply copy contents of folder vendor/restricted/authchain/quickstart/models/ to app/models., (*13)

Example migration can be executed by command php artisan migrate --package="restricted/authchain"., (*14)

NOTE: migration does`t include timestamps., (*15)

If you don't use ip address authentication, set ['defaults']['ip'] to false in app/config/packages/restricted/authchain/config.php., (*16)

Quickstart

Install laravel (see http://laravel.com/docs/quick), (*17)

composer create-project laravel/laravel your-project-name --prefer-dist

Install authchain provider (see Installation), (*18)

Configure your domains in app/config/packages/restricted/authchain/config.php, (*19)

Copy files from, (*20)

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, (*21)

cat vendor/restricted/authchain/quickstart/filters.php >> app/filters.php

Add to your app/routes.php contents from vendor/restricted/authchain/quickstart/routes.php, (*22)

cat vendor/restricted/authchain/quickstart/routes.php >> app/routes.php 

Serve your application from terminal: php artisan serve, (*23)

Go to http://localhost:8000/ and enjoy!, (*24)

Need community feedback

  • Need to implement oAuth2 ?
  • Other providers?

Contribute

Any suggestions are welcome

You can easily write your own authentication provider for authchain:, (*25)

Custom provider example (see in src/Restricted/Authchain/Provider/Domain/CustomProviderExample):, (*26)


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:, (*27)

Register custom provider in section providers:, (*28)

'providers' => array(
    // ...
    'Restricted\Authchain\Provider\Domain\CustomProviderExample',
)

In section domains:, (*29)

'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)., (*30)

  • 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., (*31)

The Versions

30/01 2015

1.0.x-dev

1.0.9999999.9999999-dev

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication auth eloquent security ldap imap

30/01 2015

dev-master

9999999-dev

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication auth eloquent security ldap imap

30/01 2015

1.0.8

1.0.8.0

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication auth eloquent security ldap imap

29/01 2015

1.0.7

1.0.7.0

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication auth eloquent security ldap imap

29/01 2015

1.0.6

1.0.6.0

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication security ldap imap

13/12 2013

1.0.5

1.0.5.0

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication security

10/12 2013

1.0.4

1.0.4.0

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication security

08/12 2013

1.0.3

1.0.3.0

Laravel 4 chain authentication (LDAP, IMAP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication security

07/12 2013

1.0.2

1.0.2.0

Laravel 4 chain authentication (LDAP, IMAP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication security

06/12 2013

1.0.1

1.0.1.0

Laravel 4 chain authentication (LDAP, IMAP, Eloquent)

  Sources   Download

MIT

The Requires

 

laravel authentication security