Add some logging and a warning about CURLOPT_VERBOSE.
This commit is contained in:
parent
d8ef5c36ac
commit
c5a53944fc
1 changed files with 124 additions and 116 deletions
|
@ -9,7 +9,7 @@ Author URI: http://fedoraproject.org/wiki/Infrastructure
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// overriding wp_authenticate
|
// overriding wp_authenticate
|
||||||
if(!function_exists('wp_authenticate')) :
|
if (!function_exists('wp_authenticate')) {
|
||||||
|
|
||||||
// let's disable a few things
|
// let's disable a few things
|
||||||
add_action('lost_password', 'disable_function');
|
add_action('lost_password', 'disable_function');
|
||||||
|
@ -44,7 +44,11 @@ function wp_authenticate($username, $password) {
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, "Auth_FAS 0.9");
|
curl_setopt($ch, CURLOPT_USERAGENT, "Auth_FAS 0.9");
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".urlencode($username)."&user_name=".urlencode($username)."&password=".urlencode($password)."&login=Login");
|
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".urlencode($username)."&user_name=".urlencode($username)."&password=".urlencode($password)."&login=Login");
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
|
||||||
|
# WARNING: Never leave this on in production, as it will cause
|
||||||
|
# plaintext passwords to show up in error logs.
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||||
|
|
||||||
$fasuserdata = json_decode(curl_exec($ch), true);
|
$fasuserdata = json_decode(curl_exec($ch), true);
|
||||||
curl_close ($ch);
|
curl_close ($ch);
|
||||||
|
|
||||||
|
@ -53,6 +57,7 @@ function wp_authenticate($username, $password) {
|
||||||
|
|
||||||
// check minimum requirements
|
// check minimum requirements
|
||||||
if (check_login_requirement($fasuserdata) !== true) {
|
if (check_login_requirement($fasuserdata) !== true) {
|
||||||
|
fwrite(STDERR, "FAS auth failed for $username: insufficient group membership\n");
|
||||||
return new WP_Error('fasauth_min_requirement', __('<strong>Error</strong>: You do not meet minimum requirements to login.'));
|
return new WP_Error('fasauth_min_requirement', __('<strong>Error</strong>: You do not meet minimum requirements to login.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,13 +71,16 @@ function wp_authenticate($username, $password) {
|
||||||
return new WP_Error('fasauth_create_wp_user', __('<strong>Error</strong>: Unable to create account. Please contact the webmaster.'));
|
return new WP_Error('fasauth_create_wp_user', __('<strong>Error</strong>: Unable to create account. Please contact the webmaster.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fwrite(STDERR, "FAS auth succeeded for $username\n");
|
||||||
return new WP_User($user_id);
|
return new WP_User($user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// all good, let go on
|
// all good, let go on
|
||||||
|
fwrite(STDERR, "FAS auth succeeded for $username\n");
|
||||||
return new WP_User($user->ID);
|
return new WP_User($user->ID);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
fwrite(STDERR, "FAS auth failed for $username: incorrect username or password\n");
|
||||||
return new WP_Error('fasauth_wrong_credentials', __('<strong>Error</strong>: FAS login unsuccessful.'));
|
return new WP_Error('fasauth_wrong_credentials', __('<strong>Error</strong>: FAS login unsuccessful.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,6 +137,6 @@ function check_login_requirement($user) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue