我正在尝试创建一个Codeigniter 3应用程序来验证CAS服务器。我用composer安装了phpcas包,但是我找不到任何关于如何做到这一点的细节或示例。我希望只有认证用户才能访问此应用程序。
我相信我必须编辑一个配置文件,但我找不到任何写下cas服务器url等的配置文件。另外,在页面的控制器中,我必须以某种方式调用库,但我需要一些示例。
所以主要的问题是我如何在我的控制器方法中使用phpcas,以及如何配置它?
我创建了一个控制器,里面有:
?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class AuthController extends CI_Controller {
public function actionLogin()
{
$this->module->casService->forceAuthentication();
$username = $this->module->casService->getUsername();
$this->module->casService->getAttribute('mail')
$this->module->casService->getAttribute('title')=='TEACHER';
//$auth->assign($casRole, $user->id);
}
public function actionLogout()
{
$this->module->casService->logout(Url::home(true));
// In case the logout fails (not authenticated)
return $this->redirect(Url::home(true));
}
}发布于 2020-09-19 17:43:29
我在控制器文件中放入下面这一行:
require_once(APPPATH . '/../vendor/autoload.php');我用以下方式初始化:
$phpCAS = new phpCAS;
phpCAS::client(CAS_VERSION_2_0, 'sso-test.sch.gr', 443, '', false);https://stackoverflow.com/questions/63961989
复制相似问题