3 * FusionForge AuthCas login page
5 * This is main login page. It takes care of different account states
6 * (by disallowing logging in with non-active account, with appropriate
9 * Copyright 1999-2001 (c) VA Linux Systems
10 * Copyright 2011, Roland Mas
12 * This file is part of FusionForge.
14 * FusionForge is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * FusionForge is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with FusionForge; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 // FIXME : WTF ?!?!?!?
30 Header( "Expires: Wed, 11 Nov 1998 11:11:11 GMT");
31 Header( "Cache-Control: no-cache");
32 Header( "Cache-Control: must-revalidate");
34 require_once('../../../www/env.inc.php');
35 require_once $gfcommon.'include/pre.php';
37 $plugin = plugin_get_object('authcas');
39 $return_to = getStringFromRequest('return_to');
40 $login = getStringFromRequest('login');
41 $postcas = getStringFromRequest('postcas');
42 $feedback = htmlspecialchars(getStringFromRequest('feedback'));
43 $warning_msg = htmlspecialchars(getStringFromRequest('warning_msg'));
44 $error_msg = htmlspecialchars(getStringFromRequest('error_msg'));
45 $triggered = getIntFromRequest('triggered');
51 $tmpreturn=explode('?',$return_to);
52 $rtpath = $tmpreturn[0] ;
54 if (@is_file(forge_get_config('url_root').$rtpath)
55 || @is_dir(forge_get_config('url_root').$rtpath)
56 || (strpos($rtpath,'/projects') == 0)
57 || (strpos($rtpath,'/plugins/mediawiki') == 0)) {
65 if (forge_get_config('use_ssl') && !session_issecure()) {
66 //force use of SSL for login
68 header('Location: https://'.getStringFromServer('HTTP_HOST').getStringFromServer('REQUEST_URI'));
71 // Here comes CAS standard magic (which will redirect to the CAS server, etc.)
75 if (phpCAS::isAuthenticated()) {
76 if ($plugin->isSufficient()) {
77 $plugin->startSession(phpCAS::getUser());
80 header ("Location: " . util_make_url($return_to));
83 header ("Location: " . util_make_url("/my"));
87 if ($login) { // The user just clicked the Login button
88 // Let's send them to CAS
90 $return_url = util_make_url('/plugins/authcas/post-login.php?postcas=true&return_to='.htmlspecialchars($return_to));
92 $GLOBALS['PHPCAS_CLIENT']->setURL($return_url);
94 phpCAS::forceAuthentication();
96 } elseif ($postcas) { // The user is coming back from CAS
97 if (phpCAS::isAuthenticated()) {
98 if ($plugin->isSufficient()) {
99 $plugin->startSession(phpCAS::getUser());
102 header ("Location: " . util_make_url($return_to));
105 header ("Location: " . util_make_url("/my"));
112 // Otherwise, display the login form again
114 $HTML->header(array('title'=>'Login'));
117 $params['return_to'] = $return_to;
118 plugin_hook('display_auth_form');
120 $HTML->footer(array());
124 // c-file-style: "bsd"