/**
  * Tests
  */
 public function testShouldDisplayAuthView()
 {
     $request = new NeechyRequest();
     $page = Page::find_by_title('logout');
     $handler = new AuthHandler($request, $page);
     $response = $handler->handle();
     $this->assertEquals(200, $response->status);
     $this->assertContains(sprintf('<button class="%s" type="submit">Sign in</button>', 'btn btn-lg btn-primary btn-block'), $response->body);
     $this->assertContains(sprintf('<button class="%s" type="submit">Sign up</button>', 'btn btn-lg btn-primary btn-block'), $response->body);
 }
Beispiel #2
0
 public function pre_process($person)
 {
     parent::pre_process($person);
     if (!is_null($person)) {
         AuthHandler::getAuthManager($this->person)->deAuthenticate(basename($_SERVER['SCRIPT_NAME']));
     }
 }
Beispiel #3
0
 public function pre_process($person)
 {
     parent::pre_process($person);
     $auth = AuthHandler::getAuthManager($this->person);
     $this->discoPath = $auth->getDiscoPath();
     /*
      * Handle country AuthN redirect. Both can redirect, if they don't, show
      * the map.
      */
     $nren = NREN_Handler::getNREN($_SERVER['SERVER_NAME']);
     if (!empty($nren)) {
         $this->redirectToWAYF($nren);
         $this->forwardToDisco($nren);
     }
     /* if not redirected, continue  */
     if (array_key_exists('country', $_GET)) {
         $this->selected_country = htmlentities($_GET['country']);
         $nren = NREN_Handler::getNREN($url, 1);
         echo "redirecting to idp-part for " . $this->selected_country . ", stopping rendering of this page now\n";
         exit(0);
     }
     /* textual view? */
     if (array_key_exists('textual_view', $_GET)) {
         if ($_GET['textual_view'] === "yes") {
             $this->mapMode = false;
         }
     } else {
         /* ok, show map */
         $this->tpl->assign('extraScripts', array('js/jquery-1.6.1.min.js', 'js/jquery-jvectormap-1.1.1.min.js', 'js/jquery-jvectormap-europe-mill-en.js'));
     }
 }
Beispiel #4
0
 /**
  * 
  * @return string The global message, or false if no such exists.
  */
 public static function getGlobalMessage()
 {
     if (AuthHandler::isSessionExisting() && isset($_SESSION[AuthHandler::SESSION_KEY_GLOBAL_MESSAGE])) {
         return $_SESSION[AuthHandler::SESSION_KEY_GLOBAL_MESSAGE];
     }
     return false;
 }
Beispiel #5
0
 /**
  * Get the auth manager based on the request
  *
  * @param $person The person for which the auth_manager should be created
  * @return an instance of Confusa_Auth
  */
 public static function getAuthManager($person)
 {
     if (!isset(AuthHandler::$auth)) {
         if (Config::get_config('auth_bypass') === TRUE) {
             require_once 'Confusa_Auth_Bypass.php';
             AuthHandler::$auth = new Confusa_Auth_Bypass($person);
         } else {
             /* Start the IdP and create the handler */
             require_once 'Confusa_Auth_IdP.php';
             AuthHandler::$auth = new Confusa_Auth_IdP($person);
         }
     }
     return AuthHandler::$auth;
 }
 public static function run($contactId)
 {
     $db = DatabaseHelper::getInstance();
     try {
         $db->beginTransaction();
         if (!$db->deleteRideByContact($contactId)) {
             throw new Exception("Could not delete rides for contact {$contact}`Id");
         }
         if (!$db->deleteContact($contactId)) {
             throw new Exception("Could not delete contact {$contactId}");
         }
         $db->commit();
         AuthHandler::logout();
     } catch (Exception $e) {
         logException($e);
         $db->rollBack();
         throw $e;
     }
 }
Beispiel #7
0
 static function buildNavbar()
 {
     $html = '';
     $role = AuthHandler::getRole();
     $acl = $GLOBALS['acl'];
     $logged = $role !== ROLE_GUEST;
     // Put branding bar if we want one
     if (getConfiguration('branding.enable')) {
         $html .= ViewRenderer::renderToString('views/branding.php');
     }
     $html .= '<div id="navbar">';
     if ($logged) {
         $pages =& self::$pagesMember;
         // Put the right ref on the logout link
         $pages[4]['params'] = array('ref' => Utils::getRunningScript());
         // If we have no ride yet, the name of join.php is still "Join"
         if (!AuthHandler::isRideRegistered()) {
             $pages[1]['name'] = 'Join';
         }
     } else {
         $pages =& self::$pagesGuest;
     }
     $str = '<ol>';
     foreach ($pages as $page) {
         if ($acl->isAllowed($role, $page['href'])) {
             $str .= '<li><a href="' . Utils::buildLocalUrl($page['href'], isset($page['params']) ? $page['params'] : null) . '" ';
             if ($page['href'] == Utils::getRunningScript()) {
                 $str .= 'class="selected"';
             }
             $str .= '>' . _($page['name']) . '</a></li>';
         }
     }
     $str .= '</ol>';
     $html .= $str;
     $html .= self::buildLanguageSelector();
     $html .= self::buildRegionSelector();
     $html .= '<div class="clearFloat"></div></div>';
     return $html;
 }
/*
 * Set configuration for client_id, client_secret and various OAuth endpoints
 */
require_once 'config.php';
/*
 * Include class which handles requests to the Drive API
 */
require_once 'drive_handler.php';
/**
 * Indicate the request type as a web API request.  This prevents the 
 * authorization logic from redirecting the user in case of failures, and
 * instead returns HTTP error codes for interpretation by the JavaScript.
 */
$requestType = 'webapi';
require_once 'auth_handler.php';
$authHandler = new AuthHandler($requestType);
$authHandler->VerifyAuth();
header('Content-type: application/json');
$driveHandler = new DriveHandler($_SESSION['credentials']);
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $file = $driveHandler->GetFile($_GET['file_id']);
    echo $file;
} else {
    /**
     * This is a HTTP PUT or POST - save file back to drive
     */
    $handle = fopen('php://input', 'r');
    $contents = stream_get_contents($handle);
    fclose($handle);
    $contentData = json_decode($contents);
    $newFile = $driveHandler->SaveFile($contentData->resource_id, $contentData);
Beispiel #9
0
<?php

include "env.php";
include APP_PATH . "/Bootstrap.php";
$contact = null;
$ref = Utils::getParam('ref');
if (AuthHandler::isLoggedIn()) {
    AuthHandler::logout();
    info('Contact ' . AuthHandler::getLoggedInUserId() . ' logged out');
    GlobalMessage::setGlobalMessage(_('Goodbye!'));
} else {
    warn('User tried to logout without being logged in');
}
if ($ref) {
    // The redirect method is only redirecting to internal pages
    Utils::redirect($ref);
} else {
    Utils::redirect('index.php');
}
Beispiel #10
0
<?php

use views\helpers\PathHelper;
session_start();
require_once dirname(__FILE__) . '/app/views/helpers/PathHelper.php';
$path = new PathHelper();
require_once $path->getModelPath() . 'DBHandler.php';
require_once $path->getModelPath() . 'AuthHandler.php';
require_once $path->getConfigPath() . 'connectionInfo.private.php';
$dbHandler = new DBHandler($host, $user, $password, $db);
$authHandler = new AuthHandler($dbHandler);
?>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>User Notes</title>
    <link rel="shortcut icon" type="image/x-icon" href="<?php 
echo $path->getAssetPath();
?>
/favicon.ico">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="<?php 
echo $path->getAssetPath();
?>
/css/notes.css"/>
</head>
<body>

<header class="header">
    <?php 
Beispiel #11
0
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../css/reset-fonts.css">
<link rel="stylesheet" type="text/css" href="../css/common.css">
<?php 
    if (LocaleManager::getInstance()->isRtl()) {
        ?>
<link rel="stylesheet" type="text/css" href="../css/common_rtl.css">
<?php 
    }
    ?>
<title>Carpool CMS</title>
</head>
<body>
<div id="bd">
<?php 
    echo View_Navbar::buildNavbar(AuthHandler::isLoggedIn());
    echo View_Header::render(_('Carpool CMS'));
    ?>
<div id="content">
<h2><?php 
    echo _('Questions and Answers editor');
    ?>
</h2>
<form id="qaDataForm" action="translations.php" method="post">
	<table style="width: 100%" summary="<?php 
    echo _('Edit existing translations');
    ?>
">
		<tr>
			<th>
    			<span><?php 
<?php

session_start();
require_once 'DBHandler.php';
require_once 'AuthHandler.php';
require_once 'connectionInfo.private.php';
$dbHandler = new DBHandler($host, $user, $password, $db);
$authHandler = new AuthHandler($dbHandler);
?>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Registration for Note Taking App</title>
    <link rel="stylesheet" href="notes.css" />
</head>
<body>

<?php 
if (isset($_POST['submit'])) {
    if (isset($_POST['password']) && isset($_POST['password_confirmation']) && isset($_POST['username'])) {
        if ($_POST['password'] == $_POST['password_confirmation']) {
            if ($authHandler->registerUser($_POST['username'], $_POST['password'])) {
                if ($authHandler->loginUser($_POST['username'], $_POST['password'])) {
                    $success = true;
                    echo '<div class="notification success">Successfully registered, you are now logged in.
                            Forwarding... </div>';
                    // forwards the user to the notes page.
                    echo "<script>\n                            setTimeout(function(){\n                                window.location.href='./notes.php';\n                            },2000);\n                        </script>";
                }
Beispiel #13
0
 public function process()
 {
     if (!$this->person->isNRENAdmin()) {
         $errorTag = PW::create();
         Logger::logEvent(LOG_NOTICE, "NRENAdmin", "process()", "User " . stripslashes($this->person->getX509ValidCN()) . " tried to access the NREN-area", __LINE__, $errorTag);
         $this->tpl->assign('reason', "[{$errorTag}] You are not an NREN-admin");
         $this->tpl->assign('content', $this->tpl->fetch('restricted_access.tpl'));
         return;
     }
     $this->tpl->assign('nrenName', $this->person->getNREN());
     $this->tpl->assign('org_states', ConfusaConstants::$ORG_STATES);
     /* Export the NREN UID key */
     $map = $this->person->getNREN()->getMap();
     $this->tpl->assign('nren_eppn_key', $map['eppn']);
     if (isset($_GET['target'])) {
         switch (Input::sanitize($_GET['target'])) {
             case 'list':
                 /* get all info from database and publish to template */
                 $this->tpl->assign('subscriber_list', $this->getSubscribers());
                 $this->tpl->assign('self_subscriber', $this->person->getSubscriber()->getIdPName());
                 $this->tpl->assign('list_subscribers', true);
                 break;
             case 'add':
                 $am = AuthHandler::getAuthManager($this->person);
                 $attributes = $am->getAttributes();
                 $nren = $this->person->getNREN();
                 if (isset($attributes[$map['epodn']])) {
                     $this->tpl->assign('foundUniqueName', $attributes[$map['epodn']][0]);
                     $this->tpl->assign('nrenOrgAttr', $map['epodn']);
                 }
                 if (isset($attributes[$map['eppn']])) {
                     $this->form_data['eppnAttr'] = $map['eppn'];
                 }
                 $this->tpl->assign('form_data', $this->form_data);
                 $this->tpl->assign('add_subscriber', true);
                 break;
             default:
                 break;
         }
     } else {
         /* get all info from database and publish to template */
         $this->tpl->assign('subscriber_list', $this->getSubscribers());
         $subscriber = $this->person->getSubscriber();
         if (isset($subscriber)) {
             $this->tpl->assign('self_subscriber', $subscriber);
         } else {
             $this->tpl->assign('self_subscriber', '');
             Framework::error_output($this->translateTag('l10n_error_illegalattributemap', 'nrenadmin') . '<a href="attributes.php">' . $this->translateTag('item_attributes', 'menu') . '</a>.');
         }
         $this->tpl->assign('list_subscribers', true);
     }
     /* render page */
     $this->tpl->assign('content', $this->tpl->fetch('nren_admin.tpl'));
 }
Beispiel #14
0
 /**
  * Return the value for the key to an IdP attribute (if defined)
  *
  * @param attr_key string The key of the attribute
  * @return string The value for the supplied attribute key
  */
 private function handleAttrValueAJAX($attr_key)
 {
     if (empty($attr_key)) {
         exit(0);
     }
     $auth = AuthHandler::getAuthManager($this->person);
     $attr_value = @implode(", ", $auth->getAttributeValue($attr_key));
     echo htmlentities("attribute={$attr_value}", ENT_COMPAT, "UTF-8");
     exit(0);
 }
Beispiel #15
0
         throw $e;
     }
     // Add or update ride
     $rideParams = array('SrcCityId' => $srcCityId, 'SrcLocation' => $srcLocation, 'DestCityId' => $destCityId, 'DestLocation' => $destLocation, 'TimeMorning' => $timeMorning, 'TimeEvening' => $timeEvening, 'Comment' => $comment, 'Notify' => $notify, 'Status' => $wantTo, 'Region' => $region);
     if ($isUpdateRide) {
         if ($db->updateRide($rideId, $srcCityId, $srcLocation, $destCityId, $destLocation, $timeMorning, $timeEvening, $comment, $wantTo, $notify, $region)) {
             GlobalMessage::setGlobalMessage(_("Ride successfully updated."));
         } else {
             throw new Exception("Could not update ride");
         }
     } else {
         $rideId = $db->addRide($srcCityId, $srcLocation, $destCityId, $destLocation, $timeMorning, $timeEvening, $contactId, $comment, $wantTo, $notify, $region);
         if (!$rideId) {
             throw new Exception("Could not add ride");
         }
         AuthHandler::updateRegisteredRideStatus(true);
         $mailBody = MailHelper::render(VIEWS_PATH . '/registrationMail.php', array('contact' => $db->getContactById($contactId)));
         Utils::sendMail(Utils::buildEmail($email), $name, getConfiguration('mail.addr'), getConfiguration('mail.display'), getConfiguration('app.name') . ' Registration', $mailBody);
     }
     $db->commit();
     // XXX: Should show interest even if it's update?
     if (!$isUpdateRide && getConfiguration('notify.immediate') == 1) {
         Service_ShowInterest::run($rideId);
     }
     echo json_encode(array('status' => 'ok', 'action' => $action));
 } catch (PDOException $e) {
     $db->rollBack();
     if ($e->getCode() == 23000) {
         // If this is a unique constraint problem - we want to display the correct message
         echo json_encode(array('status' => 'invalid', 'action' => $action, 'messages' => $messages));
     } else {
Beispiel #16
0
<?php

include "env.php";
include APP_PATH . "/Bootstrap.php";
$contact = null;
// TODO: Is this page still relevant? Maybe use the token for quick authentication?
$contactId = Utils::getParam('c');
$identifier = Utils::getParam('i');
$contact = AuthHandler::authByVerification($contactId, $identifier);
if ($contact) {
    try {
        Service_DeleteUser::run(AuthHandler::getLoggedInUserId());
        GlobalMessage::setGlobalMessage(_('Contact successfully deleted.'), GlobalMessage::INFO);
    } catch (Exception $e) {
        GlobalMessage::setGlobalMessage(_('Deletion failed') . ': ' . _('Internal error.'), GlobalMessage::ERROR);
    }
} else {
    GlobalMessage::setGlobalMessage(_('Deletion failed') . ': ' . _('Authentication failed.'), GlobalMessage::ERROR);
}
AuthHandler::logout();
Utils::redirect('index.php');
 /**
  * Accepts a list of XML nodes, each representing an object that must be either created, updated or deleted,
  * depending on the presence of respectively a @created or @deleted attribute. The node names must be equal to that
  * of an entity and the names of the child nodes must be equal to the property names applicable to that entity.
  * Node names are compared case-insensitive.
  *
  * Special attributes are
  *     deleted - Change-index indicating that this is an existing (persisted) object that must be deleted.
  *     id - Object identifier (primary key).
  *
  * Every object-node must have an @id, either permanent (numerical value) or temporary (starting with a non-digit).
  * Temporary ID's will be substituted with the permanent (persisted) ID lateron.
  *
  * Child nodes who's name equals that of an entity are NOT recursively parsed and processed. Only their @id
  * attribute is used to add or update foreign keys.
  *
  * RETURN
  * A map of (temporary and) permanent id's per entity is returned. This map enables the caller to substitute
  * temporary id's at the client side.
  *
  * ERROR
  * It is an error if the name of a given node doesn't match that of an entity, or if the names of child nodes
  * don't match that of properties of the entity.
  *
  * HOW IT WORKS
  * The nodes are scanned recursively (so $xmlElements can be a 'flat' list of object nodes or a nested xml tree or
  * a combination of both) and grouped in three arrays, one with nodes of objects that must be created, changed or
  * deleted. The 'created' group is processed first. The nodes in this group are sorted based on their entity, so the
  * order of creation allows for substituting any foreign key of successively created objects. This is to prevent
  * violating foreign key constraints.
  * Then the 'changed' group is processed. Foreign keys are substitued before updating each object in the database.
  * Foreign keys of objects that are in the 'deleted' group will be set to NULL.
  * Finally the objects in the 'deleted' group are deleted.
  */
 private function processXmlObjects($appName, array $xmlElements, $restResponseCode)
 {
     $schema = $this->metaData->getSchema($appName);
     $this->processQueryParams($schema, NULL);
     $mySQLi = $schema->getMySQLi();
     try {
         $account = PersistentAccount::getAccount($schema, AuthHandler::getSignedInAccountId($appName));
         $audit = new PersistentAudit($schema, $account);
         $objectFetcher = $this->getObjectFetcher($appName);
         $restParser = new RestParser();
         // Parse all nodes...
         $restParser->parse($schema, $xmlElements, $this->temporaryIdMap, $objectFetcher);
         // ...set the foreign key id's...
         $restParser->applyParsedRelationships();
         // ...and divide the ParsedObjects in groups (CREATED, CHANGED, DELETED).
         $restParser->groupParsedObjects($schema, $objectFetcher);
         // Any CHANGED object can have existing (persisted) relationships that don't exist in the parsed dataset.
         // Detect these now.
         $restParser->detectObsoleteConnections($schema, $objectFetcher);
         // Create all CREATED objects.
         foreach ($restParser->getCreatedObjects() as $createdObject) {
             $entity = $createdObject->getEntity();
             // Note: the id of a $createdParsedObject is always a temporary id.
             $temporaryId = $createdObject->getId();
             // Substitute any temporary id's in foreign key properties.
             $createdObject->substituteTemporaryIds($this->temporaryIdMap);
             // Create the object and add the newly created object id to the temporaryIdMap.
             $persistedId = $this->objectModifier->createObject($schema, $entity, $createdObject->getPropertyValues(), $audit);
             $createdObject->setId($persistedId);
             $this->temporaryIdMap->setId($entity, $temporaryId, $persistedId);
         }
         // Update all objects in the CHANGED group.
         foreach ($restParser->getChangedObjects() as $changedObject) {
             if ($changedObject->getScope()->includes(Scope::TAG_PROPERTIES) != Scope::INCLUDES_ALL) {
                 continue;
             }
             $changedObject->substituteTemporaryIds($this->temporaryIdMap);
             $isPersisted = $this->objectModifier->modifyObject($schema, $changedObject->getEntity(), $changedObject->getId(), $changedObject->getPropertyValues(), $audit);
             if ($isPersisted) {
                 $this->temporaryIdMap->setId($changedObject->getEntity(), NULL, $changedObject->getId());
             }
         }
         // Create and/or delete all link-relationships.
         foreach ($restParser->getChangedAndTouchedObjects() as $changedObject) {
             $changedObject->establishLinks($schema, $this->objectModifier, $audit);
         }
         foreach ($restParser->getCreatedObjects() as $createdObject) {
             $createdObject->establishLinks($schema, $this->objectModifier, $audit);
         }
         // Delete all objects in the DELETED group.
         foreach ($restParser->getDeletedObjects() as $deletedObject) {
             $this->objectModifier->deleteObjectTree($schema, $deletedObject->getEntity(), $deletedObject->getId(), $audit);
         }
         // Update the PUBLISHED state.
         foreach ($restParser->getPublishedObjects() as $publishedObject) {
             $this->objectPublisher->publish($schema, $publishedObject->getEntity(), $publishedObject->getId(), $audit);
             // Purge - permanently delete - all 'terminated' objects that are not part of the published data.
             $this->objectModifier->purge($schema, $publishedObject->getEntity(), $publishedObject->getId(), $audit);
         }
         // Commit the database transaction.
         $mySQLi->commit();
         // Save temporaryIds in the session.
         $_SESSION[$this->sessionId] = $this->temporaryIdMap->serializeTemporaryIds();
         return new RestResponse($restResponseCode, $this->temporaryIdMap);
     } catch (Exception $e) {
         Bootstrap::logException($e);
         $mySQLi->rollback();
         return new RestResponse(RestResponse::SERVER_ERROR, $e);
     }
 }
<?php

error_reporting(E_ALL);
// AuthHandler Testclass
$DOC_ROOT = $_SERVER['DOCUMENT_ROOT'];
$USER_DIR = '/martin';
$PROJECT_NAME = '/hem';
$APP_ROOT = $DOC_ROOT . $USER_DIR . $PROJECT_NAME;
$PEAR_DIR = $APP_ROOT . '/pear';
$APP_FRAMEWORK_DIR = $APP_ROOT . '/framework';
$PATH = $PEAR_DIR . ":" . $APP_FRAMEWORK_DIR;
ini_set('include_path', ':' . $PATH . ':' . ini_get('include_path'));
$DB_URL = 'mysql://*****:*****@localhost/testlu';
require_once 'class.AuthHandler.php';
$auth_handler = new AuthHandler(array('auth_dsn' => $DB_URL, 'auth_session_name' => 'PHPSESSION', 'auth_exit_page' => $_SERVER['SCRIPT_NAME']));
if ($auth_handler->isAuthenticated()) {
    echo "You're in: " . $auth_handler->getUserName() . "<br/>";
    $_SESSION['SESSION_USERNAME'] = $auth_handler->getUserName();
    echo "<a href=\"" . $_SERVER['SCRIPT_NAME'] . "?logout=1\">Logout</a>";
} else {
    echo "<form name='loginForm' action='" . $_SERVER['SCRIPT_NAME'] . "' method=\"post\">";
    echo "Username:<input type=\"text\" name=\"handle\" value=\"\" /><br/>";
    echo "Password:<input type=\"password\" name=\"passwd\" /><br/>";
    echo "Remember me <input type=\"checkbox\" name=\"rememberMe\" /><br/>";
    echo "<input type=\"submit\" value=\"Log-in\" />";
    echo "</form>";
}
Beispiel #19
0
 /**
  * @throws CGE_CriticalAttributeException If an attribute needed for the operation of Confusa is not found
  * @throws MapNotFoundException If the NREN-map for the attributes is not found
  */
 public function authenticate()
 {
     /* if login, trigger SAML-redirect first */
     $auth = AuthHandler::getAuthManager($this->person);
     $authRequired = $this->contentPage->is_protected() || isset($_GET['start_login']) && $_GET['start_login'] === 'yes';
     $auth->authenticate($authRequired);
     /* show a warning if the person does not have Confusa
      * entitlement and ConfusaAdmin entitlement */
     if ($this->person->isAuth()) {
         if ($this->person->testEntitlementAttribute(Config::get_config('entitlement_user')) == false) {
             if ($this->person->testEntitlementAttribute(Config::get_config('entitlement_admin')) == false) {
                 $entitlement = Config::get_config('entitlement_namespace') . ":";
                 $entitlement .= Config::get_config('entitlement_user');
                 $msg = $this->contentPage->translateMessageTag('fw_error_entitlement_unset_1');
                 $msg .= "<br /><i>{$entitlement}</i><br /><br />";
                 $msg .= $this->contentPage->translateMessageTag('fw_error_entitlement_unset_2');
                 if (!is_null($this->person->getSubscriber())) {
                     $url = $this->person->getSubscriber()->getHelpURL();
                     $email = $this->person->getSubscriber()->getHelpEmail();
                     $msg .= "<br />\n";
                     $msg .= $this->contentPage->translateMessageTag('fw_error_entitlement_unset_3');
                     $msg .= '<br /><ul><li style="margin: 1em 0 0 2em">';
                     $msg .= $this->contentPage->translateMessageTag('fw_error_entitlement_unset_4');
                     $msg .= "<a href=\"mailto:{$email}\">{$email}</a></li>";
                     $msg .= '<li style="margin: 1em 0 0 2em">';
                     $msg .= $this->contentPage->translateMessageTag('fw_error_entitlement_unset_5');
                     $msg .= "<a href=\"{$url}\">{$url}</a></li>\n</ul><br />\n";
                 }
                 Framework::error_output($msg);
             } else {
                 $entitlement = Config::get_config('entitlement_namespace') . ":";
                 $entitlement = Config::get_config('entitlement_user');
                 $msg = $this->contentPage->translateMessageTag('fw_error_entitlement_unset_1');
                 $msg .= "<br /><i>{$entitlement}</i><br /><br />";
                 $msg .= $this->contentPage->translateMessageTag('fw_error_entitlement_unset_6');
                 Framework::warning_output($msg);
             }
         }
     } else {
         /* maybe we can guess the NREN from the URL */
         $this->person->setNREN(NREN_Handler::getNREN($_SERVER['SERVER_NAME']), 1);
     }
     /*
      * Force reauthentication based on the settings if the session is too
      * old */
     if (Framework::$sensitive_action) {
         $auth->reAuthenticate();
     }
 }
<?php

include "../env.php";
include APP_PATH . "/Bootstrap.php";
if (ENV !== ENV_DEVELOPMENT && (!Utils::IsXhrRequest() || !AuthHandler::isSessionExisting())) {
    die;
}
extract($_GET, EXTR_SKIP);
if (!isset($regionId)) {
    die;
}
try {
    $regionConfiguration = RegionManager::getInstance()->getRegionConfiguration($regionId);
    $cities = DatabaseHelper::getInstance()->getCities($regionId);
    if ($regionConfiguration !== false) {
        $res = array('status' => 'ok', 'results' => array('regionConfiguration' => $regionConfiguration, 'cities' => $cities));
    } else {
        warn("Could not find configuration for region {$regionId}");
        $res = array('status' => 'err', 'msg' => _("Region not found"));
    }
} catch (Exception $e) {
    logException($e);
    $res = array('status' => 'err', 'msg' => _("Internal Error"));
}
echo json_encode($res);
Beispiel #21
0
    $acl->addResource(ROLE_GUEST, array('webres.php', 'test.php'));
}
$acl->addResource(ROLE_GUEST, array('auth.php', 'optout.php'));
if (getConfiguration('auth.mode') == AuthHandler::AUTH_MODE_PASS) {
    $acl->addResource(ROLE_GUEST, array('join.php', 'help.php', 'AddRideAll.php', 'GetRegionConfiguration.php'));
} else {
    if (AuthHandler::getAuthMode() == AuthHandler::AUTH_MODE_TOKEN) {
        $acl->addResource(ROLE_GUEST, array('join.php', 'help.php', 'index.php', 'AddRideAll.php', 'feedback.php', 'SearchRides.php', 'GetRegionConfiguration.php'));
    }
}
$acl->addResource(ROLE_IDENTIFIED, array('join.php', 'help.php', 'index.php', 'feedback.php', 'logout.php', 'thanks.php', 'SearchRides.php', 'AddRideAll.php', 'GetRegionConfiguration.php'));
$acl->addResource(ROLE_IDENTIFIED_REGISTERED, array('ActivateToggle.php', 'DeleteRide.php', 'ShowInterest.php'));
// Content management
$acl->addResource(ROLE_ADMINISTRATOR, array('translations.php'));
// Enfore access control
$role = AuthHandler::getRole();
$resource = Utils::getRunningScript();
if (!$acl->isAllowed($role, $resource)) {
    if ($role == ROLE_GUEST && $acl->isAllowed($role, 'auth.php')) {
        // Not allowed: if not logged in and allowed to - redirect to login page
        GlobalMessage::setGlobalMessage(_('Please login to access this page'), GlobalMessage::ERROR);
        Utils::redirect('auth.php', array('ref' => $resource));
    } else {
        if ($acl->isAllowed($role, 'auth.php')) {
            // User is logged in but not permitted to use this page
            header("HTTP/1.1 401 Unauthorized");
            die('<p>' . _('Access Denied') . '</p>');
        } else {
            // User is not logged-in and not allowed to do that - totally forbidden
            header("HTTP/1.1 403 Forbidden");
            die('<p>' . _('Sorry, you are not allowed to use this application.') . '</p>');
Beispiel #22
0
    ?>
</span></li>
<?php 
}
?>
</ul>
<?php 
if (!empty($contact['Email'])) {
    ?>
<p><?php 
    echo _('Confirmation mail was sent to your email.');
    ?>
</p>
<?php 
}
if (AuthHandler::getAuthMode() == AuthHandler::AUTH_MODE_TOKEN) {
    ?>
    <p><?php 
    echo _('You can always update or delete your account by browsing to the following link');
    ?>
:</p>
    <p id="authLink"><a href="<?php 
    echo htmlspecialchars($authUrl);
    ?>
"><?php 
    echo htmlspecialchars($authUrl);
    ?>
</a></p>
    <p><?php 
    echo _('To use it, just paste the exact link to your browser address bar and hit "Enter".');
    ?>
<?php

session_start();
use views\helpers\PathHelper;
require_once dirname(dirname(dirname(__FILE__))) . '/views/helpers/PathHelper.php';
$path = new PathHelper();
require_once $path->getModelPath() . 'DBHandler.php';
require_once $path->getModelPath() . 'AuthHandler.php';
require_once $path->getConfigPath() . 'connectionInfo.private.php';
$dbHandler = new DBHandler($host, $user, $password, $db);
$authHandler = new AuthHandler($dbHandler);
if (isset($_POST['title']) && isset($_POST['content'])) {
    if ($id = $dbHandler->insertNote($_POST['title'], $_POST['content'], $authHandler->getUserId())) {
        $result = array("id" => $id, "title" => $_POST['title'], "content" => $_POST['content']);
    } else {
        header("HTTP/1.1 501 Could not modify object");
        $result = array("error" => "An error occurred saving your note.");
    }
} else {
    // title and content were not set
    header("HTTP/1.1 502 Empty parameter set");
    $result = array("error" => "Please provide a title and content for your note.");
}
header("Content-Type: application/json; charset=UTF-8");
echo json_encode($result);
Beispiel #24
0
 />
					<?php 
if ($domainUsersMode) {
    echo '@' . getConfiguration('default.domain');
}
if (!$canUpdateEmail) {
    echo '<p class="description">' . _('Authentication policy does not allow you to change email account.') . '</p>';
} else {
    if ($domainUsersMode) {
        echo '<p class="description">' . _('Please use your company email, without the domain suffix.') . '</p>';
    }
}
?>
				</dd>
				<?php 
if (AuthHandler::getAuthMode() == AuthHandler::AUTH_MODE_PASS) {
    ?>
				<dd class="mandatory">
					<label for="passw1"><?php 
    echo _('Password');
    ?>
</label>
					<input class="textInput" id="passw1" name="passw1" type="password" size=20 value="" />
				</dd>
				<dd class="mandatory">
					<label for="passw2"><?php 
    echo _('Confirm password');
    ?>
</label>
					<input class="textInput" id="passw2" name="passw2" type="password" size=20 value="" />
				</dd>												
Beispiel #25
0
<?php

include "../env.php";
include APP_PATH . "/Bootstrap.php";
if (ENV !== ENV_DEVELOPMENT && (!Utils::IsXhrRequest() || !AuthHandler::isSessionExisting())) {
    die;
}
$contactId = AuthHandler::getLoggedInUserId();
if (!$contactId) {
    warn("Toggle activate command sent while no user is logged in");
    die;
}
try {
    $server = DatabaseHelper::getInstance();
    $ride = $server->getRideProvidedByContactId($contactId);
    if (!$ride) {
        throw new Exception("No ride found for contact {$contactId}");
    }
    $rideId = $ride['Id'];
    if ($ride['Active'] == RIDE_ACTIVE) {
        // Hidden status is always status + 2
        $newStatus = RIDE_INACTIVE;
        $msg = _("Ride de-activated. From now on, this ride will not appear in the search results.");
    } else {
        if ($ride['Active'] == RIDE_INACTIVE) {
            $newStatus = RIDE_ACTIVE;
            $msg = _("Ride activated. You are back in business!");
        } else {
            throw new Exception("Illegal status");
        }
    }
/*
 * Set configuration for client_id, client_secret and various OAuth endpoints
 */
require_once 'config.php';
/*
 * Check the configuration
 */
require_once 'check_config.php';
/*
 * Perform all authorization and authentication logic - exchanging auth
 * code for access token, retrieving user profile info, looking up
 * pre-existing refresh token in database, updating it (if applicable),
 * and more.
 */
require_once 'auth_handler.php';
$authHandler = new AuthHandler($requestType);
$authHandler->VerifyAuth();
/*
 * If an authorization 'code' is set, then we assume the user came from
 * Google Drive and check to see if the 'state' parameter exists, with
 * the mode and potially specified file IDs (on open) or a folder parentId
 * (on create).
 */
if (isset($_GET['code'])) {
    /*
     * State should always be defined
     */
    if (isset($_GET['state'])) {
        $state = json_decode(stripslashes($_GET['state']));
        $_SESSION['mode'] = $state->action;
        if (isset($state->ids)) {
Beispiel #27
0
<?php

include "env.php";
include APP_PATH . "/Bootstrap.php";
$db = DatabaseHelper::getInstance();
AuthHandler::putUserToken();
$displayDest = getConfiguration('mode.single.dest', 0) == 0;
$currentRegion = RegionManager::getInstance()->getCurrentRegionId();
if ($displayDest) {
    $availableCities = $db->getAllAvailableCities($currentRegion);
} else {
    $availableCities = $db->getAvailableCities('Dest', $currentRegion);
}
$availableDestCities =& $availableCities;
$availableSrcCities =& $availableCities;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/reset-fonts.css">
<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap_custom.min.css">
<link rel="stylesheet" type="text/css" href="css/common.css">
<link rel="stylesheet" type="text/css" href="css/index.css">
<?php 
if (LocaleManager::getInstance()->isRtl()) {
    ?>
<link rel="stylesheet" type="text/css" href="css/common_rtl.css">
<?php 
}
?>
Beispiel #28
0
<?php

require_once '../confusa_include.php';
require_once 'AuthHandler.php';
require_once 'Person.php';
/* if nothing is sent via REST, close */
if (is_null($_SERVER['PATH_INFO'])) {
    if (Config::get_config('debug')) {
        echo "No path set!<br />\n";
    }
    exit(0);
}
/* valid session? */
$person = new Person();
$auth = AuthHandler::getAuthManager($person);
$auth->authenticate(true);
if (!$person->isAuth()) {
    if (Config::get_config('debug')) {
        echo "Client is not authenticated!<br />\n";
    }
    exit(0);
}
/* get path, explode and parse content. */
$path = $_SERVER['PATH_INFO'];
$res = explode("/", trim($path, "/"));
if (count($res) != 2) {
    if (Config::get_config('debug')) {
        echo "error with params!<br />\n";
        exit(0);
    }
}