'. t("Authentication to the Fedora Account System (FAS)") .'

'; $output .= '

'. t("Note that this module doesn't actually function yet.") .'

'; break; } return $output; } // function authfas_help /** * Implementation of hook_perm(). */ function authfas_perm() { return array('administer FAS settings'); } // function authfas_perm() /** * Implementation of hook_block(). */ function authfas_block($op = 'list', $delta = 0, $edit = array()) { // DUMMY if ($op == "list") { $block = array(); $block[0]["info"] = t('AuthFAS success'); return $block; } else if ($op == "view") { $fasurl = variable_get('authfas_fasurl', 'WHOOPS'); $block_content = ''; $block_content .= $fasurl; $block = array(); $block['subject'] = 'FAS URL'; $block['content'] = $block_content; return $block; } } /** * Implementation of hook_admin(). */ function authfas_admin() { $form = array(); $form['authfas_fasurl'] = array( '#type' => 'textfield', '#title' => t('Location of FAS instance'), '#default_value' => variable_get('authfas_fasurl', 'admin.fedoraproject.org/accounts'), '#size' => 50, '#maxlength' => 255, '#description' => t('The location of the FAS instance to which users can authenticate'), '#required' => TRUE, ); // We have a required setting for the Authenticated User role. $form['authfas_authuser_fasgroup'] = array( '#type' => 'textfield', '#title' => t('FAS group for authenticated users'), '#default_value' => variable_get('authfas_authuser_fasgroup', ''), '#size' => 50, '#maxlength' => 255, '#description' => t('To authenticate when this module is enabled, a user must be a member of this FAS group.'), '#required' => TRUE, ); $form['authfas_more_information'] = array( '#type' => 'item', '#title' => t('More information'), '#description' => t('Visit the Roles settings page to set FAS group mappings for specific roles.', array('@roles' => url('admin/user/roles'))), ); return system_settings_form($form); } /** * Implementation of hook_menu(). */ function authfas_menu() { $items = array(); $items['admin/settings/authfas'] = array( 'title' => 'AuthFAS module settings', 'description' => 'Settings for authenticating to a FAS instance', 'page callback' => 'drupal_get_form', 'page arguments' => array('authfas_admin'), 'access arguments' => array('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Validate settings entered in AuthFAS settings menu */ function authfas_admin_validate($form, &$form_state) { // This is where we would validate the menu settings above // http://drupal.org/node/206761 $ch = curl_init(); $fasurl = $form_state['values']['authfas_fasurl']; // Expect a JSON interface to be present curl_setopt($ch, CURLOPT_URL, 'https://' . $fasurl . '/json'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Auth_FAS 0.9"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // The following two lines need to be enabled when using a test FAS // with an invalid cert. Otherwise they should be commented (or // set to True) for security. // #curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // #curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); $response = json_decode(curl_exec($ch), true); curl_close ($ch); if (!isset($response["help"])) { form_set_error("authfas_fasurl", 'No JSON interface present at https://' .$fasurl. '/json'); return FALSE; } return TRUE; } function authfas_form_user_admin_role_alter(&$form, $form_state) { $newform = array(); // I'm obviously not very good at PHP because I couldn't figure // out a more clever way to insert this field into an existing // $form array. We want the field for FAS group mapping to be part // of the form *before* the submit control. while (list($key, $val) = each($form)) { if ($key == 'submit') { $newform['fasgroup'] = array( '#type' => 'textfield', '#title' => 'FAS group mapping', '#description' => 'Enter the name for a FAS group that maps to this role.', '#size' => 30, '#maxlength' => 255, ); } $newform[$key] = $val; } $form = $newform; } // Local variables: // mode:php // tab-width:2 // indent-tabs-mode:nil // End: