Skip to content

Commit

Permalink
verbose debug, return real Response at onAuthenticationSuccess
Browse files Browse the repository at this point in the history
  • Loading branch information
szabogyula committed Feb 16, 2017
1 parent d573d93 commit 4e78f23
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions Security/ShibbolethAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ public function getCredentials(Request $request)
if ($request->server->has($shibbolethModuleAttribute)) {
// What you return here will be passed to getUser() as $credentials
$username = $request->server->get($this->config['usernameAttribute']);
if (! $username) {
if (! $username) { // return null, there is no username in server variables
$this->logger->debug('[ShibbolethAuthenticator::getCredential] no username in server variables');
return null;
}
return array(

$retarray = array(
'username' => $request->server->get($this->config['usernameAttribute']),
);
$this->logger->debug('[ShibbolethAuthenticator::getCredential] success '. var_export($retarray,1));
return $retarray;
} else {
throw new AuthenticationException(
'There is no shibboleth session, not found '
Expand Down Expand Up @@ -76,15 +80,16 @@ public function getUser($credentials, UserProviderInterface $userProvider)

if ($credentials !== null and is_array($credentials)) {
$user = $userProvider->loadUserByUsername($credentials['username']);
$this->logger->debug('[ShibbolethAuthenticator::getUser] '.$user->getUsername());
$this->logger->debug('[ShibbolethAuthenticator::getUser] success '.$user->getUsername());
return $user;
}
$this->logger->debug('[ShibbolethAuthenticator::getUser] false return null');
return null;
}

public function checkCredentials($credentials, UserInterface $user)
{
$this->logger->debug('[ShibbolethAuthenticator::checkCredentials]');
$this->logger->debug('[ShibbolethAuthenticator::checkCredentials] return true');
// check credentials - e.g. make sure the password is valid
// no credential check is needed in this case

Expand All @@ -97,6 +102,18 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
$this->logger->debug('[ShibbolethAuthenticator::onAuthenticationSuccess]');
// on success, let the request continue
return;
$session = $request->getSession();
if ($session->has('referer')) {
if ($session->get('referer') !== null && $session->get('referer') !== '')
{
$response = new RedirectResponse($session->get('referer'));
} else {
$response = new RedirectResponse($request->getBaseUrl());
}
} else {
$response = new RedirectResponse($request->getBaseUrl());
}
return $response;
}

public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
Expand Down

0 comments on commit 4e78f23

Please sign in to comment.