/** * * Obtem a Instância do SAMoodleAuthLib * * @param int $lap 172800000 * @param string $salt '1234567890abcdefghijklmnopqrstuvxwyz' * * @return SAMoodleAuthLib */ public static function getAuthLib($lap = 172800000, $salt = '1234567890abcdefghijklmnopqrstuvxwyz') { $instance = self::$instance; if (empty($instance['authlib'])) { $instance['authlib'] = new SAMoodleAuthLib($lap, $salt); self::$instance = $instance; } return $instance['authlib']; }
/** * Hook for overriding behaviour of login page. * This method is called from login/index.php page for all enabled auth plugins. * * @global object * @global object */ function loginpage_hook() { global $frm; // can be used to override submitted login form global $user; // can be used to replace authenticate_user_login() global $CFG; if (empty($_GET) && !array_key_exists('satoken', $_GET)) { return; } // para analisar url_get_encrypted_parameter($url, $config); // $saToken = optional_param('satoken', null, PARAM_TEXT); if (isset($saToken)) { $saToken = base64_decode($saToken); if (optional_param('debug', 0, PARAM_BOOL)) { $salt = optional_param('salt', $this->getConfig('tokensalt'), PARAM_TEXT); $validity = optional_param('validity', $this->getConfig('validitytoken'), PARAM_INT); } else { $salt = $this->getConfig('tokensalt'); $validity = $this->getConfig('validitytoken'); } //print_r($CFG); require $CFG->dirroot . '/local/samoodlelib/lib.php'; $saAuthLib = SAMoodleLib::getAuthLib($validity, $salt); try { $saToken = $saAuthLib->criptDecript($saToken); } catch (SAAuthLibException $e) { throw new SAMoodleLibException($e); return; } try { $frmTmp = $saAuthLib->makeFakeForm($saToken); $frm = new stdClass(); $frm->username = $frmTmp->username; $frm->password = $frmTmp->password; } catch (SAAuthLibException $e) { throw new SAMoodleLibException($e); return; } } }
} try { $frmTmp = $saAuthLib->makeFakeForm($saToken); $username = $frmTmp->username; $password = $frmTmp->password; } catch (SAAuthLibException $e) { echo $e; return; } } else { if ($username = optional_param('username', null, PARAM_USERNAME)) { $password = required_param('password', PARAM_TEXT); $salt = optional_param('salt', $CFG->passwordsaltmain, PARAM_ALPHANUMEXT); $time = optional_param('time', time(), PARAM_INT); $validity = optional_param('validity', 6000, PARAM_INT); $authLib = SAMoodleLib::getAuthLib($validity, $salt); $newToken = $authLib->createToken($username, $password, $time, false); $criptToken = $authLib->createToken($username, $password, $time, $salt); $base64NewToken = base64_encode($newToken); $base64criptToken = base64_encode($criptToken); $realToken = $authLib->criptDecript($criptToken); } } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body>