我想使用带有SSO连接的Voyager。
我正在尝试使用LdapRecord来完成这个任务。
但是用户模型是不同的,我不能合并它们。
对于如何使用旅行者和LdapRecord,有什么想法吗?
发布于 2022-09-13 12:48:30
使用Windows IIS,我为我的站点启用Windows身份验证。
因此,我们可以使用$_SERVER‘’AUTH_USER‘
namespace App\Http\Controllers\Common;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Commun\FunctionController;
use App\Models\User;
class ConnexionController extends Controller
{
/**
*
* @return array
*/
public static function ConnexionSSO()
{
$authenticate = array(
'state' => false,
'message' => "You can't be authenticated."
);
$not_autorised = "";
$ident = "";
$agident = 0;
$name = "";
$surname = "";
$email = "";
if (App::environment() == 'local') {
$ident = 'IDENT_LOCAL';
$name = 'IDENT';
$surname = 'FOR_LOCAL';
$authenticate = [
'state' => true,
'message' => "You have been authenticated."
];
$agident = 1;
} else if (isset($_SERVER['AUTH_USER']) && $_SERVER['AUTH_USER'] != '') {
$ident = $_SERVER['AUTH_USER'];
if (Str::contains($ident , '\\')) {
$ident = explode('\\', $ident );
$ident = $ident [1];
}
$user = FunctionController::DataAgentIdentifiant($ident);
$name = $user['nom'];
$surname = $user['prenom'];
$email = $user['mail'];
$select = "PS @nom='".$name." ".$surname."'";
$dataUser = collect(DB::connection('sqlsrv')
->select($select))
->first();
$agident = $dataUser->AgIdent;
$authenticate = [
'state' => true,
'message' => "You have been authenticated."
];
}
return array(
'authenticate' => $authenticate,
'not_autorised' => $not_autorised,
'ident' => $ident,
'agident' => $agident,
'name' => $name,
'surname' => $surname,
'email' => $email
);
}
}https://stackoverflow.com/questions/71956347
复制相似问题