Apply PHPCS fixes.

This commit is contained in:
very-ape 2021-05-17 10:55:15 -07:00
parent e39e621421
commit 092605c2c2
1 changed files with 30 additions and 30 deletions

View File

@ -25,7 +25,9 @@ function saml_module($a)
function saml_init($a) function saml_init($a)
{ {
if ($a->argc < 2) return; if ($a->argc < 2) {
return;
}
switch ($a->argv[1]) { switch ($a->argv[1]) {
case "metadata.xml": case "metadata.xml":
@ -101,12 +103,13 @@ function saml_is_configured()
DI::config()->get('saml', 'sp_key') && DI::config()->get('saml', 'sp_key') &&
DI::config()->get('saml', 'sp_cert') && DI::config()->get('saml', 'sp_cert') &&
DI::config()->get('saml', 'idp_cert'); DI::config()->get('saml', 'idp_cert');
} }
function saml_sso_initiate(&$a, &$b) function saml_sso_initiate(&$a, &$b)
{ {
if (!saml_is_configured()) return; if (!saml_is_configured()) {
return;
}
$auth = new \OneLogin\Saml2\Auth(saml_settings()); $auth = new \OneLogin\Saml2\Auth(saml_settings());
$ssoBuiltUrl = $auth->login(null, array(), false, false, true); $ssoBuiltUrl = $auth->login(null, array(), false, false, true);
@ -162,8 +165,7 @@ function saml_sso_reply($a)
} }
if (isset($_POST['RelayState']) if (isset($_POST['RelayState'])
&& \OneLogin\Saml2\Utils::getSelfURL() != $_POST['RelayState']) && \OneLogin\Saml2\Utils::getSelfURL() != $_POST['RelayState']) {
{
$auth->redirectTo($_POST['RelayState']); $auth->redirectTo($_POST['RelayState']);
} }
} }
@ -271,8 +273,7 @@ function saml_addon_admin (&$a, &$o)
function saml_addon_admin_post(&$a) function saml_addon_admin_post(&$a)
{ {
$safeset = function ($key) $safeset = function ($key) {
{
$val = (!empty($_POST[$key]) ? Strings::escapeTags(trim($_POST[$key])) : ''); $val = (!empty($_POST[$key]) ? Strings::escapeTags(trim($_POST[$key])) : '');
DI::config()->set('saml', $key, $val); DI::config()->set('saml', $key, $val);
}; };
@ -313,7 +314,6 @@ function saml_create_user($username, $email, $name)
]); ]);
return $user; return $user;
} catch (Exception $e) { } catch (Exception $e) {
Logger::error( Logger::error(
'Exception while creating user', 'Exception while creating user',
@ -323,7 +323,8 @@ function saml_create_user($username, $email, $name)
'name' => $name, 'name' => $name,
'exception' => $e->getMessage(), 'exception' => $e->getMessage(),
'trace' => $e->getTraceAsString() 'trace' => $e->getTraceAsString()
]); ]
);
return false; return false;
} }
@ -444,4 +445,3 @@ function saml_settings()
) )
); );
} }
?>