Browse Source

add realm.loginedUserDefaultTeam

if not empty, then every logined user will join this team
so we can set acl on the default team
pull/1250/head
qxo 6 years ago
parent
commit
83c8bbc1a8

+ 7
- 0
src/main/distrib/data/defaults.properties View File

# BASEFOLDER # BASEFOLDER
realm.userService = ${baseFolder}/users.conf 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 # Ordered list of external authentication providers which will be used if
# authentication against the local user service fails. # authentication against the local user service fails.
# #

+ 11
- 0
src/main/java/com/gitblit/auth/AuthenticationProvider.java View File

import com.gitblit.Constants.Role; import com.gitblit.Constants.Role;
import com.gitblit.Constants.AuthenticationType; import com.gitblit.Constants.AuthenticationType;
import com.gitblit.IStoredSettings; import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
import com.gitblit.manager.IRuntimeManager; import com.gitblit.manager.IRuntimeManager;
import com.gitblit.manager.IUserManager; import com.gitblit.manager.IUserManager;
import com.gitblit.models.TeamModel; import com.gitblit.models.TeamModel;
protected void updateUser(UserModel userModel) { protected void updateUser(UserModel userModel) {
final UserModel userLocalDB = userManager.getUserModel(userModel.getName()); 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 // Establish the checksum of the current version of the user
final BigInteger userCurrentCheck = DeepCopier.checksum(userModel); final BigInteger userCurrentCheck = DeepCopier.checksum(userModel);


// Establish the checksum of the stored version of the user // Establish the checksum of the stored version of the user
final BigInteger userLocalDBcheck = DeepCopier.checksum(userLocalDB); final BigInteger userLocalDBcheck = DeepCopier.checksum(userLocalDB);


// Compare the checksums // Compare the checksums
if (!userCurrentCheck.equals(userLocalDBcheck)) { if (!userCurrentCheck.equals(userLocalDBcheck)) {
// If mismatch, save the new instance. // If mismatch, save the new instance.
userManager.updateUserModel(userModel); userManager.updateUserModel(userModel);
} }
} }


protected void updateTeam(TeamModel teamModel) { protected void updateTeam(TeamModel teamModel) {

Loading…
Cancel
Save