Log in via single sign-on (CAS)?
I configure Drupal to log in with CA开发者_JAVA技巧S.
After login in CAS, When I visit first page of drupal website I want to be logged in without click any link (Log in via single sign-on (CAS))
is any option for that is Drupal CAS setting?
There is an option for that.
Go to the configuration page of CAS module (/admin/config/people/cas).
Under the fieldset Redirection, check this checkbox:
Check with the CAS server to see if the user is already logged in?
I'm not familiar with CAS and don't know what variables you have available to you to tell if the user should be logged in or not, but you should be able to achieve this with a custom module in hook_init() and user_external_login_register() http://api.drupal.org/api/drupal/modules--user--user.module/function/user_external_login_register/7
Psuedo Code:
<?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');
}
}
}
Use this library: https://wiki.jasig.org/display/CASC/phpCAS
And in the first page of your Drupal site create the client and force authentication:
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
The last call will redirect the user to CAS. If he is logged in, then the user will be sent back to the first page of your Drupal site and he'll be logged in. it's instantaneous. The user won't even see that he went to a CAS page.
HTH
精彩评论