import org.slf4j.LoggerFactory;\r
\r
import com.gitblit.models.UserModel;\r
+import com.gitblit.utils.DeepCopier;\r
import com.gitblit.utils.StringUtils;\r
\r
/**\r
\r
public AuthenticatedRequest(HttpServletRequest req) {\r
super(req);\r
- user = new UserModel("anonymous");\r
- user.isAuthenticated = false;\r
+ user = DeepCopier.copy(UserModel.ANONYMOUS);\r
}\r
\r
UserModel getUser() {\r
return (user != null && user.isLocalAccount()) || userService.supportsTeamMembershipChanges();
}
+ /**
+ * Returns true if the username represents an internal account
+ *
+ * @param username
+ * @return true if the specified username represents an internal account
+ */
+ protected boolean isInternalAccount(String username) {
+ return !StringUtils.isEmpty(username)
+ && (username.equalsIgnoreCase(Constants.FEDERATION_USER)
+ || username.equalsIgnoreCase(UserModel.ANONYMOUS.username));
+ }
+
/**
* Authenticate a user based on a username and password.
*
if (principal != null) {
String username = principal.getName();
if (!StringUtils.isEmpty(username)) {
+ boolean internalAccount = isInternalAccount(username);
UserModel user = getUserModel(username);
if (user != null) {
// existing user
user.username, httpRequest.getRemoteAddr()));
return user;
} else if (settings.getBoolean(Keys.realm.container.autoCreateAccounts, false)
- && !username.equalsIgnoreCase(Constants.FEDERATION_USER)) {
+ && !internalAccount) {
// auto-create user from an authenticated container principal
user = new UserModel(username.toLowerCase());
user.displayName = username;
logger.debug(MessageFormat.format("{0} authenticated and created by servlet container principal from {1}",
user.username, httpRequest.getRemoteAddr()));
return user;
- } else {
+ } else if (!internalAccount) {
logger.warn(MessageFormat.format("Failed to find UserModel for {0}, attempted servlet container authentication from {1}",
principal.getName(), httpRequest.getRemoteAddr()));
}
String cloneUrl = sb.toString();
// Retrieve all available repositories
- UserModel user = new UserModel(Constants.FEDERATION_USER);
- user.canAdmin = true;
+ UserModel user = getFederationUser();
List<RepositoryModel> list = getRepositoryModels(user);
// create the [cloneurl, repositoryModel] map
PersonIdent ident;
if (UserModel.ANONYMOUS.equals(user)) {
// anonymous push
- ident = new PersonIdent("anonymous", "anonymous");
+ ident = new PersonIdent(user.username + "/" + user.username, user.username);
} else {
// construct real pushing account
ident = new PersonIdent(MessageFormat.format("{0}/{1}", user.getDisplayName(), user.username),
gb.reviewPatchset = review {0} patchset {1}
gb.todaysActivityStats = today / {1} commits by {2} authors
gb.todaysActivityNone = today / none
-gb.noActivityToday = there has been no activity today
\ No newline at end of file
+gb.noActivityToday = there has been no activity today
+gb.anonymousUser= anonymous
\ No newline at end of file
import com.gitblit.models.RefLogEntry;\r
import com.gitblit.models.RepositoryCommit;\r
import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.UserModel;\r
import com.gitblit.utils.RefLogUtils;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.utils.TimeUtils;\r
if (change.user.username.equals(change.user.emailAddress) && change.user.emailAddress.indexOf('@') > -1) {\r
// username is an email address - 1.2.1 push log bug\r
changeItem.add(new Label("whoChanged", change.user.getDisplayName()));\r
+ } else if (change.user.username.equals(UserModel.ANONYMOUS.username)) {\r
+ // anonymous change\r
+ changeItem.add(new Label("whoChanged", getString("gb.anonymousUser")));\r
} else {\r
// link to user account page\r
changeItem.add(new LinkPanel("whoChanged", null, change.user.getDisplayName(),\r