Skip to content

Commit c370d7f

Browse files
committed
PSR-12
1 parent 11a7013 commit c370d7f

File tree

8 files changed

+25
-20
lines changed

8 files changed

+25
-20
lines changed

lib/Auth/Source/Negotiate.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
namespace SimpleSAML\Module\negotiate\Auth\Source;
44

5-
use \SimpleSAML\Logger;
5+
use SimpleSAML\Logger;
66

77
/**
88
* The Negotiate module. Allows for password-less, secure login by Kerberos and Negotiate.
99
*
1010
* @author Mathias Meisfjordskar, University of Oslo <[email protected]>
1111
* @package SimpleSAMLphp
1212
*/
13-
1413
class Negotiate extends \SimpleSAML\Auth\Source
1514
{
1615
// Constants used in the module
@@ -132,9 +131,10 @@ public function authenticate(&$state)
132131
$session = \SimpleSAML\Session::getSessionFromRequest();
133132
$disabled = $session->getData('negotiate:disable', 'session');
134133

135-
if ($disabled ||
136-
(!empty($_COOKIE['NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT']) &&
137-
$_COOKIE['NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT'] == 'True')
134+
if (
135+
$disabled
136+
|| (!empty($_COOKIE['NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT'])
137+
&& $_COOKIE['NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT'] == 'True')
138138
) {
139139
Logger::debug('Negotiate - session disabled. falling back');
140140
$this->fallBack($state);
@@ -174,22 +174,22 @@ public function authenticate(&$state)
174174
try {
175175
$reply = $auth->doAuthentication();
176176
} catch (\Exception $e) {
177-
Logger::error('Negotiate - authenticate(): doAuthentication() exception: '.$e->getMessage());
177+
Logger::error('Negotiate - authenticate(): doAuthentication() exception: ' . $e->getMessage());
178178
$reply = null;
179179
}
180180

181181
if ($reply) {
182182
// success! krb TGS received
183183
$user = $auth->getAuthenticatedUser();
184-
Logger::info('Negotiate - authenticate(): '.$user.' authenticated.');
184+
Logger::info('Negotiate - authenticate(): ' . $user . ' authenticated.');
185185
$lookup = $this->lookupUserData($user);
186186
if ($lookup !== null) {
187187
$state['Attributes'] = $lookup;
188188
// Override the backend so logout will know what to look for
189189
$state['LogoutState'] = [
190190
'negotiate:backend' => null,
191191
];
192-
Logger::info('Negotiate - authenticate(): '.$user.' authorized.');
192+
Logger::info('Negotiate - authenticate(): ' . $user . ' authorized.');
193193
\SimpleSAML\Auth\Source::completeAuth($state);
194194
// Never reached.
195195
assert(false);
@@ -202,7 +202,7 @@ public function authenticate(&$state)
202202
// No auth token. Send it.
203203
Logger::debug('Negotiate - authenticate(): Sending Negotiate.');
204204
// Save the $state array, so that we can restore if after a redirect
205-
Logger::debug('Negotiate - fallback: '.$state['LogoutState']['negotiate:backend']);
205+
Logger::debug('Negotiate - fallback: ' . $state['LogoutState']['negotiate:backend']);
206206
$id = \SimpleSAML\Auth\State::saveState($state, self::STAGEID);
207207
$params = ['AuthState' => $id];
208208

@@ -255,11 +255,11 @@ public function checkMask()
255255
foreach ($this->subnet as $cidr) {
256256
$ret = \SimpleSAML\Utils\Net::ipCIDRcheck($cidr);
257257
if ($ret) {
258-
Logger::debug('Negotiate: Client "'.$ip.'" matched subnet.');
258+
Logger::debug('Negotiate: Client "' . $ip . '" matched subnet.');
259259
return true;
260260
}
261261
}
262-
Logger::debug('Negotiate: Client "'.$ip.'" did not match subnet.');
262+
Logger::debug('Negotiate: Client "' . $ip . '" did not match subnet.');
263263
return false;
264264
}
265265

@@ -342,7 +342,7 @@ protected function lookupUserData($user)
342342
$dn = $this->ldap->searchfordn($this->base, $this->attr, $uid);
343343
return $this->ldap->getAttributes($dn, $this->attributes);
344344
} catch (\SimpleSAML\Error\Exception $e) {
345-
Logger::debug('Negotiate - ldap lookup failed: '.$e);
345+
Logger::debug('Negotiate - ldap lookup failed: ' . $e);
346346
return null;
347347
}
348348
}
@@ -361,11 +361,12 @@ protected function adminBind()
361361
// no admin user
362362
return;
363363
}
364-
Logger::debug('Negotiate - authenticate(): Binding as system user '.var_export($this->admin_user, true));
364+
Logger::debug('Negotiate - authenticate(): Binding as system user ' . var_export($this->admin_user, true));
365365

366366
if (!$this->ldap->bind($this->admin_user, $this->admin_pw)) {
367-
$msg = 'Unable to authenticate system user (LDAP_INVALID_CREDENTIALS) '.var_export($this->admin_user, true);
368-
Logger::error('Negotiate - authenticate(): '.$msg);
367+
$msg = 'Unable to authenticate system user (LDAP_INVALID_CREDENTIALS) '
368+
. var_export($this->admin_user, true);
369+
Logger::error('Negotiate - authenticate(): ' . $msg);
369370
throw new \SimpleSAML\Error\AuthSource('negotiate', $msg);
370371
}
371372
}
@@ -385,7 +386,7 @@ public function logout(&$state)
385386
assert(is_array($state));
386387
// get the source that was used to authenticate
387388
$authId = $state['negotiate:backend'];
388-
Logger::debug('Negotiate - logout has the following authId: "'.$authId.'"');
389+
Logger::debug('Negotiate - logout has the following authId: "' . $authId . '"');
389390

