2017 © Pedro PelĂĄez
 

library lmod-authz-ldap

Auth & Authorization system for AdLdap2

image

irisit/lmod-authz-ldap

Auth & Authorization system for AdLdap2

  • Tuesday, April 24, 2018
  • by Bouhnosaure
  • Repository
  • 3 Watchers
  • 0 Stars
  • 40 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 48 % Grown

The README.md

Authz Ldap Module

Documentation du module d'authentification et d'authorisation, (*1)

Fonctionnalités

Guest

  • Sign in

Admin

  • List of users -- Assign role to user -- Trigger ldap sync, (*2)

  • List of permissions -- Parse from source file -- Edit descriptions, (*3)

  • List of roles -- Create role -- Edit role --- Assign permissions to role, (*4)

Install

Begin by installing this package through Composer. Edit your project's composer.json file to require laravelcollective/html., (*5)

composer require "laravelcollective/html":"^5.4.0" composer require "adldap2/adldap2-laravel": "^3.0", (*6)

Next, add your new provider to the providers array of config/app.php:, (*7)

  'providers' => [
    // ...
    Collective\Html\HtmlServiceProvider::class,
    Irisit\AuthzLdap\AuthzServiceProvider::class,
    Adldap\Laravel\AdldapServiceProvider::class,
    Adldap\Laravel\AdldapAuthServiceProvider::class,
    // ...
  ],

Finally, add two class aliases to the aliases array of config/app.php:, (*8)

  'aliases' => [
    // ...
      'Form' => Collective\Html\FormFacade::class,
      'Html' => Collective\Html\HtmlFacade::class,
      'Adldap' => Adldap\Laravel\Facades\Adldap::class,
    // ...
  ],

Replace all the in the App\User::class, (*9)

<?php

namespace App;

use Adldap\Laravel\Traits\HasLdapUser;
use Illuminate\Notifications\Notifiable;
use Irisit\AuthzLdap\Models\BaseUser as Authenticatable;

class User extends Authenticatable
{
    use Notifiable, HasLdapUser;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'firstname',
        'lastname',
        'username',
        'email',
        'password',
        'role_id'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

Replace in migrations the name attribute by, (*10)

$table->string('firstname');
$table->string('lastname');
$table->string('username')->unique();

Replace the line in App\Http\Kernel.php, (*11)

'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,, (*12)

by, (*13)

'guest' => \Irisit\AuthzLdap\Http\Middleware\RedirectIfAuthenticated::class,, (*14)

And add at the end ( after guest ), (*15)

'role' => \Irisit\AuthzLdap\Http\Middleware\RedirectIfNotRole::class,, (*16)

so you can use the middleware 'role' to protect a route or a group like this middleware => 'role:admin,manager', (*17)

Run, (*18)

php artisan db:seed --class=Irisit\AuthzLdap\Database\Seeds\DatabaseSeeder, (*19)

Add to config/filesystem.php, (*20)

        'base' => [
            'driver' => 'local',
            'root' => base_path() . DIRECTORY_SEPARATOR,
        ],

Add this to app/Exceptions/Handler.php, (*21)

/**
 * @override
 * @param \Illuminate\Http\Request $request
 * @param AuthenticationException $exception
 * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
 */
protected function unauthenticated($request, AuthenticationException $exception)
{
    return $request->expectsJson()
        ? response()->json(['message' => 'Unauthenticated.'], 401)
        : redirect()->guest(route('authz.get_login'));
}

And run php artisan vendor:publish --provider="Irisit\AuthzLdap\AuthzServiceProvider" to get the configuration file and the seeder file, (*22)

For the seeder add $this->call(RoleTableSeeder::class); to the /database/seeders/DatabaseSeeder.php, (*23)

to import users : php artisan adldap:import, (*24)

to get groups : php artisan lmod_authz:import_groups_ldap, (*25)

to get permissions : php artisan lmod_authz:parse_permissions, (*26)

to promote user as admin : php artisan lmod_authz:promote_user_admin, (*27)


In order to use the filters you have to create a scope, (*28)

<?php

namespace App\Scopes;

use Adldap\Query\Builder;
use Adldap\Laravel\Scopes\ScopeInterface;

class FilterScope implements ScopeInterface
{
    /**
     * {@inheritdoc}
     */
    public function apply(Builder $builder)
    {
        $builder->rawFilter(config('irisit_authz.ldap_filters'));
    }
}

And add the scope to adldap_auth.php config file, (*29)

    'scopes' => [

        // Only allows users with a user principal name to authenticate.

        App\Scopes\SamAccountNameScope::class,

        App\Scopes\FilterScope::class, <---

    ],

The Versions

24/04 2018

dev-master

9999999-dev

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

24/04 2018

0.1.9

0.1.9.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

23/04 2018

0.1.8

0.1.8.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

23/04 2018

0.1.7

0.1.7.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

02/03 2018

0.1.6

0.1.6.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

02/01 2018

0.1.5

0.1.5.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

02/01 2018

0.1.4

0.1.4.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

02/01 2018

0.1.3

0.1.3.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

05/12 2017

0.1.2

0.1.2.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

04/12 2017

0.1.1

0.1.1.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

04/12 2017

0.1.0

0.1.0.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

30/11 2017

0.0.6

0.0.6.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

30/11 2017

0.0.5

0.0.5.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

30/11 2017

0.0.4

0.0.4.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

30/11 2017

0.0.3

0.0.3.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

30/11 2017

0.0.2

0.0.2.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC

30/11 2017

0.0.1

0.0.1.0

Auth & Authorization system for AdLdap2

  Sources   Download

MIT

The Requires

 

by monkeyC