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