390391
if ($authId === null) {
391392
$session = \SimpleSAML\Session::getSessionFromRequest();

templates/disable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
* @package SimpleSAMLphp
99
*/
10+
1011
$this->includeAtTemplateBase('includes/header.php');
1112
?>
1213
<h1><?php echo $this->t('{negotiate:negotiate:disable_title}'); ?></h1>

templates/enable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
* @package SimpleSAMLphp
99
*/
10+
1011
$this->includeAtTemplateBase('includes/header.php');
1112
?>
1213
<h1><?php echo $this->t('{negotiate:negotiate:enable_title}'); ?></h1>

tests/bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

33
$projectRoot = dirname(__DIR__);
4-
require_once($projectRoot.'/vendor/autoload.php');
4+
require_once($projectRoot . '/vendor/autoload.php');
55

66
// Symlink module into ssp vendor lib so that templates and urls can resolve correctly
7-
$linkPath = $projectRoot.'/vendor/simplesamlphp/simplesamlphp/modules/negotiate';
7+
$linkPath = $projectRoot . '/vendor/simplesamlphp/simplesamlphp/modules/negotiate';
88
if (file_exists($linkPath) === false) {
99
echo "Linking '$linkPath' to '$projectRoot'\n";
1010
symlink($projectRoot, $linkPath);

www/backend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
$_REQUEST['AuthState'],
1313
\SimpleSAML\Module\negotiate\Auth\Source\Negotiate::STAGEID
1414
);
15-
\SimpleSAML\Logger::debug('backend - fallback: '.$state['LogoutState']['negotiate:backend']);
15+
\SimpleSAML\Logger::debug('backend - fallback: ' . $state['LogoutState']['negotiate:backend']);
1616

1717
\SimpleSAML\Module\negotiate\Auth\Source\Negotiate::fallBack($state);
1818

www/disable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @author Mathias Meisfjordskar, University of Oslo.
45

www/enable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @author Mathias Meisfjordskar, University of Oslo.
45

www/retry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
if (isset($idpmeta['auth'])) {
2121
$source = \SimpleSAML\Auth\Source::getById($idpmeta['auth']);
2222
if ($source === null) {
23-
throw new \SimpleSAML\Error\BadRequest('Invalid AuthId "'.$idpmeta['auth'].'" - not found.');
23+
throw new \SimpleSAML\Error\BadRequest('Invalid AuthId "' . $idpmeta['auth'] . '" - not found.');
2424
}
2525

2626
$session = \SimpleSAML\Session::getSessionFromRequest();

0 commit comments

Comments
 (0)