* Removed -f parameter from mail() usage, likely to cause failures and bounces.
* (bug 2130) Fixed interwiki links with fragments
* (bug 684) Accept an attribute parameter array on parser hook tags
+* (bug 814) Integrate AuthPlugin changes to support Ryan Lane's external
+ LDAP authentication plugin
=== Caveats ===
return false;
}
+ /**
+ * Modify options in the login template.
+ *
+ * @param UserLoginTemplate $template
+ * @access public
+ */
+ function modifyUITemplate( &$template ) {
+ # Override this!
+ $template->set( 'usedomain', false );
+ }
+
+ /**
+ * Set the domain this plugin is supposed to use when authenticating.
+ *
+ * @param string $domain
+ * @access public
+ */
+ function setDomain( $domain ) {
+ $this->domain = $domain;
+ }
+
+ /**
+ * Check to see if the specific domain is a valid domain.
+ *
+ * @param string $domain
+ * @return bool
+ * @access public
+ */
+ function validDomain( $domain ) {
+ # Override this!
+ return true;
+ }
+
+ /**
+ * When a user logs in, optionally fill in preferences and such.
+ * For instance, you might pull the email address or real name from the
+ * external user database.
+ *
+ * The User object is passed by reference so it can be modified; don't
+ * forget the & on your function declaration.
+ *
+ * @param User $user
+ * @access public
+ */
+ function updateUser( &$user ) {
+ # Override this and do something
+ return true;
+ }
+
+
/**
* Return true if the wiki should create a new local account automatically
* when asked to login a user who doesn't exist locally but does in the
return false;
}
+ /**
+ * Set the given password in the authentication database.
+ * Return true if successful.
+ *
+ * @param string $password
+ * @return bool
+ * @access public
+ */
+ function setPassword( $password ) {
+ return true;
+ }
+
+ /**
+ * Update user information in the external authentication database.
+ * Return true if successful.
+ *
+ * @param User $user
+ * @return bool
+ * @access public
+ */
+ function updateExternalDB( $user ) {
+ return true;
+ }
+
+ /**
+ * Check to see if external accounts can be created.
+ * Return true if external accounts can be created.
+ * @return bool
+ * @access public
+ */
+ function canCreateAccounts() {
+ return false;
+ }
+
+ /**
+ * Add a user to the external authentication database.
+ * Return true if successful.
+ *
+ * @param User $user
+ * @param string $password
+ * @return bool
+ * @access public
+ */
+ function addUser( $user, $password ) {
+ return true;
+ }
+
+
/**
* Return true to prevent logins that don't authenticate here from being
* checked against the local database's password fields.
}
}
-?>
\ No newline at end of file
+?>
global $wgUser, $wgLang, $wgOut;
global $wgEnableUserEmail, $wgEnableEmail;
global $wgEmailAuthentication, $wgMinimalPasswordLength;
+ global $wgAuth;
+
if ( '' != $this->mNewpass ) {
if ( $this->mNewpass != $this->mRetypePass ) {
$this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
return;
}
+ if (!$wgAuth->setPassword( $wgUser, $this->mNewpass )) {
+ $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
+ return;
+ }
$wgUser->setPassword( $this->mNewpass );
}
$wgUser->setRealName( $this->mRealName );
foreach ( $this->mToggles as $tname => $tvalue ) {
$wgUser->setOption( $tname, $tvalue );
}
+ if (!$wgAuth->updateExternalDB($wgUser)) {
+ $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
+ return;
+ }
$wgUser->setCookies();
$wgUser->saveSettings();
class LoginForm {
var $mName, $mPassword, $mRetype, $mReturnto, $mCookieCheck, $mPosted;
var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
- var $mLoginattempt, $mRemember, $mEmail;
+ var $mLoginattempt, $mRemember, $mEmail, $mDomain;
/**
* Constructor
*/
function LoginForm( &$request ) {
global $wgLang, $wgAllowRealName, $wgEnableEmail;
+ global $wgAuth;
$this->mName = $request->getText( 'wpName' );
$this->mPassword = $request->getText( 'wpPassword' );
$this->mRetype = $request->getText( 'wpRetype' );
+ $this->mDomain = $request->getText( 'wpDomain' );
$this->mReturnto = $request->getVal( 'returnto' );
$this->mCookieCheck = $request->getVal( 'wpCookieCheck' );
$this->mPosted = $request->wasPosted();
} else {
$this->mRealName = '';
}
-
+
+ if( !$wgAuth->validDomain( $this->mDomain ) ) {
+ $this->mDomain = 'invaliddomain';
+ }
+ $wgAuth->setDomain( $this->mDomain );
+
# When switching accounts, it sucks to get automatically logged out
if( $this->mReturnto == $wgLang->specialPage( 'Userlogout' ) ) {
$this->mReturnto = '';
global $wgMaxNameChars;
global $wgMemc, $wgAccountCreationThrottle, $wgDBname, $wgIP;
global $wgMinimalPasswordLength;
+ global $wgAuth;
+
+ // If the user passes an invalid domain, something is fishy
+ if( !$wgAuth->validDomain( $this->mDomain ) ) {
+ $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
+ return false;
+ }
+
+ // If we are not allowing users to login locally, we should
+ // be checking to see if the user is actually able to
+ // authenticate to the authentication server before they
+ // create an account (otherwise, they can create a local account
+ // and login as any domain user). We only need to check this for
+ // domains that aren't local.
+ if( 'local' != $this->mDomain && '' != $this->mDomain ) {
+ if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName ) || !$wgAuth->authenticate( $this->mName, $this->mPassword ) ) ) {
+ $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
+ return false;
+ }
+ }
+
+
if (!$wgUser->isAllowedToCreateAccount()) {
$this->userNotPrivilegedMessage();
}
}
+ if( !$wgAuth->addUser( $u, $this->mPassword ) ) {
+ $this->mainLoginForm( wfMsg( 'externaldberror' ) );
+ return false;
+ }
+
return $this->initUser( $u );
}
*/
function processLogin() {
global $wgUser;
+ global $wgAuth;
if ( '' == $this->mName ) {
$this->mainLoginForm( wfMsg( 'noname' ) );
}
$u->setOption( 'rememberpassword', $r );
+ $wgAuth->updateUser( $u );
+
$wgUser = $u;
$wgUser->setCookies();
function mainLoginForm( $err ) {
global $wgUser, $wgOut, $wgLang;
global $wgDBname, $wgAllowRealName, $wgEnableEmail;
+ global $wgAuth;
if ( '' == $this->mName ) {
if ( $wgUser->isLoggedIn() ) {
$template->set( 'retype', $this->mRetype );
$template->set( 'email', $this->mEmail );
$template->set( 'realname', $this->mRealName );
+ $template->set( 'domain', $this->mDomain );
$template->set( 'action', $titleObj->getLocalUrl( $q ) );
$template->set( 'error', $err );
$template->set( 'userealname', $wgAllowRealName );
$template->set( 'useemail', $wgEnableEmail );
$template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember );
+ $wgAuth->modifyUITemplate( $template );
$wgOut->setPageTitle( wfMsg( 'userlogin' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
* @return bool True if the given password is correct otherwise False.
*/
function checkPassword( $password ) {
- global $wgAuth;
+ global $wgAuth, $wgMinimalPasswordLength;
$this->loadFromDatabase();
+
+ // Even though we stop people from creating passwords that
+ // are shorter than this, doesn't mean people wont be able
+ // to. Certain authentication plugins do NOT want to save
+ // domain passwords in a mysql database, so we should
+ // check this (incase $wgAuth->strict() is false).
+ if( strlen( $password ) < $wgMinimalPasswordLength ) {
+ return false;
+ }
if( $wgAuth->authenticate( $this->getName(), $password ) ) {
return true;
value="<?php $this->msg('login') ?>" />
</td>
</tr>
+ <?php if( $this->data['usedomain'] ) {
+ $doms = "";
+ foreach( $this->data['domainnames'] as $dom ) {
+ $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
+ }
+ ?>
+ <tr>
+ <td align='right'><?php $this->msg( 'yourdomainname' ) ?>:</td>
+ <td align='left'>
+ <select tabindex='11' name="wpDomain" value="<?php $this->text( 'domain' ) ?>">
+ <?php echo $doms ?>
+ </select>
+ </td>
+ </tr>
+ <?php } ?>
<?php if( $this->data['create'] ) { ?>
<tr>
<td colspan='3'> </td>
}
}
-?>
\ No newline at end of file
+?>
'yourpasswordagain' => 'Retype password',
'newusersonly' => ' (new users only)',
'remembermypassword' => 'Remember my password across sessions.',
+'yourdomainname' => 'Your domain',
+'externaldberror' => 'There was either an external authentication database error or you are not allowed to update your external account.',
'loginproblem' => '<b>There has been a problem with your login.</b><br />Try again!',
'alreadyloggedin' => "<font color=red><b>User $1, you are already logged in!</b></font><br />\n",