Add and commented out SSL options, fix trailing whitespace.
This commit is contained in:
parent
abae1901c0
commit
692acc9eaf
2 changed files with 18 additions and 11 deletions
|
@ -31,7 +31,7 @@ if (!function_exists('wp_authenticate')) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FAS Authentication
|
* FAS Authentication
|
||||||
*/
|
*/
|
||||||
function wp_authenticate($username, $password) {
|
function wp_authenticate($username, $password) {
|
||||||
|
|
||||||
$config = fasauth_config();
|
$config = fasauth_config();
|
||||||
|
@ -42,13 +42,19 @@ if (!function_exists('wp_authenticate')) {
|
||||||
curl_setopt($ch, CURLOPT_URL, $config['fas_json_url']);
|
curl_setopt($ch, CURLOPT_URL, $config['fas_json_url']);
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, "Wordpress MU FAS Auth 0.1");
|
curl_setopt($ch, CURLOPT_USERAGENT, "Wordpress MU FAS Auth 0.1");
|
||||||
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
|
# WARNING: Never leave this on in production, as it will cause
|
||||||
# plaintext passwords to show up in error logs.
|
# plaintext passwords to show up in error logs.
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||||
|
|
||||||
|
# The following two lines need to be uncommented 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);
|
||||||
|
|
||||||
$fasuserdata = json_decode(curl_exec($ch), true);
|
$fasuserdata = json_decode(curl_exec($ch), true);
|
||||||
curl_close ($ch);
|
curl_close ($ch);
|
||||||
|
|
||||||
|
@ -58,17 +64,17 @@ if (!function_exists('wp_authenticate')) {
|
||||||
// check minimum requirements
|
// check minimum requirements
|
||||||
if (check_login_requirement($fasuserdata) !== true) {
|
if (check_login_requirement($fasuserdata) !== true) {
|
||||||
error_log("FAS auth failed for $username: insufficient group membership", 0);
|
error_log("FAS auth failed for $username: insufficient group membership", 0);
|
||||||
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.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's check wp db for user
|
// let's check wp db for user
|
||||||
$user = get_userdatabylogin($username);
|
$user = get_userdatabylogin($username);
|
||||||
|
|
||||||
// user not found, let's create db entry for it
|
// user not found, let's create db entry for it
|
||||||
if ( !$user || ($user->user_login != $username) ) {
|
if ( !$user || ($user->user_login != $username) ) {
|
||||||
$user_id = create_wp_user($username);
|
$user_id = create_wp_user($username);
|
||||||
if (!$user_id) {
|
if (!$user_id) {
|
||||||
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.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log("FAS auth succeeded for $username", 0);
|
error_log("FAS auth succeeded for $username", 0);
|
||||||
|
@ -87,7 +93,7 @@ if (!function_exists('wp_authenticate')) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates user in wp db
|
* Creates user in wp db
|
||||||
*/
|
*/
|
||||||
function create_wp_user($username) {
|
function create_wp_user($username) {
|
||||||
|
|
||||||
$config = fasauth_config();
|
$config = fasauth_config();
|
||||||
|
@ -104,7 +110,7 @@ if (!function_exists('wp_authenticate')) {
|
||||||
function disable_function() {
|
function disable_function() {
|
||||||
die('Feature disabled.');
|
die('Feature disabled.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used to redirect all lost password request to FAS.
|
* Used to redirect all lost password request to FAS.
|
||||||
*/
|
*/
|
||||||
|
@ -112,7 +118,7 @@ if (!function_exists('wp_authenticate')) {
|
||||||
$config = fasauth_config();
|
$config = fasauth_config();
|
||||||
wp_redirect($config['fas_pass_reset_url'], 302);
|
wp_redirect($config['fas_pass_reset_url'], 302);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* checks minimum login requirements
|
* checks minimum login requirements
|
||||||
|
|
|
@ -19,11 +19,12 @@ class Auth_FAS extends AuthPlugin {
|
||||||
# plaintext passwords to show up in error logs.
|
# plaintext passwords to show up in error logs.
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||||
|
|
||||||
# The following two lines need to be enabled when using a test FAS
|
# The following two lines need to be uncommented when using a test FAS
|
||||||
# with an invalid cert. Otherwise they should be commented (or
|
# with an invalid cert. Otherwise they should be commented (or set to
|
||||||
# set to True) for security.
|
# True) for security.
|
||||||
#curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
#curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||||
#curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
#curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||||
|
|
||||||
$response = json_decode(curl_exec($ch), true);
|
$response = json_decode(curl_exec($ch), true);
|
||||||
curl_close ($ch);
|
curl_close ($ch);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue