ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAuthApache.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program 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. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 define ('APACHE_AUTH_TYPE_DIRECT_MAPPING', 1);
25 define ('APACHE_AUTH_TYPE_EXTENDED_MAPPING', 2);
26 define ('APACHE_AUTH_TYPE_BY_FUNCTION', 3);
27 
35 class ilAuthApache extends Auth
36 {
38 
44  public function supportsRedirects()
45  {
46  return true;
47  }
48 
55  public function __construct($a_container,$a_addition_options = array())
56  {
57  global $lng;
58 
59  parent::__construct($a_container,$a_addition_options,'',false);
60  $this->setSessionName("_authhttp".md5(CLIENT_ID));
61 
62  $this->apache_settings = new ilSetting('apache_auth');
63 
64  if (defined('IL_CERT_SSO') && IL_CERT_SSO) {
65  // DO NOT DELETE!!!
66  // faking post values is REQUIRED to avoid canceling of the
67  // startup routines
68  // $_POST['username'] = 'xxx';
69  $_POST['password'] = 'yyy';
70  $_POST['sendLogin'] = '1';
71  $_POST['auth_mode'] = AUTH_APACHE;
72  $_POST['cmd[butSubmit]'] = 'Submit';
73 
74  if ($_POST['username'] != 'anonymous') {
75 
76  switch($this->apache_settings->get('apache_auth_username_config_type'))
77  {
79  $_POST['username'] = $_SERVER[$this->apache_settings->get('apache_auth_username_direct_mapping_fieldname')];
80  break;
82  throw new ilException("APACHE_AUTH_TYPE_EXTENDED_MAPPING not yet implemented");
84  include_once 'Services/AuthApache/classes/custom_username_func.php';
85  $_POST['username'] = ApacheCustom::getUsername();
86  break;
87  }
88 
89  }
90  }
91 
92  if (defined('IL_CERT_SSO') && IL_CERT_SSO && !$_POST['username']) {
93  $_POST['username'] = '§invalid';
94  $_POST['password'] = 'anonymous';
95  $_SESSION['username_invalid'] = true;
96  }
97 
98  $this->initAuth();
99  }
100 
101 
102  public function login() {
103  global $ilIliasIniFile, $ilias;
104 
105  if (!$this->apache_settings->get('apache_auth_authenticate_on_login_page') && preg_match('/.*login\.php$/', $_SERVER['SCRIPT_NAME'])) {
106  return;
107  }
108 
109  if (!isset($_GET['passed_sso']) && (!defined('IL_CERT_SSO') || IL_CERT_SSO == false)) {
110 
111  // redirect to sso
112  // this part is executed in default ilias context...
113 
114  $path = $_SERVER['REQUEST_URI'];
115 
116  if ($path{0} == '/') {
117  $path = substr($path, 1);
118  }
119 
120  if (substr($path, 0, 4) != 'http') {
121  $parts = parse_url(ILIAS_HTTP_PATH);
122  $path = $parts['scheme'] . '://' . $parts['host'] . '/' . $path;
123  }
124  ilUtil::redirect(ilUtil::getHtmlPath('/sso/index.php?force_mode_apache=1&r=' . $path . '&cookie_path='.IL_COOKIE_PATH . '&ilias_path=' . ILIAS_HTTP_PATH));
125  exit;
126  }
127  else {
128  return parent::login();
129  }
130  }
131 }