public function done() { //Restore session $_SESSION = $this->session; $this->f3->set('SESSION', $this->session); $this->f3->set('PARAMS', $this->params); //Restore original login $auth = new AuthHelper(null); $auth->forceLogin($this->f3->get('SESSION.user')); $auth->setupSession($this->f3->get('SESSION.user')); //Restore session $_SESSION = $this->session; $this->f3->set('SESSION', $this->session); $this->f3->set('PARAMS', $this->params); }
/** * check if user is logged in. Do not load from DB by default */ public function isLoggedIn($load = false) { if (parent::isLoggedIn($load)) { $this->obj->set('actags', $_SESSION['appUserAcl']); return true; } else { return false; } }
<?php session_start(); error_reporting(E_ALL | E_STRICT); ini_set("display_errors", 1); require_once "Settings.php"; require_once "AuthHelper.php"; require_once "Token.php"; //check for token in session first time in if (!isset($_SESSION[Settings::$tokenCache])) { //redirect to login page header("Location:Login.php"); } else { //use the refresh token to get a new access token $token = AuthHelper::getAccessTokenFromRefreshToken($_SESSION[Settings::$tokenCache]); $path = Settings::$unifiedAPIEndpoint . "me"; if (isset($_GET["id"]) && isset($_SESSION[Settings::$apiRoot])) { //get the apiRoot from session $apiRoot = $_SESSION[Settings::$apiRoot]; $path = $apiRoot . "/users/" . $_GET["id"]; } //perform a REST query for the user $request = curl_init($path); curl_setopt($request, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $token->accessToken, "Accept: application/json")); curl_setopt($request, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($request); $user = json_decode($response, true); //perform a REST query for the users manager $request = curl_init($path . "/manager"); curl_setopt($request, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $token->accessToken, "Accept: application/json")); curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
$mgmtApiDemoUrl = THIS_PAGE . '?demo=mgmt'; $coreReportingDemoUrl = THIS_PAGE . '?demo=reporting'; // Build a new client object to work with authorization. $client = new Google_Client(); $client->setClientId(CLIENT_ID); $client->setClientSecret(CLIENT_SECRET); $client->setRedirectUri(REDIRECT_URL); $client->setApplicationName(APP_NAME); $client->setScopes(array(ANALYTICS_SCOPE)); // Magic. Returns objects from the Analytics Service // instead of associative arrays. $client->setUseObjects(true); // Build a new storage object to handle and store tokens in sessions. // Create a new storage object to persist the tokens across sessions. $storage = new apiSessionStorage(); $authHelper = new AuthHelper($client, $storage, THIS_PAGE); // Main controller logic. if ($_GET['action'] == 'revoke') { $authHelper->revokeToken(); } else { if ($_GET['action'] == 'auth' || $_GET['code']) { $authHelper->authenticate(); } else { $authHelper->setTokenFromStorage(); if ($authHelper->isAuthorized()) { $analytics = new Google_AnalyticsService($client); if ($_GET['demo'] == 'hello') { // Hello Analytics API Demo. require_once 'helloAnalyticsApi.php'; $demo = new HelloAnalyticsApi($analytics); $htmlOutput = $demo->getHtmlOutput();
/** * Loads the requested URL * * @access public * @author Renie Siqueira da Silva * @since 1.0 * @return void */ public function run() { $controller_path = CONTROLLERS . $this->_controller . CONTROLLERSUFIX . ".php"; if (!file_exists($controller_path)) { $this->dispatch404(); } require_once $controller_path; $controller = $this->_controller . CONTROLLERSUFIX; $app = new $controller(); $action = $this->_action; if (defined('RESTFULENABLE') && RESTFULENABLE) { if ($action == DEFAULTACTION || $action == null) { $found = false; $controllerMethods = get_class_methods($controller); foreach ($controllerMethods as $key => $value) { $refM = new ReflectionMethod($controller, $value); $methodArr = array(); preg_match("/(@REQUEST_METHOD )(.*)/", $refM->getDocComment(), $methodArr); if (isset($methodArr[0])) { if (trim(strtolower($methodArr[2])) == trim(strtolower(SYSTEM::$SERVER['REQUEST_METHOD']))) { $action = $value; } } } } else { if (!method_exists($app, $action)) { $this->dispatch404(true); die; } $refM = new ReflectionMethod($controller, $action); $methodArr = array(); preg_match("/(@REQUEST_METHOD )(.*)/", $refM->getDocComment(), $methodArr); if (isset($methodArr[0])) { if (trim(strtolower($methodArr[2])) != trim(strtolower(SYSTEM::$SERVER['REQUEST_METHOD']))) { $action = null; } } } if ($action == null) { header(':', true, 405); die; } } $this->_action = $action; if (!method_exists($app, $this->_action)) { $this->dispatch404(); die; } if (defined('AUTHENABLE') && AUTHENABLE) { $refC = new ReflectionClass($controller); $authMNeeded = array(); preg_match("/@OdinAuth /", $refM->getDocComment(), $authMNeeded); $authCNeeded = array(); preg_match("/@OdinAuth /", $refC->getDocComment(), $authCNeeded); $authLogin = array(); preg_match("/@OdinAuthLogin /", $refM->getDocComment(), $authLogin); if (isset($authMNeeded[0]) || isset($authCNeeded[0])) { if (!AuthHelper::checkLogin()) { if (defined('AUTHCONTROLLERERROR') && AUTHCONTROLLERERROR != "") { SessionHelper::setSystemSession('requiredController', $this->_controller); SessionHelper::setSystemSession('requiredAction', $this->_action); SessionHelper::setSystemSession('requiredURL', true); if (defined('AUTHCONTROLLERACTION') && AUTHCONTROLLERACTION != "") { RedirectHelper::goToControllerAction(AUTHCONTROLLERERROR, AUTHACTIONERROR); } else { RedirectHelper::goToController(AUTHCONTROLLERERROR); } } else { RedirectHelper::goToIndex(); } } } elseif (isset($authLogin[0])) { if (AuthHelper::checkLogin()) { if (defined('AUTHCONTROLLERHOME') && AUTHCONTROLLERHOME != "") { if (defined('AUTHACTIONHOME') && AUTHACTIONHOME != "" && (AUTHCONTROLLERHOME != AUTHCONTROLLERERROR && AUTHACTIONHOME != AUTHACTIONERROR || AUTHACTIONHOME != AUTHACTIONERROR || AUTHCONTROLLERHOME != AUTHCONTROLLERERROR)) { RedirectHelper::goToControllerAction(AUTHCONTROLLERHOME, AUTHACTIONHOME); exit; } else { echo "FURY OF ODIN!!!!!"; exit; } } else { echo "FURY OF ODIN!!!!!"; exit; } } } } try { $app->{$action}(); } catch (Exception $e) { echo $e; } }
public function init() { $rule = new AuthHelper(); $rule->checkRule(1); }
if (isset($_GET["code"])) { //use the authorization code to get access token for the unified API $token = AuthHelper::getAccessTokenFromCode($_GET["code"]); if (isset($token->refreshToken)) { $_SESSION[Settings::$tokenCache] = $token->refreshToken; header("Location:Index.php"); } } ?> <html> <head> <title>Login</title> <link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.min.css"> <script type="text/javascript" src="lib/jquery/dist/jquery.min.js"></script> <script type="text/javascript" src="lib/bootstrap/dist/js/bootstrap.min.js"></script> <script type="text/javascript"> function login() { <?php echo "window.location = '" . AuthHelper::getAuthorizationUrl() . "';"; ?> } </script> </head> <body> <div class="container"> <button type="button" name="button" onclick="login()" class="btn btn-primary btn-block">Login with Office 365</button> </div> </body> </html>
@extends('app') @section('content') {!! Form::model(new App\Video, array( 'route' => 'videos.store', 'class' => 'form-horizontal', 'novalidate' => 'novalidate', 'files' => true) ) !!} <?php $userRole = AuthHelper::authenticate(); $user = Cas::user(); ?> <!-- @include('videos/partials/_form', ['submit_text' => 'Upload']) --> <div class="hidden">{{AuthHelper::authenticate()}}</div> <div class = "container" style="padding:10px;"> <div class="row" style="padding:10px"> <div calss="col-xs-12" style="margin:auto;" > <div class="hidden" id="progress-box" style="max-width:100%;padding-left:0px; margin:auto; width:750px;"> <div class="panel-heading"><p id="panel-heading" class="text-muted">Loading.........</p></div> <center><div id="videoplayer" style="max-width:100%; height:auto; padding:10px;"> <div class="container-fluid" > <div class="progress"> <div class="progress-bar" id="progress-bar" style="width: 0%"></div> </div> </div></div></div></center> </div> </div>
public function setRawPassword($pass, $salt) { switch (APP_AUTH_PASSWORD_MODE) { case 1: $this->data['password'] = crypt($pass, $salt); break; case 2: $this->data['password'] = AuthHelper::getDbPass("ENCRYPT('{$pass}','{$salt}')"); break; case 3: $this->data['password'] = AuthHelper::getDbPass("ENCODE('{$pass}','{$salt}')"); break; case 4: case 5: $this->data['password'] = AuthHelper::getDbPass("MD5('{$pass}')"); break; default: $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_ECB), MCRYPT_RAND); $crypttext = mcrypt_encrypt(APP_AUTH_PASSWORD_MODE, $salt, $pass, MCRYPT_MODE_ECB, $iv); $this->data['password'] = bin2hex($crypttext); break; } }
/** * Loads the requested URL * * @access public * @author Renie Siqueira da Silva * @since 1.0 * @return void */ public function run() { $controller_path = CONTROLLERS . $this->_controller . "Controller.php"; if (!file_exists($controller_path)) { $this->dispatch404(); } require_once $controller_path; $controller = $this->_controller . "Controller"; $app = new $controller(); if (!method_exists($app, $this->_action)) { $this->dispatch404(); } $action = $this->_action; if (defined('AUTHENABLE') && AUTHENABLE) { $refM = new ReflectionMethod($controller, $action); $refC = new ReflectionClass($controller); $authMNeeded = array(); preg_match("/@OdinAuth /", $refM->getDocComment(), $authMNeeded); $authCNeeded = array(); preg_match("/@OdinAuth /", $refC->getDocComment(), $authCNeeded); $authLogin = array(); preg_match("/@OdinAuthLogin /", $refM->getDocComment(), $authLogin); if (isset($authMNeeded[0]) || isset($authCNeeded[0])) { if (!AuthHelper::checkLogin()) { if (defined('AUTHCONTROLLERERROR') && AUTHCONTROLLERERROR != "") { SessionHelper::setSystemSession('requiredController', $this->_controller); SessionHelper::setSystemSession('requiredAction', $this->_action); SessionHelper::setSystemSession('requiredURL', true); if (defined('AUTHCONTROLLERACTION') && AUTHCONTROLLERACTION != "") { RedirectHelper::goToControllerAction(AUTHCONTROLLERERROR, AUTHACTIONERROR); } else { RedirectHelper::goToController(AUTHCONTROLLERERROR); } } else { RedirectHelper::goToIndex(); } } } elseif (isset($authLogin[0])) { if (AuthHelper::checkLogin()) { if (defined('AUTHCONTROLLERHOME') && AUTHCONTROLLERHOME != "") { if (defined('AUTHACTIONHOME') && AUTHACTIONHOME != "" && (AUTHCONTROLLERHOME != AUTHCONTROLLERERROR && AUTHACTIONHOME != AUTHACTIONERROR || AUTHACTIONHOME != AUTHACTIONERROR || AUTHCONTROLLERHOME != AUTHCONTROLLERERROR)) { RedirectHelper::goToControllerAction(AUTHCONTROLLERHOME, AUTHACTIONHOME); exit; } else { RedirectHelper::goToUrl("odinphp.com/Fury"); exit; } } else { RedirectHelper::goToUrl("odinphp.com/Fury"); exit; } } } } try { $app->{$action}(); } catch (Exception $e) { echo $e; } }
/** *@OdinAuth */ public function gtfo() { AuthHelper::logout(); SessionHelper::setSystemSession('msg', 'You are not logged anymore.'); RedirectHelper::goToController("TestAuthentication"); }