mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
log authorization summary to trace level
This commit is contained in:
@@ -35,6 +35,7 @@ package sonia.scm.security;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
@@ -85,6 +86,9 @@ import sonia.scm.user.UserModificationEvent;
|
|||||||
public class AuthorizationCollector
|
public class AuthorizationCollector
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO move to util class
|
||||||
|
private static final String SEPARATOR = System.getProperty("line.separator", "\n");
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private static final String CACHE_NAME = "sonia.cache.authorizing";
|
private static final String CACHE_NAME = "sonia.cache.authorizing";
|
||||||
|
|
||||||
@@ -360,9 +364,36 @@ public class AuthorizationCollector
|
|||||||
logger.trace("retrieve AuthorizationInfo for user {} from cache", user.getName());
|
logger.trace("retrieve AuthorizationInfo for user {} from cache", user.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logger.isTraceEnabled()){
|
||||||
|
logger.trace(createAuthorizationSummary(user, groupNames, info));
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createAuthorizationSummary(User user, GroupNames groups, AuthorizationInfo authzInfo)
|
||||||
|
{
|
||||||
|
StringBuilder buffer = new StringBuilder("authorization summary: ");
|
||||||
|
buffer.append(SEPARATOR).append("username : ").append(user.getName());
|
||||||
|
buffer.append(SEPARATOR).append("groups : ");
|
||||||
|
append(buffer, groups);
|
||||||
|
buffer.append(SEPARATOR).append("roles : ");
|
||||||
|
append(buffer, authzInfo.getRoles());
|
||||||
|
buffer.append(SEPARATOR).append("permissions:");
|
||||||
|
append(buffer, authzInfo.getStringPermissions());
|
||||||
|
append(buffer, authzInfo.getObjectPermissions());
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void append(StringBuilder buffer, Iterable<?> iterable){
|
||||||
|
if (iterable != null){
|
||||||
|
for ( Object item : iterable )
|
||||||
|
{
|
||||||
|
buffer.append(SEPARATOR).append(" - ").append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -52,6 +52,9 @@
|
|||||||
|
|
||||||
<logger name="sonia.scm" level="TRACE" />
|
<logger name="sonia.scm" level="TRACE" />
|
||||||
|
|
||||||
|
<logger name="sonia.scm.security.AuthorizationCollector" level="DEBUG" />
|
||||||
|
<logger name="sonia.scm.web.filter.AutoLoginFilter" level="DEBUG" />
|
||||||
|
|
||||||
<!-- suppress massive gzip logging -->
|
<!-- suppress massive gzip logging -->
|
||||||
<logger name="sonia.scm.filter.GZipFilter" level="WARN" />
|
<logger name="sonia.scm.filter.GZipFilter" level="WARN" />
|
||||||
<logger name="sonia.scm.filter.GZipResponseStream" level="WARN" />
|
<logger name="sonia.scm.filter.GZipResponseStream" level="WARN" />
|
||||||
|
|||||||
Reference in New Issue
Block a user