diff --git a/src/main/distrib/data/defaults.properties b/src/main/distrib/data/defaults.properties index 9c5979030..18f658ecb 100644 --- a/src/main/distrib/data/defaults.properties +++ b/src/main/distrib/data/defaults.properties @@ -848,6 +848,13 @@ web.tabLength = 4 # BASEFOLDER realm.userService = ${baseFolder}/users.conf + +# if not empty, then every logined user will join this team +# so we can set acl on the default team +# SINCE 1.8.2 +realm.loginedUserDefaultTeam= + + # Ordered list of external authentication providers which will be used if # authentication against the local user service fails. # diff --git a/src/main/java/com/gitblit/auth/AuthenticationProvider.java b/src/main/java/com/gitblit/auth/AuthenticationProvider.java index e359fd7e4..dd2adc90e 100644 --- a/src/main/java/com/gitblit/auth/AuthenticationProvider.java +++ b/src/main/java/com/gitblit/auth/AuthenticationProvider.java @@ -27,6 +27,7 @@ import com.gitblit.Constants.Role; import com.gitblit.Constants.AuthenticationType; import com.gitblit.IStoredSettings; +import com.gitblit.Keys; import com.gitblit.manager.IRuntimeManager; import com.gitblit.manager.IUserManager; import com.gitblit.models.TeamModel; @@ -88,17 +89,27 @@ protected void setCookie(UserModel user) { protected void updateUser(UserModel userModel) { final UserModel userLocalDB = userManager.getUserModel(userModel.getName()); + String loginedUserDefaultTeam = settings.getString(Keys.realm.loginedUserDefaultTeam,null); + if(!StringUtils.isEmpty(loginedUserDefaultTeam)){ + TeamModel defaultTeam = userManager.getTeamModel(loginedUserDefaultTeam); + if( defaultTeam != null ) { + userModel.teams.add(defaultTeam); + } + } // Establish the checksum of the current version of the user final BigInteger userCurrentCheck = DeepCopier.checksum(userModel); // Establish the checksum of the stored version of the user final BigInteger userLocalDBcheck = DeepCopier.checksum(userLocalDB); + // Compare the checksums if (!userCurrentCheck.equals(userLocalDBcheck)) { // If mismatch, save the new instance. userManager.updateUserModel(userModel); } + + } protected void updateTeam(TeamModel teamModel) {