【发布时间】:2021-01-05 18:15:52
【问题描述】:
我正在尝试制作一个 Codeigniter 3 应用程序来向 CAS 服务器进行身份验证。 我用作曲家安装了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));
}
}
【问题讨论】:
-
到目前为止你尝试过什么?你被困在哪里了?
标签: codeigniter composer-php phpcas