From b61919158de05b1e73f5c6b3280b8c4a02bc54e9 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Thu, 18 Oct 2018 14:18:10 +0200 Subject: [PATCH] modules: PSR2 --- .../authfacebook/extlibinc/base_facebook.php | 22 ++++++++++++------- modules/core/lib/Auth/Process/PHP.php | 5 ++++- modules/core/www/frontpage_federation.php | 2 +- modules/oauth/lib/Registry.php | 11 ++++++++++ modules/oauth/www/registry.edit.php | 16 ++------------ modules/oauth/www/registry.php | 14 +----------- 6 files changed, 33 insertions(+), 37 deletions(-) diff --git a/modules/authfacebook/extlibinc/base_facebook.php b/modules/authfacebook/extlibinc/base_facebook.php index ea661c7a9..b656f350f 100644 --- a/modules/authfacebook/extlibinc/base_facebook.php +++ b/modules/authfacebook/extlibinc/base_facebook.php @@ -849,10 +849,13 @@ abstract class BaseFacebook $params['api_key'] = $this->getAppId(); $params['format'] = 'json-strings'; - $result = json_decode($this->_oauthRequest( - $this->getApiUrl($params['method']), - $params - ), true); + $result = json_decode( + $this->_oauthRequest( + $this->getApiUrl($params['method']), + $params + ), + true + ); // results are returned, errors are thrown if (is_array($result) && isset($result['error_code'])) { @@ -910,10 +913,13 @@ abstract class BaseFacebook $domainKey = 'graph'; } - $result = json_decode($this->_oauthRequest( - $this->getUrl($domainKey, $path), - $params - ), true); + $result = json_decode( + $this->_oauthRequest( + $this->getUrl($domainKey, $path), + $params + ), + true + ); // results are returned, errors are thrown if (is_array($result) && isset($result['error'])) { diff --git a/modules/core/lib/Auth/Process/PHP.php b/modules/core/lib/Auth/Process/PHP.php index 5f6168522..cd424c76e 100644 --- a/modules/core/lib/Auth/Process/PHP.php +++ b/modules/core/lib/Auth/Process/PHP.php @@ -49,7 +49,10 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter assert(is_array($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); }; $function($request['Attributes'], $request); diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php index 1d00be38e..267a54a53 100644 --- a/modules/core/www/frontpage_federation.php +++ b/modules/core/www/frontpage_federation.php @@ -121,7 +121,7 @@ foreach ($metaentries['hosted'] as $index => $entity) { $metaentries['hosted'][$index][$new] = $entity[$old][$defaultLanguage]; } elseif (isset($entity[$old][$fallbackLanguage])) { $metaentries['hosted'][$index][$new] = $entity[$old][$fallbackLanguage]; - } + } } } foreach ($metaentries['remote'] as $key => $set) { diff --git a/modules/oauth/lib/Registry.php b/modules/oauth/lib/Registry.php index 0ff3b5105..0939be6f4 100644 --- a/modules/oauth/lib/Registry.php +++ b/modules/oauth/lib/Registry.php @@ -11,6 +11,17 @@ namespace SimpleSAML\Module\oauth; 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) { if (array_key_exists('field_'.$key, $request)) { diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php index c9a50b2f3..a367c4820 100644 --- a/modules/oauth/www/registry.edit.php +++ b/modules/oauth/www/registry.edit.php @@ -22,22 +22,10 @@ if ($session->isValid($authsource)) { $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)) { $entryc = $store->get('consumers', $_REQUEST['editkey'], ''); $entry = $entryc['value']; - requireOwnership($entry, $userid); + \SimpleSAML\Module\oauth\Registry::requireOwnership($entry, $userid); } else { $entry = [ 'owner' => $userid, @@ -53,7 +41,7 @@ if (isset($_POST['submit'])) { $entry = $editor->formToMeta($_POST, [], ['owner' => $userid]); - requireOwnership($entry, $userid); + \SimpleSAML\Module\oauth\Registry::requireOwnership($entry, $userid); $store->set('consumers', $entry['key'], '', $entry); diff --git a/modules/oauth/www/registry.php b/modules/oauth/www/registry.php index 3f3403bf1..4431835a6 100644 --- a/modules/oauth/www/registry.php +++ b/modules/oauth/www/registry.php @@ -21,23 +21,11 @@ if ($session->isValid($authsource)) { $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'])) { $entryc = $store->get('consumers', $_REQUEST['delete'], ''); $entry = $entryc['value']; - requireOwnership($entry, $userid); + \SimpleSAML\Module\oauth\Registry::requireOwnership($entry, $userid); $store->remove('consumers', $entry['key'], ''); } -- GitLab