Attivazione autenticazione LDAP con registrazione utenti in DB
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
@@ -37,4 +38,12 @@ class LoginController extends Controller
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
protected function credentials(Request $request)
|
||||
{
|
||||
return [
|
||||
'mail' => $request->email,
|
||||
'password'=>$request->password,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,6 @@ class CategorieController extends Controller
|
||||
public function apiList()
|
||||
{
|
||||
$categorie=DB::table('categories')->orderBy('cat_name')->get();
|
||||
return json_encode($categorie);
|
||||
return response()->json($categorie);
|
||||
}
|
||||
}
|
||||
|
||||
21
app/Ldap/Rules/OnlyInGroupUsers.php
Normal file
21
app/Ldap/Rules/OnlyInGroupUsers.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ldap\Rules;
|
||||
|
||||
use LdapRecord\Laravel\Auth\Rule;
|
||||
|
||||
class OnlyInGroupUsers extends Rule
|
||||
{
|
||||
/**
|
||||
* Check if the rule passes validation.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid()
|
||||
{
|
||||
//
|
||||
return $this->user->groups()->exists(
|
||||
env('LDAP_GROUP_ACCESS')
|
||||
);
|
||||
}
|
||||
}
|
||||
15
app/Ldap/User.php
Normal file
15
app/Ldap/User.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ldap;
|
||||
|
||||
use LdapRecord\Models\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
/**
|
||||
* The object classes of the LDAP model.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $objectClasses = [];
|
||||
}
|
||||
@@ -4,13 +4,16 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
//use LdapRecord\Laravel\Auth\Authenticatable;
|
||||
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
|
||||
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
use HasApiTokens, HasFactory, Notifiable, AuthenticateswithLdap;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -41,4 +44,14 @@ class User extends Authenticatable
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function getLdapDomainColumn()
|
||||
{
|
||||
return 'domain';
|
||||
}
|
||||
|
||||
public function getLdapGuidColumn()
|
||||
{
|
||||
return 'guid';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user