Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SaaS/CE version consolidation #13

Merged
merged 6 commits into from
Aug 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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