diff --git a/include/class.config.php b/include/class.config.php
index 4114cfca..54d0e0fe 100644
--- a/include/class.config.php
+++ b/include/class.config.php
@@ -719,6 +719,62 @@ function getUploadDir() {
return $this->get('upload_dir');
}
+ /**
+ * Returns true if HTTP pass-though authentication is enabled, otherwise false.
+ *
+ * Configuration: allow_http_auth
+ *
+ * @return bool
+ */
+ function allowHttpAuth() {
+ return (int)$this->get('allow_http_auth') === 1;
+ }
+
+ /**
+ * Returns true if users that pass through HTTP authentication should be automatically created, otherwise false.
+ *
+ * Configuration: auto_create_users
+ *
+ * @return bool
+ */
+ function autoCreateUsers() {
+ return (int)$this->get('auto_create_users') === 1;
+ }
+
+ /**
+ * Default domain for users when auto-created.
+ *
+ * Configuration: default_email_domain
+ *
+ * @return string
+ */
+ function defaultEmailDomain() {
+ return $this->get('default_email_domain');
+ }
+
+ /**
+ * Default timezone id.
+ *
+ * Configuration: default_timezone_id
+ *
+ * @return int
+ */
+ function defaultTimezoneId() {
+ return $this->get('default_timezone_id');
+ }
+
+
+ /**
+ * Returns the id of the default group automatically created users should use.
+ *
+ * Configuration: default_group_id
+ *
+ * @return int
+ */
+ function defaultGroupId() {
+ return $this->get('default_group_id');
+ }
+
function updateSettings($vars, &$errors) {
if(!$vars || $errors)
@@ -800,6 +856,10 @@ function updateSystemSettings($vars, &$errors) {
'daydatetime_format'=>$vars['daydatetime_format'],
'default_timezone_id'=>$vars['default_timezone_id'],
'enable_daylight_saving'=>isset($vars['enable_daylight_saving'])?1:0,
+ 'allow_http_auth'=>isset($vars['allow_http_auth'])?1:0,
+ 'auto_create_users'=>isset($vars['auto_create_users'])?1:0,
+ 'default_group_id'=>$vars['default_group_id'],
+ 'default_email_domain'=>$vars['default_email_domain']
));
}
diff --git a/include/staff/firstlogin.php b/include/staff/firstlogin.php
new file mode 100644
index 00000000..a657403b
--- /dev/null
+++ b/include/staff/firstlogin.php
@@ -0,0 +1,122 @@
+getInfo();
+$info['id']=$thisstaff->getId();
+$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
+?>
+
diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php
index 2e0fe9e5..d7f8b714 100644
--- a/include/staff/header.inc.php
+++ b/include/staff/header.inc.php
@@ -41,7 +41,7 @@
?>
diff --git a/include/staff/settings-system.inc.php b/include/staff/settings-system.inc.php
index 8dd170e4..6d455add 100644
--- a/include/staff/settings-system.inc.php
+++ b/include/staff/settings-system.inc.php
@@ -117,7 +117,7 @@
Authentication Settings
- Password Change Policy:
+ |
Password Change Policy: |
|
- Allow Password Resets:
+ |
Allow Password Resets: |
>
Enables the Forgot my password link on the staff
control panel
|
- Password Reset Window:
+ |
Password Reset Window: |
@@ -203,6 +203,46 @@
(binds staff session to originating IP address upon login)
|
+
+
+ HTTP Authentication
+ |
+
+ Enabled: |
+
+ >
+ Enables HTTP pass-though authentication
+ |
+
+ Auto Create Users: |
+
+ >
+ Automatically creates users in osTicket if they do not exist
+ |
+
+ Default Group: |
+
+
+ |
+
+ Default Email Domain: |
+
+
+ example.net
+ |
+
+
Date and Time Options: Please refer to PHP Manual for supported parameters.
diff --git a/scp/firstlogin.php b/scp/firstlogin.php
new file mode 100644
index 00000000..aec2bb4c
--- /dev/null
+++ b/scp/firstlogin.php
@@ -0,0 +1,44 @@
+
+ Copyright (c) 2006-2013 osTicket
+ http://www.osticket.com
+
+ Released under the GNU General Public License WITHOUT ANY WARRANTY.
+ See LICENSE.TXT for details.
+
+ vim: expandtab sw=4 ts=4 sts=4:
+**********************************************************************/
+require('staff.inc.php');
+
+$staff = $thisstaff;
+
+if($_POST){
+ $vars = $_POST;
+ $vars['id'] = $staff->getId();
+ $vars['username'] = $staff->getUserName();
+ $vars['dept_id'] = $staff->getDeptId();
+ $vars['group_id'] = $staff->getGroupId();
+ $vars['isadmin'] = '0';
+ $vars['isactive'] = '1';
+
+ if($staff->update($vars,$errors)){
+ $msg='Staff updated successfully';
+ }elseif(!$errors['err']){
+ $errors['err']='Unable to update staff. Correct any error(s) below and try again!';
+ }
+}
+
+$page='firstlogin.php';
+//if($staff || ($_REQUEST['a'] && !strcasecmp($_REQUEST['a'],'add')))
+// $page='staff.inc.php';
+
+$nav->setTabActive('staff');
+require(STAFFINC_DIR.'header.inc.php');
+require(STAFFINC_DIR.$page);
+include(STAFFINC_DIR.'footer.inc.php');
+?>
diff --git a/scp/staff.inc.php b/scp/staff.inc.php
index 0c835d46..bda8cc0e 100644
--- a/scp/staff.inc.php
+++ b/scp/staff.inc.php
@@ -57,6 +57,55 @@ function staffLoginPage($msg) {
}
$thisstaff = new StaffSession($_SESSION['_staff']['userID']); //Set staff object.
+
+if (!$thisstaff->isValid() && isset($_SERVER['AUTH_TYPE']) && $ost->getConfig()->allowHttpAuth()) {
+ $username = $_SERVER['PHP_AUTH_USER'];
+ $id = Staff::getIdByUsername($username);
+
+ $isNew = false;
+ if ($id === null || $id === false) {
+ $isNew = true;
+
+ $config = $ost->getConfig();
+ $vars = array(
+ 'id' => '',
+ 'username' => $username,
+ 'passwd1' => $_SERVER['PHP_AUTH_PW'],
+ 'passwd2' => $_SERVER['PHP_AUTH_PW'],
+ 'firstname' => 'Change',
+ 'lastname' => 'Me',
+ 'email' => sprintf('%s@%s', $username, $config->defaultEmailDomain()),
+ 'phone' => '',
+ 'phone_ext' => '',
+ 'mobile' => '',
+ 'signature' => '',
+ 'isadmin' => '0',
+ 'isactive' => '1',
+ 'group_id' => $config->defaultGroupId(),
+ 'dept_id' => $config->getDefaultDept()->getId(),
+ 'timezone_id' => $config->defaultTimezoneId(),
+ 'daylight_saving' => '1',
+ 'isvisible' => '1',
+ 'notes' => 'Auto-created'
+ );
+
+ $id = Staff::create($vars, $errors);
+ if (is_array($errors) || count($errors) > 0) {
+ var_dump($errors);die();
+ }
+ }
+
+ $thisstaff = new StaffSession($id);
+ Staff::_do_login($thisstaff, null);
+ $thisstaff->session->session_id = session_id();
+ $thisstaff->refreshSession();
+
+ if ($isNew) {
+ require(SCP_DIR.'firstlogin.php');
+ exit;
+ }
+}
+
//1) is the user Logged in for real && is staff.
if(!$thisstaff->getId() || !$thisstaff->isValid()){
if (isset($_SESSION['_staff']['auth']['msg'])) {
@@ -71,6 +120,7 @@ function staffLoginPage($msg) {
staffLoginPage($msg);
exit;
}
+
//2) if not super admin..check system status and group status
if(!$thisstaff->isAdmin()) {
//Check for disabled staff or group!
|