Skip to content

Commit

Permalink
Merge pull request #13 from Brightcookie/saas-consolidation
Browse files Browse the repository at this point in the history
SaaS/CE version consolidation
  • Loading branch information
sraka1 committed Aug 11, 2015
2 parents 4c19c03 + af4f3fc commit 4940d2b
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 875 deletions.
950 changes: 101 additions & 849 deletions composer.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions public/assets/styles/pure/grids-responsive-min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions public/assets/styles/pure/grids-responsive-old-ie-min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions public/assets/styles/pure/pure-min.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
}
}

// Use Mongo's native long int
ini_set('mongo.native_long', 1);

// Only invoked if mode is "production"
$app->configureMode('production', function () use ($app, $appRoot) {
Expand Down
13 changes: 4 additions & 9 deletions src/xAPI/Document/Auth/AbstractToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public function hasPermission($permissionName)
if ($scope->getName() === $permissionName || $scope->getName() === 'super') {
return true;
}

if ($permissionName !== 'super' && $scope->getName() === 'all') {
return true;
}
}

return false;
Expand Down Expand Up @@ -92,15 +96,6 @@ public function isExpired()
}
}

public function isValid()
{
if ($this->isExpired()) {
return false;
} else {
return true;
}
}

public function jsonSerialize()
{
return $this->_data;
Expand Down
18 changes: 17 additions & 1 deletion src/xAPI/Document/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,23 @@ public function extractActivities()
$activities = [];
// Main activity
if ((isset($this->_data['statement']['object']['objectType']) && $this->_data['statement']['object']['objectType'] === 'Activity') || !isset($this->_data['statement']['object']['objectType'])) {
$activities[] = $this->_data['statement']['object'];
$activity = $this->_data['statement']['object'];

// Sort of a hack - PHP's copy-on-write needs to be executed, otherwise the MongoDB PHP driver
// overwrites the contents of the variable being passed to the batchInsert call - regardless of
// whether the variable has been passed by reference or not!
// See more:
// http://php.net/manual/en/mongocollection.insert.php Insert behaviour
// http://php.net/manual/en/mongocollection.batchinsert.php Should behave the same as insert, however, does not
// https://jira.mongodb.org/browse/PHP-383
// http://www.phpinternalsbook.com/zvals/memory_management.html#reference-counting-and-copy-on-write
//
// TODO: Report bug to Mongo bug tracker
//
$activity['DUMMY'] = 'DUMMY';
unset($activity['DUMMY']);

$activities[] = $activity;
}

/* Commented out for now due to performance reasons
Expand Down
3 changes: 1 addition & 2 deletions src/xAPI/Service/Auth/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public function fetchToken($key, $secret)
$expiresAt = $accessTokenDocument->getExpiresAt();

if ($expiresAt !== null) {
$dateTime = new \DateTime($expiresAt);
if ($dateTime->getTimestamp() >= time()) {
if ($expiresAt->sec <= time()) {
throw new \Exception('Expired token.', Resource::STATUS_FORBIDDEN);
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/xAPI/Service/Auth/OAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ public function fetchToken($accessToken)
throw new \Exception('Invalid access token specified.', Resource::STATUS_FORBIDDEN);
}

$expiresAt = $accessTokenDocument->getExpiresAt();

if ($expiresAt !== null) {
if ($expiresAt->sec <= time()) {
throw new \Exception('Expired token.', Resource::STATUS_FORBIDDEN);
}
}

$this->setAccessTokens([$accessTokenDocument]);

return $accessTokenDocument;
Expand Down
6 changes: 3 additions & 3 deletions src/xAPI/View/V10/BasicAuth/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function render()
$view = [
'key' => $accessTokenDocument->getKey(),
'secret' => $accessTokenDocument->getSecret(),
'expiresAt' => $accessTokenDocument->getExpiresAt(),
'expiresAt' => $accessTokenDocument->getExpiresAt()->sec,
'expiresIn' => $accessTokenDocument->getExpiresIn(),
'createdAt' => $accessTokenDocument->getCreatedAt(),
'expired' => $accessTokenDocument->getExpired(),
'createdAt' => $accessTokenDocument->getCreatedAt()->sec,
'expired' => $accessTokenDocument->isExpired(),
'scopes' => array_values($accessTokenDocument->scopes),
'user' => $accessTokenDocument->user->renderSummary(),
];
Expand Down
Loading

0 comments on commit 4940d2b

Please sign in to comment.