Exemplo n.º 1
0
$dest = $dest && (!strstr($dest, 'login.php') && !strstr($dest, 'ajax.php')) ? $dest : 'index.php';
$show_reset = false;
if ($_POST) {
    // Lookup support backends for this staff
    $username = trim($_POST['userid']);
    if ($user = StaffAuthenticationBackend::process($username, $_POST['passwd'], $errors)) {
        session_write_close();
        Http::redirect($dest);
        require_once 'index.php';
        //Just incase header is messed up.
        exit;
    }
    $msg = $errors['err'] ? $errors['err'] : 'Invalid login';
    $show_reset = true;
} elseif ($_GET['do']) {
    switch ($_GET['do']) {
        case 'ext':
            // Lookup external backend
            if ($bk = StaffAuthenticationBackend::getBackend($_GET['bk'])) {
                $bk->triggerAuth();
            }
    }
    Http::redirect('login.php');
} elseif (!$thisstaff || !($thisstaff->getId() || $thisstaff->isValid())) {
    if (($user = StaffAuthenticationBackend::processSignOn($errors, false)) && $user instanceof StaffSession) {
        @header("Location: {$dest}");
    }
}
define("OSTSCPINC", TRUE);
//Make includes happy!
include_once INCLUDE_DIR . 'staff/login.tpl.php';
Exemplo n.º 2
0
 function addRemoteCollaborator($tid, $bk, $id)
 {
     global $thisstaff;
     if (!($ticket = Ticket::lookup($tid)) || !$ticket->checkStaffAccess($thisstaff)) {
         Http::response(404, 'No such ticket');
     } elseif (!$bk || !$id) {
         Http::response(422, 'Backend and user id required');
     } elseif (!($backend = StaffAuthenticationBackend::getBackend($bk))) {
         Http::response(404, 'User not found');
     }
     $user_info = $backend->lookup($id);
     $form = UserForm::getUserForm()->getForm($user_info);
     $info = array();
     if (!$user_info) {
         $info['error'] = 'Unable to find user in directory';
     }
     return self::_addcollaborator($ticket, null, $form, $info);
 }
Exemplo n.º 3
0
 function getAuthBackend()
 {
     list($authkey, ) = explode(':', $this->getAuthKey());
     return StaffAuthenticationBackend::getBackend($authkey);
 }
Exemplo n.º 4
0
            </span>
            </div>
<?php 
        }
        ?>
        </a><?php 
    }
    function triggerAuth()
    {
        $_SESSION['ext:bk:class'] = get_class($this);
    }
}
Signal::connect('api', function ($dispatcher) {
    $dispatcher->append(url('^/auth/ext$', function () {
        if ($class = $_SESSION['ext:bk:class']) {
            $bk = StaffAuthenticationBackend::getBackend($class::$id) ?: UserAuthenticationBackend::getBackend($class::$id);
            if ($bk instanceof ExternalAuthentication) {
                $bk->triggerAuth();
            }
        }
    }));
});
abstract class UserAuthenticationBackend extends AuthenticationBackend
{
    private static $_registry = array();
    static function _register($class)
    {
        static::$_registry[$class::$id] = $class;
    }
    static function allRegistered()
    {