我将 Drupal 配置为使用 CAS 登录。
登录 CAS 后,当我访问 drupal 网站的第一页时,我想在不单击任何链接的情况下登录(通过单点登录(CAS)登录)
有任何选项是 Drupal CAS 设置吗?
我不熟悉 CAS,也不知道您可以使用哪些变量来判断用户是否应该登录,但您应该可以使用 hook_init() 和 user_external_login_register( ) http://api.drupal.org/api/drupal/modules--user--user.module/function/user_external_login_register/7
伪代码:
<?php
/**
* Implements hook_init().
*/
function mymodule_init() {
// only check if user is not logged in
if (user_is_anonymous()) {
// add your condition to test if user is valid
if ( <condition to check if user should be logged in> ) {
// programmatically login user by name
user_external_login_register('<username>', 'mymodule');
}
}
}
使用这个库:https ://wiki.jasig.org/display/CASC/phpCAS
在您的 Drupal 站点的第一页中创建客户端并强制身份验证:
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
最后一次调用会将用户重定向到 CAS。如果他已登录,那么用户将被发送回您的 Drupal 站点的第一页,并且他将登录。这是即时的。用户甚至不会看到他访问了 CAS 页面。
高温高压
有一个选项。
进入CAS模块的配置页面(/admin/config/people/cas)。
在字段集重定向下,选中此复选框:
检查 CAS 服务器以查看用户是否已登录?