Author: chabotc
Date: Wed Jun 4 03:38:06 2008
New Revision: 663053
URL: http://svn.apache.org/viewvc?rev=663053&view=rev
Log:
A little test with falling back on basic base64 encoding if plain text tokens
are allowed and no mcrypt extension is available. Hope this will make it easier
for people to get a basic dev env setup without banging their heads against the
mcrypt dependency, which seems to be the main cause of trouble for most
newcommers
Modified:
incubator/shindig/trunk/php/index.php
incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicBlobCrypter.php
Modified: incubator/shindig/trunk/php/index.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/index.php?rev=663053&r1=663052&r2=663053&view=diff
==============================================================================
--- incubator/shindig/trunk/php/index.php (original)
+++ incubator/shindig/trunk/php/index.php Wed Jun 4 03:38:06 2008
@@ -37,7 +37,10 @@
include_once ('config.php');
// basic sanity check if we have all required modules
-$modules = array('json', 'mcrypt', 'SimpleXML', 'libxml', 'curl');
+$modules = array('json', 'SimpleXML', 'libxml', 'curl');
+if (!Config::get('allow_plaintext_token')) {
+ $modules[] = 'mcrypt';
+}
foreach ($modules as $module) {
if (!extension_loaded($module)) {
die("Shindig requires the {$module} extention, see <a
href='http://www.php.net/{$module}'>http://www.php.net/{$module}</a> for more
info");
Modified:
incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicBlobCrypter.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicBlobCrypter.php?rev=663053&r1=663052&r2=663053&view=diff
==============================================================================
---
incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicBlobCrypter.php
(original)
+++
incubator/shindig/trunk/php/src/gadgets/samplecontainer/BasicBlobCrypter.php
Wed Jun 4 03:38:06 2008
@@ -40,12 +40,16 @@
public function wrap(Array $in)
{
$encoded = $this->serializeAndTimestamp($in);
- $cipherText = Crypto::aes128cbcEncrypt($this->cipherKey,
$encoded);
+ if (!function_exists('mcrypt_module_open') &&
Config::get('allow_plaintext_token')) {
+ $cipherText = base64_encode($encoded);
+ } else {
+ $cipherText =
Crypto::aes128cbcEncrypt($this->cipherKey, $encoded);
+ }
$hmac = Crypto::hmacSha1($this->hmacKey, $cipherText);
$b64 = base64_encode($cipherText . $hmac);
return $b64;
}
-
+
private function serializeAndTimestamp(Array $in)
{
$encoded = "";
@@ -78,7 +82,11 @@
$cipherText = substr($bin, 0, strlen($bin) -
Crypto::$HMAC_SHA1_LEN);
$hmac = substr($bin, strlen($cipherText));
Crypto::hmacSha1Verify($this->hmacKey, $cipherText,
$hmac);
- $plain = Crypto::aes128cbcDecrypt($this->cipherKey,
$cipherText);
+ if (!function_exists('mcrypt_module_open') &&
Config::get('allow_plaintext_token')) {
+ $plain = base64_decode($cipherText);
+ } else {
+ $plain =
Crypto::aes128cbcDecrypt($this->cipherKey, $cipherText);
+ }
$out = $this->deserialize($plain);
$this->checkTimestamp($out, $maxAgeSec);
}