Skip to content
Snippets Groups Projects
Commit b6191915 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

modules: PSR2

parent 2d370693
No related branches found
No related tags found
No related merge requests found
...@@ -849,10 +849,13 @@ abstract class BaseFacebook ...@@ -849,10 +849,13 @@ abstract class BaseFacebook
$params['api_key'] = $this->getAppId(); $params['api_key'] = $this->getAppId();
$params['format'] = 'json-strings'; $params['format'] = 'json-strings';
$result = json_decode($this->_oauthRequest( $result = json_decode(
$this->getApiUrl($params['method']), $this->_oauthRequest(
$params $this->getApiUrl($params['method']),
), true); $params
),
true
);
// results are returned, errors are thrown // results are returned, errors are thrown
if (is_array($result) && isset($result['error_code'])) { if (is_array($result) && isset($result['error_code'])) {
...@@ -910,10 +913,13 @@ abstract class BaseFacebook ...@@ -910,10 +913,13 @@ abstract class BaseFacebook
$domainKey = 'graph'; $domainKey = 'graph';
} }
$result = json_decode($this->_oauthRequest( $result = json_decode(
$this->getUrl($domainKey, $path), $this->_oauthRequest(
$params $this->getUrl($domainKey, $path),
), true); $params
),
true
);
// results are returned, errors are thrown // results are returned, errors are thrown
if (is_array($result) && isset($result['error'])) { if (is_array($result) && isset($result['error'])) {
......
...@@ -49,7 +49,10 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter ...@@ -49,7 +49,10 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter
assert(is_array($request)); assert(is_array($request));
assert(array_key_exists('Attributes', $request)); assert(array_key_exists('Attributes', $request));
$function = function (/** @scrutinizer ignore-unused */ &$attributes, /** @scrutinizer ignore-unused */ &$state) { $function = function (
/** @scrutinizer ignore-unused */ &$attributes,
/** @scrutinizer ignore-unused */ &$state
) {
eval($this->code); eval($this->code);
}; };
$function($request['Attributes'], $request); $function($request['Attributes'], $request);
......
...@@ -121,7 +121,7 @@ foreach ($metaentries['hosted'] as $index => $entity) { ...@@ -121,7 +121,7 @@ foreach ($metaentries['hosted'] as $index => $entity) {
$metaentries['hosted'][$index][$new] = $entity[$old][$defaultLanguage]; $metaentries['hosted'][$index][$new] = $entity[$old][$defaultLanguage];
} elseif (isset($entity[$old][$fallbackLanguage])) { } elseif (isset($entity[$old][$fallbackLanguage])) {
$metaentries['hosted'][$index][$new] = $entity[$old][$fallbackLanguage]; $metaentries['hosted'][$index][$new] = $entity[$old][$fallbackLanguage];
} }
} }
} }
foreach ($metaentries['remote'] as $key => $set) { foreach ($metaentries['remote'] as $key => $set) {
......
...@@ -11,6 +11,17 @@ namespace SimpleSAML\Module\oauth; ...@@ -11,6 +11,17 @@ namespace SimpleSAML\Module\oauth;
class Registry class Registry
{ {
public static function requireOwnership($entry, $userid)
{
if (!isset($entry['owner'])) {
throw new \Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.');
} elseif ($entry['owner'] !== $userid) {
throw new \Exception(
'OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.'
);
}
}
protected function getStandardField($request, &$entry, $key) protected function getStandardField($request, &$entry, $key)
{ {
if (array_key_exists('field_'.$key, $request)) { if (array_key_exists('field_'.$key, $request)) {
......
...@@ -22,22 +22,10 @@ if ($session->isValid($authsource)) { ...@@ -22,22 +22,10 @@ if ($session->isValid($authsource)) {
$as->initLogin(\SimpleSAML\Utils\HTTP::getSelfURL()); $as->initLogin(\SimpleSAML\Utils\HTTP::getSelfURL());
} }
function requireOwnership($entry, $userid)
{
if (!isset($entry['owner'])) {
throw new \Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.');
}
if ($entry['owner'] !== $userid) {
throw new \Exception(
'OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.'
);
}
}
if (array_key_exists('editkey', $_REQUEST)) { if (array_key_exists('editkey', $_REQUEST)) {
$entryc = $store->get('consumers', $_REQUEST['editkey'], ''); $entryc = $store->get('consumers', $_REQUEST['editkey'], '');
$entry = $entryc['value']; $entry = $entryc['value'];
requireOwnership($entry, $userid); \SimpleSAML\Module\oauth\Registry::requireOwnership($entry, $userid);
} else { } else {
$entry = [ $entry = [
'owner' => $userid, 'owner' => $userid,
...@@ -53,7 +41,7 @@ if (isset($_POST['submit'])) { ...@@ -53,7 +41,7 @@ if (isset($_POST['submit'])) {
$entry = $editor->formToMeta($_POST, [], ['owner' => $userid]); $entry = $editor->formToMeta($_POST, [], ['owner' => $userid]);
requireOwnership($entry, $userid); \SimpleSAML\Module\oauth\Registry::requireOwnership($entry, $userid);
$store->set('consumers', $entry['key'], '', $entry); $store->set('consumers', $entry['key'], '', $entry);
......
...@@ -21,23 +21,11 @@ if ($session->isValid($authsource)) { ...@@ -21,23 +21,11 @@ if ($session->isValid($authsource)) {
$as->initLogin(\SimpleSAML\Utils\HTTP::getSelfURL()); $as->initLogin(\SimpleSAML\Utils\HTTP::getSelfURL());
} }
function requireOwnership($entry, $userid)
{
if (!isset($entry['owner'])) {
throw new \Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.');
}
if ($entry['owner'] !== $userid) {
throw new \Exception(
'OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.'
);
}
}
if (isset($_REQUEST['delete'])) { if (isset($_REQUEST['delete'])) {
$entryc = $store->get('consumers', $_REQUEST['delete'], ''); $entryc = $store->get('consumers', $_REQUEST['delete'], '');
$entry = $entryc['value']; $entry = $entryc['value'];
requireOwnership($entry, $userid); \SimpleSAML\Module\oauth\Registry::requireOwnership($entry, $userid);
$store->remove('consumers', $entry['key'], ''); $store->remove('consumers', $entry['key'], '');
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment