I have tried everything I have found on the internet to no avail.
The module provides external authentication handled by an iframe. When the authentication completes, a message is sent to the socket on the drupal page with success or failed status. In the event of success, the module needs to communicate again with the external server to get the userid on drupal to complete the login.
Two things: (1) The drupal must have no knowledge of the external credentials, and (2) the username/password on the external authenticator are independent of the drupal username/password.
The name of the module is 'yauisauth'.
Given that, I have the following in hook_menu:
function yauisauth_menu() {
$items['yauisauth/callback/%'] = array(
'title' => 'yauis login completion',
'description' => 'coordinates yauis login with drupal login',
'access callback' => user_is_anonymous,
'file' => 'yauisauth.inc',
'page callback' => 'yauisauth_callback',
'page arguments' => array(2),
'type' => MENU_CALLBACK,
);
$items['yauisauth/failed'] = array(
'title' => 'login failed',
'description' => 'login failed',
'access callback' => user_is_anonymous,
'file' => 'yauisauth.inc',
'page callback' => 'yauis_login_failed',
'type' => MENU_CALLBACK,
);
return $items;
}
The callback is invoked from the javascript:
return_to = 'yauisauth/callback/';
return_to += transid;
jQuery.post(return_to, null, null);
The error I get is:
POST http://localhost/drupal7/yauisauth/callback/4ddcd4ab-5167-4aa5-bafa-ee46812237d8 404 (Not Found)
Obvious, I am not constructing the url in a way that drupal wants to see it but I don't know what to do.
Originally, I had all the functions in yauisauth.module but then split the callback functions and the ones it calls into yauisauth.inc
Between each change, I do the following:
(in mysql):
UPDATE system SET status='0' WHERE name='yauisauth'; DELETE FROM cache_bootstrap WHERE cid='system_list';
then in bash:
drush -cc menu
drush -cc all
(Blindly following every instruction I can find on the net.)
The callback function looks like:
function yauisauth_callback($transid) {
$attr = get_attributes($transid);
if (empty($attr)) {
return drupal_not_found();
}
... // calls to other functions local to the yauisauth.inc file
}
Can anyone tell me why my invocation of the callback function is failing and what I can do to make it work?
Based on advice received elsewhere, I changed my drupal to reside at the document root of a virtual host and put the entire url into the javascript call - window.location.origin + '/yauisauth/callback'. An alert informs me that the url is constructed correctly.
I have a "die" at the beginning of the callback function that never gets executed.
If I put the url in the address bar, the "die" statement is executed so the route is found.
Still looking for advice.
I just took another look at your code – you're adding underscores when none are needed, for example page_callback
should be page callback
. See: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7.