| | |
| | | |
| | | import com.gitblit.Constants; |
| | | import com.gitblit.Constants.AccountType; |
| | | import com.gitblit.Constants.Role; |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider; |
| | | import com.gitblit.models.TeamModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.utils.ArrayUtils; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.sun.jna.platform.win32.Win32Exception; |
| | | |
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean supportsRoleChanges(UserModel user, Role role) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean supportsRoleChanges(TeamModel team, Role role) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public AccountType getAccountType() { |
| | | return AccountType.WINDOWS; |
| | |
| | | } |
| | | |
| | | UserModel user = userManager.getUserModel(username); |
| | | if (user == null) // create user object for new authenticated user |
| | | if (user == null) { |
| | | // create user object for new authenticated user |
| | | user = new UserModel(username.toLowerCase()); |
| | | } |
| | | |
| | | // create a user cookie |
| | | if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) { |
| | | user.cookie = StringUtils.getSHA1(user.username + new String(password)); |
| | | } |
| | | setCookie(user, password); |
| | | |
| | | // update user attributes from Windows identity |
| | | user.accountType = getAccountType(); |
| | |
| | | groupNames.add(group.getFqn()); |
| | | } |
| | | |
| | | if (groupNames.contains("BUILTIN\\Administrators")) { |
| | | // local administrator |
| | | user.canAdmin = true; |
| | | if (settings.getBoolean(Keys.realm.windows.permitBuiltInAdministrators, true)) { |
| | | if (groupNames.contains("BUILTIN\\Administrators")) { |
| | | // local administrator |
| | | user.canAdmin = true; |
| | | } |
| | | } |
| | | |
| | | // TODO consider mapping Windows groups to teams |