Configureable delimiter for remote auth groups (#1782)
* add groups-delimiter (REMOTE_AUTH_GROUPS_DELIMITER) for parsing groups from a remote auth source * added doc
This commit is contained in:
@@ -27,6 +27,7 @@ public class AppProperties {
|
||||
private String headerEmail;
|
||||
private String headerGroups;
|
||||
private String adminGroup;
|
||||
private String groupsDelimiter = "\\s+"; // Default to whitespace for backward compatibility
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
+3
-2
@@ -25,7 +25,6 @@ import java.util.regex.Pattern;
|
||||
@AllArgsConstructor
|
||||
public class UserProvisioningService {
|
||||
|
||||
private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+");
|
||||
private final AppProperties appProperties;
|
||||
private final UserRepository userRepository;
|
||||
private final LibraryRepository libraryRepository;
|
||||
@@ -146,7 +145,9 @@ public class UserProvisioningService {
|
||||
if (groupsContent.length() >= 2 && groupsContent.charAt(0) == '[' && groupsContent.charAt(groupsContent.length() - 1) == ']') {
|
||||
groupsContent = groupsContent.substring(1, groupsContent.length() - 1);
|
||||
}
|
||||
List<String> groupsList = Arrays.asList(WHITESPACE_PATTERN.split(groupsContent));
|
||||
String delimiter = appProperties.getRemoteAuth().getGroupsDelimiter();
|
||||
Pattern groupsPattern = Pattern.compile(delimiter);
|
||||
List<String> groupsList = Arrays.asList(groupsPattern.split(groupsContent));
|
||||
isAdmin = groupsList.contains(appProperties.getRemoteAuth().getAdminGroup());
|
||||
log.debug("Remote-Auth: user {} will be admin: {}", username, isAdmin);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ app:
|
||||
header-email: ${REMOTE_AUTH_HEADER_EMAIL:Remote-Email}
|
||||
header-groups: ${REMOTE_AUTH_HEADER_GROUPS:Remote-Groups}
|
||||
admin-group: ${REMOTE_AUTH_ADMIN_GROUP}
|
||||
groups-delimiter: ${REMOTE_AUTH_GROUPS_DELIMITER:\\s+}
|
||||
force-disable-oidc: ${FORCE_DISABLE_OIDC:false}
|
||||
|
||||
server:
|
||||
|
||||
Reference in New Issue
Block a user