merged branch Seldaek/auth_logging (PR #3682)

Commits
-------

da0bd7d [Security] Log file/line that triggered the AccessDeniedException

Discussion
----------

[Security] Log file/line that triggered the AccessDeniedException

I had to debug some strange issue in a complex system and with all the nested requests and such, knowing exactly what was triggering the login page to show up wasn't so easy. This helps (unless you use annotations, but the JMSSecurityExtra bundle could use a custom exception class that overrides getLine/getFile and makes it point to the annotation line).
This commit is contained in:
Fabien Potencier 2012-03-23 12:39:07 +01:00
commit dd7efb7f36

View File

@ -98,7 +98,7 @@ class ExceptionListener
$token = $this->context->getToken();
if (!$this->authenticationTrustResolver->isFullFledged($token)) {
if (null !== $this->logger) {
$this->logger->debug('Access denied (user is not fully authenticated); redirecting to authentication entry point');
$this->logger->debug('Access is denied (user is not fully authenticated) by '.$exception->getFile().' at line '.$exception->getLine().'; redirecting to authentication entry point');
}
try {
@ -110,7 +110,7 @@ class ExceptionListener
}
} else {
if (null !== $this->logger) {
$this->logger->debug('Access is denied (and user is neither anonymous, nor remember-me)');
$this->logger->debug('Access is denied (and user is neither anonymous, nor remember-me) by '.$exception->getFile().' at line '.$exception->getLine());
}
try {