22
33namespace 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-
1413class 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 ();
0 commit comments