Skip to content

Commit

Permalink
MDL-8590 auth cleanup - part 6
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 21, 2007
1 parent 7ee8146 commit 430759a
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 73 deletions.
6 changes: 3 additions & 3 deletions auth/cas/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function is_internal() {
* @return bool
*/
function can_change_password() {
return false;
return !empty($this->config->changepasswordurl);
}

/**
Expand All @@ -235,10 +235,10 @@ function config_form($config, $err, $user_fields) {
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* Returns the URL for changing the user's pw, or empty if the default can
* be used.
*
* @return bool
* @return string
*/
function change_password_url() {
return $this->config->changepasswordurl;
Expand Down
14 changes: 10 additions & 4 deletions auth/db/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,23 @@ function is_internal() {
* @return bool
*/
function can_change_password() {
return ($this->config->passtype === 'internal');
return ($this->config->passtype == 'internal' or !empty($this->config->changepasswordurl));
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* Returns the URL for changing the user's pw, or empty if the default can
* be used.
*
* @return bool
* @return string
*/
function change_password_url() {
return $this->config->changepasswordurl;
if ($this->config->passtype == 'internal') {
// standard form
return '';
} else {
// use custom url
return $this->config->changepasswordurl;
}
}

/**
Expand Down
19 changes: 14 additions & 5 deletions auth/email/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function user_update_password($user, $newpassword) {
return update_internal_user_password($user, $newpassword);
}

/*
/**
* Sign up a new user ready for confirmation.
*/
function user_signup($user, $notify = true) {
Expand All @@ -93,7 +93,7 @@ function user_signup($user, $notify = true) {
}
}

/*
/**
* Confirm the new user as registered.
*/
function user_confirm($username, $confirmsecret) {
Expand Down Expand Up @@ -135,13 +135,22 @@ function can_change_password() {
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* Returns the URL for changing the user's pw, or empty if the default can
* be used.
*
* @return bool
* @return mixed
*/
function change_password_url() {
return false;
return ''; // use dafult internal method
}

/**
* Returns true if plugin allows resetting of internal password.
*
* @return bool
*/
function can_reset_password() {
return true;
}

/**
Expand Down
15 changes: 7 additions & 8 deletions auth/imap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function auth_plugin_imap() {
* Returns true if the username and password work and false if they are
* wrong or don't exist.
*
* @param string $username The username
* @param string $password The password
* @param string $username The username (with system magic quotes)
* @param string $password The password (with system magic quotes)
* @return bool Authentication success or failure.
*/
function user_login ($username, $password) {
Expand Down Expand Up @@ -71,7 +71,7 @@ function user_login ($username, $password) {
}

error_reporting(0);
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
$connection = imap_open($host, stripslashes($username), stripslashes($password), OP_HALFOPEN);
error_reporting($CFG->debug);

if ($connection) {
Expand Down Expand Up @@ -99,18 +99,17 @@ function is_internal() {
* @return bool
*/
function can_change_password() {
return false;
return !empty($this->config->changepasswordurl);
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* Returns the URL for changing the user's pw, or empty if the default can
* be used.
*
* @return bool
* @return string
*/
function change_password_url() {
return $CFG->changepasswordurl; // TODO: will this be global?
//return $this->config->changepasswordurl;
return $this->config->changepasswordurl;
}

/**
Expand Down
21 changes: 8 additions & 13 deletions auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ function auth_plugin_ldap() {
}
}
//hack prefix to objectclass
if ('objectClass=' != substr($this->config->objectclass, 0, 12)) {
$this->config->objectclass = 'objectClass='.$this->config->objectclass;
if (empty($this->config->objectclass)) { // Can't send empty filter
$this->config->objectclass='objectClass=*';
} else if (strpos($this->config->objectclass, 'objectClass=') !== 0) {
$this->config->objectclass = 'objectClass='.$this->config->objectclass;
}

}

/**
Expand Down Expand Up @@ -135,10 +138,6 @@ function get_userinfo($username) {

$user_dn = $this->ldap_find_userdn($ldapconnection, $extusername);

if (empty($this->config->objectclass)) { // Can't send empty filter
$this->config->objectclass="objectClass=*";
}

if (!$user_info_result = ldap_read($ldapconnection, $user_dn, $this->config->objectclass, $search_attribs)) {
return false; // error!
}
Expand Down Expand Up @@ -387,10 +386,6 @@ function sync_users ($bulk_insert_records = 1000, $do_updates = true) {
//// get user's list from ldap to sql in a scalable fashion
////
// prepare some data we'll need
if (! empty($this->config->objectclass)) {
$this->config->objectclass="objectClass=*";
}

$filter = "(&(".$this->config->user_attribute."=*)(".$this->config->objectclass."))";

$contexts = explode(";",$this->config->contexts);
Expand Down Expand Up @@ -1500,11 +1495,11 @@ function is_internal() {
* @return bool
*/
function can_change_password() {
return true;
return !empty($this->config->stdchangepassword) or !empty($this->config->changepasswordurl);
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* Returns the URL for changing the user's pw, or empty if the default can
* be used.
*
* @return string url
Expand All @@ -1513,7 +1508,7 @@ function change_password_url() {
if (empty($this->config->stdchangepassword)) {
return $this->config->changepasswordurl;
} else {
return false;
return '';
}
}

Expand Down
15 changes: 12 additions & 3 deletions auth/manual/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,22 @@ function can_change_password() {
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* Returns the URL for changing the user's pw, or empty if the default can
* be used.
*
* @return bool
* @return string
*/
function change_password_url() {
return false;
return '';
}

/**
* Returns true if plugin allows resetting of internal password.
*
* @return bool
*/
function can_reset_password() {
return true;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions auth/mnet/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,17 +609,18 @@ function is_internal() {
* @return bool
*/
function can_change_password() {
//TODO: it should be able to redirect, right?
return false;
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* be used.
*
* @return bool
* @return string
*/
function change_password_url() {
return false;
return '';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions auth/nntp/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function auth_plugin_nntp() {
* Returns true if the username and password work and false if they are
* wrong or don't exist.
*
* @param string $username The username
* @param string $password The password
* @param string $username The username (with system magic quotes)
* @param string $password The password (with system magic quotes)
* @return bool Authentication success or failure.
*/
function user_login ($username, $password) {
Expand All @@ -55,7 +55,7 @@ function user_login ($username, $password) {
$host = '{' . trim($host) . ':' . $this->config->port . '/nntp}';

error_reporting(0);
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
$connection = imap_open($host, stripslashes($username), stripslashes($password), OP_HALFOPEN);
error_reporting($CFG->debug);

if ($connection) {
Expand Down
10 changes: 0 additions & 10 deletions auth/nologin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ function can_change_password() {
return false;
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* be used.
*
* @return bool
*/
function change_password_url() {
return false;
}

/**
* Prints a form for configuring this authentication plugin.
*
Expand Down
15 changes: 12 additions & 3 deletions auth/none/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,22 @@ function can_change_password() {
}

/**
* Returns the URL for changing the user's pw, or false if the default can
* Returns the URL for changing the user's pw, or empty if the default can
* be used.
*
* @return bool
* @return string
*/
function change_password_url() {
return false;
return '';
}

/**
* Returns true if plugin allows resetting of internal password.
*
* @return bool
*/
function can_reset_password() {
return true;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions auth/pam/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ function auth_plugin_pam() {
* Returns true if the username and password work and false if they are
* wrong or don't exist.
*
* @param string $username The username
* @param string $password The password
* @param string $username The username (with system magic quotes)
* @param string $password The password (with system magic quotes)
* @return bool Authentication success or failure.
*/
function user_login ($username, $password) {
Expand All @@ -70,7 +70,7 @@ function user_login ($username, $password) {

// call_time_pass_reference of errormessage is deprecated - throws warnings in multiauth
//if (pam_auth($username, $password, &$errormessage)) {
if (pam_auth($username, $password)) {
if (pam_auth(stripslashes($username), strislashes($password))) {
return true;
}
else {
Expand Down
11 changes: 5 additions & 6 deletions auth/pop3/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function auth_plugin_pop3() {
* Returns true if the username and password work and false if they are
* wrong or don't exist.
*
* @param string $username The username
* @param string $password The password
* @param string $username The username (with system magic quotes)
* @param string $password The password (with system magic quotes)
* @return bool Authentication success or failure.
*/
function user_login($username, $password) {
Expand Down Expand Up @@ -72,7 +72,7 @@ function user_login($username, $password) {
}

error_reporting(0);
$connection = imap_open($host, $username, $password);
$connection = imap_open($host, stripslashes($username), stripslashes($password));
error_reporting($CFG->debug);

if ($connection) {
Expand All @@ -99,7 +99,7 @@ function is_internal() {
* @return bool
*/
function can_change_password() {
return false;
return !empty($this->config->changepasswordurl);
}

/**
Expand All @@ -109,8 +109,7 @@ function can_change_password() {
* @return bool
*/
function change_password_url() {
return $CFG->changepasswordurl; // TODO: will this be global?
//return $this->config->changepasswordurl;
return $this->config->changepasswordurl;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions auth/radius/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function auth_plugin_radius() {
* Returns true if the username and password work and false if they are
* wrong or don't exist.
*
* @param string $username The username
* @param string $password The password
* @param string $username The username (with system magic quotes)
* @param string $password The password (with system magic quotes)
* @return bool Authentication success or failure.
*/
function user_login ($username, $password) {
Expand All @@ -52,7 +52,7 @@ function user_login ($username, $password) {
// printf("nasport: $this->config->nasport <br/>");
// printf("secret: $this->config->secret <br/>");

$rauth = new Auth_RADIUS_PAP($username, $password);
$rauth = new Auth_RADIUS_PAP(stripslashes($username), stripslashes($password));
$rauth->addServer($this->config->host, $this->config->nasport, $this->config->secret);

if (!$rauth->start()) {
Expand Down
Loading

0 comments on commit 430759a

Please sign in to comment.