1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
<?php
/**
* FusionForge authentication management
*
* Copyright 2011, Roland Mas
* Copyright 2014, Franck Villaume - TrivialDev
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software
* Foundation; either version 2 of the Licence, or (at your option)
* any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with FusionForge; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* Default authentication mechanism based on DB user's password storage
*
*/
class AuthBuiltinPlugin extends ForgeAuthPlugin {
/**
* AuthBuiltinPlugin() - constructor
*
*/
function AuthBuiltinPlugin() {
$this->ForgeAuthPlugin();
$this->name = 'authbuiltin';
$this->text = 'Built-in authentication';
$this->_addHook('check_auth_session');
$this->_addHook('fetch_authenticated_user');
$this->_addHook('display_auth_form');
// display_create_user_form - display a form to create a user from external auth
// sync_account_info - sync identity from external source (realname, email, etc.)
// get_extra_roles - add new roles not necessarily stored in the database
// restrict_roles - filter out unwanted roles
$this->_addHook('close_auth_session');
$this->declareConfigVars();
}
/**
* Display a form to input credentials : default login dialog ('display_auth_form' hook)
* @param unknown_type $params
* @return boolean
*/
function displayAuthForm(&$params) {
if (!$this->isRequired() && !$this->isSufficient()) {
return true;
}
$return_to = $params['return_to'];
$loginname = '';
$result = '';
$result .= '<p>';
$result .= _('Cookies must be enabled past this point.');
$result .= '</p>';
$result .= '<form action="' . util_make_url('/plugins/authbuiltin/post-login.php') . '" method="post">
<input type="hidden" name="form_key" value="' . form_generate_key() . '"/>
<input type="hidden" name="return_to" value="' . htmlspecialchars(stripslashes($return_to)) . '" />
<p>';
if (forge_get_config('require_unique_email')) {
$result .= _('Login name or email address')._(':');
} else {
$result .= _('Login Name')._(':');
}
$result .= '<br /><input type="text" name="form_loginname" value="' . htmlspecialchars(stripslashes($loginname)) . '" required="required" /></p><p>' . _('Password')._(':') . '<br /><input type="password" name="form_pw" required="required" /></p><p><input type="submit" name="login" value="' . _('Login') . '" />
</p>
</form>' ;
$result .= '<p>' . util_make_link('/account/lostpw.php', _('[Lost your password?]')) . '</p>';
// hide "new account" item if restricted to admin
if (!forge_get_config ('user_registration_restricted')) {
$result .= '<p>' . util_make_link('/account/register.php', _('New Account')) . '</p>';
}
$result .= '<p>' . util_make_link('/account/pending-resend.php', _('Resend confirmation email to a pending account')) . '</p>';
$params['html_snippets'][$this->name] = $result;
}
}
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
|