mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
improve trace logging for authentication
This commit is contained in:
@@ -123,15 +123,42 @@ public class BasicAuthenticationFilter extends HttpFilter
|
||||
if (Util.isNotEmpty(authentication)
|
||||
&& authentication.toUpperCase().startsWith(AUTHORIZATION_BASIC_PREFIX))
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("found basic authorization header, start authentication");
|
||||
}
|
||||
|
||||
user = authenticate(request, response, securityContext, authentication);
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
logger.trace("user {} successfully authenticated", user.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.trace("authentcation failed, user object is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (securityContext.isAuthenticated())
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("user is allready authenticated");
|
||||
}
|
||||
|
||||
user = securityContext.getUser();
|
||||
}
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("could not find user send unauthorized");
|
||||
}
|
||||
|
||||
HttpUtil.sendUnauthorized(response);
|
||||
}
|
||||
else
|
||||
@@ -192,6 +219,11 @@ public class BasicAuthenticationFilter extends HttpFilter
|
||||
|
||||
if (Util.isNotEmpty(username) && Util.isNotEmpty(password))
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("try to authenticate user {}", username);
|
||||
}
|
||||
|
||||
user = securityContext.authenticate(request, response, username,
|
||||
password);
|
||||
}
|
||||
|
||||
@@ -150,6 +150,15 @@ public abstract class PermissionFilter extends HttpFilter
|
||||
|
||||
if (hasPermission(repository, securityContext, writeRequest))
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("{} access to repository {} for user {} granted",
|
||||
new Object[] { writeRequest
|
||||
? "write"
|
||||
: "read", repository.getName(),
|
||||
user.getName() });
|
||||
}
|
||||
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user