Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=4.0.11
version=4.0.12
group=org.openmbee.mms

springBootVersion=2.6.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class GroupConstants {
public static final String GROUP_NOT_EMPTY = "Group is not empty";
public static final String GROUP_NOT_FOUND = "Group not found";
public static final String INVALID_ACTION = "Invalid action";
public static final String INVALID_GROUP_NAME= "Invalid group name";
public static final String INVALID_GROUP_NAME = "Invalid group name";
public static final String NAME = "name";
public static final String NO_USERS_PROVIDED = "No users provided";
public static final String RESTRICTED_GROUP = "Restricted group";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
@Service
public class GroupValidationService {

private static final Set<String> RESTRICTED_NAMES = Set.of(MMSADMIN, EVERYONE);
private Pattern VALID_GROUP_NAME_PATTERN = Pattern.compile("^[\\w-]+");
private static final Set<String> RESTRICTED_NAMES = Set.of(MMSADMIN, EVERYONE);
private final Pattern VALID_GROUP_NAME_PATTERN = Pattern.compile("^[ -~]+");

public boolean isRestrictedGroup(String groupName) {
return RESTRICTED_NAMES.contains(groupName);
}

public boolean isValidGroupName(String groupName){
public boolean isValidGroupName(String groupName) {
return groupName != null &&
!isRestrictedGroup(groupName) &&
VALID_GROUP_NAME_PATTERN.matcher(groupName).matches();
}

public boolean canDeleteGroup(Group group){
public boolean canDeleteGroup(Group group) {
return !isRestrictedGroup(group.getName()) &&
(group.getUsers() == null || group.getUsers().isEmpty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.springframework.ldap.core.support.BaseLdapPathContextSource;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.ldap.filter.*;
import org.springframework.ldap.support.LdapEncoder;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configurers.ldap.LdapAuthenticationProviderConfigurer;
Expand Down Expand Up @@ -185,7 +186,7 @@ public Collection<? extends GrantedAuthority> getGrantedAuthorities(

AndFilter andFilter = new AndFilter();
HardcodedFilter groupsFilter = new HardcodedFilter(
groupSearchFilter.replace("{0}", userDn));
groupSearchFilter.replace("{0}", LdapEncoder.filterEncode(userDn)));
andFilter.and(groupsFilter);
andFilter.and(orFilter);

Expand Down