我不知道这是否可能,但我会向你解释的。我试图用SSLVerifyClient来验证用户,但前提是用户选择这样做(用户可以使用电子邮件/密码或证书登录)。我在公共目录中创建了另一个名为idportaal的文件夹。在文件夹中,我有带有SSLVerifyClient require SSLVerifyDepth 2的SSLVerifyClient require SSLVerifyDepth 2文件,也有一个index.php和函数文件。
当用户单击链接时,我将指向idportal文件夹,其中要求用户进行认证:如果提供了有效的证书,我将手动登录用户,并尝试将用户重定向到主页,但无法工作。
我可以在laravel安装文件夹外启动laravel。我得到正确的用户,但一旦我去主页,会话是未设置的。可以设置会话吗?
以下是idportal/index.php的代码
<?php
require $_SERVER['DOCUMENT_ROOT'] .'/bootstrap/autoload.php';
$app = require $_SERVER['DOCUMENT_ROOT'] .'/bootstrap/app.php';
$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
include "ocspcheck.php";
if (!$_SERVER["SSL_CLIENT_CERT"])
{
echo "Couldn't get client SSL certificate (ID-card autentication certificate)!";
}
else
{
$result = doOCSPcheck($_SERVER["SSL_CLIENT_CERT"]);
// $app['session']->driver()->setId($id);
// $app['session']->driver()->start();
$userData = $_SERVER['SSL_CLIENT_S_DN_CN'];
$first_name = $_SERVER['SSL_CLIENT_S_DN_G'];
$last_name = $_SERVER['SSL_CLIENT_S_DN_S'];
//get the user with the name
$selected_user = App\User::where('user_firstname', $first_name)->where('user_lastname', $last_name)->first();
if (isset($_COOKIE[$app['config']['session.cookie']])) {
//login user with the id
$id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]);
//set session id
$app['session']->driver()->setId($id);
}
//start session
$app['session']->driver()->start();
\Auth::loginUsingId($selected_user->id);
//put user to session
\Session::put('user', Auth::user());
//save session
\Session::save();
}链接到登录页面中的文件夹。
<a href="/idportaal/idkaart/index.php"><img src="assets/login/id-kaart-logo.gif"></a>发布于 2017-05-12 09:23:16
做你已经在做的事。但是在最后登录用户的地方,在这个idportaal/index.php文件中。别干那事。相反,创建一个新的路由,比如/ssl/login_auto/,然后重定向到这个路由。此路由将首先使用Auth::login($user)登录用户,然后重定向到主页。显然,您需要传递一些信息来确定哪些用户需要登录。如果您不太担心安全性,您可以直接传递id。但如果没有,则生成一些数字,保存在db中,并在重定向时传递它。在/ssl/login_auto/上验证相同
https://stackoverflow.com/questions/43932018
复制相似问题