Hello there. I am trying to make a module that performs automatic authentication with siteminder. Siteminder is a program that sits on my server and catches a web page, then performs authentication, then stores the authentication info inside of the http header. I am trying to make a module that logs someone into drupal automatically when this happens. I have started to code a module, (haven't done that before), and from the looks of it it should work but it doesn't even show up in the available modules list in drupals administer section. The module is pretty much exactly taken from the book Pro Drupal Development where I was planning on starting with that and changing it till it fit our solutions, but I couldn't get that to show up. Then I started to look inside of the drupal documentation for what it takes to get a module to show up, I added a couple sections... and now it still doesnt work. I have zero errors in eclipse, and just a warning but it looks like nothing serious. Below is the code and if anyone could give me any feed back or spots anything obvious, I would really appreciate it. Thanks
The First file, smautoauth.php
/**
* Created on Sep 16, 2008
*
* @file smautoauth.php
* Automatically logs users in using their siteminder credentials.
*/
function smautoauth_help($path, $arg) {
$output = '<p>' . "t(Works by logging the user in with no options.)" . '<p>';
return $output;
}
function smautoauth_perm() {
return array('access smautoauth', 'administer smautoauth');
}
function onthisdate_block($op='list', $delta=0) {
// listing of blocks, such as on the admin/block page
if ($op == "list") {
$block[0]["info"] = t("Siteminder Auto Auth");
return $block;
} else if ($op == 'view') {
$status = "logged in";
$block['subject'] = 'Siteminder Auto Auth';
$block['content'] = $status;
return $block;
}
}
function smautoauth_form_alter(&$form, $form_state, $form_id)
{
if($form_id =='user_login' || $form_id == 'user_login_block'){
$form['pass']['#required'] = FALSE;
if (isset($form_state['post']['name'])) {
$array_key = array_search('user_login_authenticate_validate' ,
$form['#validate']);
if ($array_key === FALSE) {
$final_validator = array_pop($form['#validate']);
$form['#validate'][] = 'smautoauth_login_validate';
$form['#validate'][] = $final_validator;
}
else
{
$form['validate'][$array_key] = 'smautoauth_login_validate';
}
}
}
}
function smautoauth_login_validate($form, &$form_state) {
global $user;
if(!empty($user->uid)) {
return;
}
if(!smautoauth_authenticate($form_state['values'])) {
form_set_error('name', t('Unrecognized username.'));
}
}
function smautoauth_authenticate($form_values) {
global $smautoauth_authenticated;
$username = $_SERVER['HTTP_SM_USER'];
if(isset($username)){
user_external_login_register($username, substr($username, 2, 7));
user_authenticate_finalize($form_state['values']);
$smautoauth_authenticated = TRUE;
return TRUE;
}
else
{
return FALSE;
}
}
The second file, smautoauth.info
; $Id$
name = SMAutoAuth
description = Automatically logs users in using Siteminder header info.
core = 6.x
package = "Siteminder Auto Login"
The third file, smautoauth.admin.inc
/**
* @file smautoauth.admin.inc
* Administration page callbacks for the siteminderautoauth module.
* Created on Sep 16, 2008
*
*/
/**
* Form builder. Configure Siteminder auto authentication program.
* @ingroup forms
* @see system_settings_form().
*/
function smautoauth_admin_settings()
{
//Get an array of node types with internal names as keys and
// friendly names as values
$options = node_get_types('names');
$form['smautoauth_settings'] = array(
'#type' => 'checkboxes',
'#title' => $options,
'#default_value' => variable_get('smautoauth_node_types', array('page')),
'#description' => t('A text field will be available on these content' .
'types to make user specfic notes.'),
);
return system_settings_form($form);
}
Again, any help would be greatly appreciated. Thanks!
Comments
Not needed
As it turns out... This module is un needed. Siteminder is totally integrated simply by installing WebServer Authentication module. This is located here ...
http://drupal.org/project/webserver_auth
Install... Uncheck the two options they provide, and poof, magically it works. Thanks guys