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