2 /** External authentication via WebID for FusionForge
3 * Copyright 2011, Roland Mas
4 * Copyright 2011, Olivier Berger & Institut Telecom
6 * This program was developped in the frame of the COCLICO project
7 * (http://www.coclico-project.org/) with financial support of the Paris
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 // FIXME : WTF ?!?!?!?
27 Header( "Expires: Wed, 11 Nov 1998 11:11:11 GMT");
28 Header( "Cache-Control: no-cache");
29 Header( "Cache-Control: must-revalidate");
31 require_once '../../../www/env.inc.php';
32 require_once $gfcommon.'include/pre.php';
33 require_once '../../../www/include/login-form.php';
36 require_once 'WebIDDelegatedAuth/lib/Authentication.php';
38 $plugin = plugin_get_object('authwebid');
40 $return_to = getStringFromRequest('return_to');
41 //$login = getStringFromRequest('login');
43 //$webid_identifier = getStringFromRequest('webid');
44 $triggered = getIntFromRequest('triggered');
46 if (forge_get_config('use_ssl') && !session_issecure()) {
47 //force use of SSL for login
49 session_redirect_external('https://'.getStringFromServer('HTTP_HOST').getStringFromServer('REQUEST_URI'));
52 // TODO check error param in request
53 if ( $plugin->justBeenAuthenticatedByIdP() ) {
54 //echo "authenticated as :";
55 //print_r($plugin->delegatedAuthentifier);
59 if ($plugin->isSufficient()) {
62 $username = $plugin->getUserNameFromWebIDIdentity($plugin->getCurrentWebID());
64 $user_tmp = user_get_object_by_name($username);
65 if($user_tmp->usesPlugin($plugin->name)) {
66 $user = $plugin->startSession($username);
69 $warning_msg = _('WebID plugin not activated for the user account');
74 $feedback = _('The IdP has confirmed that you own this WebID bound to your account. Welcome.');
75 // redirect to the proper place in the forge
77 validate_return_to($return_to);
79 session_redirect($return_to);
81 session_redirect("/my");
85 $warning_msg = sprintf (_("Unknown user with identity '%s'"),$plugin->getCurrentWebID());
90 echo "error :". $plugin->delegatedAuthentifier->authnDiagnostic;
91 print_r($plugin->delegatedAuthentifier);
96 // Otherwise, display the login form again
97 display_login_page($return_to, $triggered);
101 // c-file-style: "bsd"