default groups
This commit is contained in:
1 parent
6989589e72
commit
98958a2bc4
17 files changed
+242
-1
No files matched your search
@@ -165,6 +165,12 @@ public interface RealmModel extends RoleContainerModel {
|
||||
|
||||
void updateDefaultRoles(String[] defaultRoles);
|
||||
|
||||
List<GroupModel> getDefaultGroups();
|
||||
|
||||
void addDefaultGroup(GroupModel group);
|
||||
|
||||
void removeDefaultGroup(GroupModel group);
|
||||
|
||||
// Key is clientId
|
||||
Map<String, ClientModel> getClientNameMap();
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public class RealmEntity extends AbstractIdentifiableEntity {
|
||||
|
||||
// We are using names of defaultRoles (not ids)
|
||||
private List<String> defaultRoles = new ArrayList<String>();
|
||||
private List<String> defaultGroups = new ArrayList<String>();
|
||||
|
||||
private List<RequiredCredentialEntity> requiredCredentials = new ArrayList<RequiredCredentialEntity>();
|
||||
private List<UserFederationProviderEntity> userFederationProviders = new ArrayList<UserFederationProviderEntity>();
|
||||
@@ -629,6 +630,14 @@ public class RealmEntity extends AbstractIdentifiableEntity {
|
||||
public void setClientAuthenticationFlow(String clientAuthenticationFlow) {
|
||||
this.clientAuthenticationFlow = clientAuthenticationFlow;
|
||||
}
|
||||
|
||||
public List<String> getDefaultGroups() {
|
||||
return defaultGroups;
|
||||
}
|
||||
|
||||
public void setDefaultGroups(List<String> defaultGroups) {
|
||||
this.defaultGroups = defaultGroups;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -239,6 +239,14 @@ public class ModelToRepresentation {
|
||||
roleStrings.addAll(defaultRoles);
|
||||
rep.setDefaultRoles(roleStrings);
|
||||
}
|
||||
List<GroupModel> defaultGroups = realm.getDefaultGroups();
|
||||
if (!defaultGroups.isEmpty()) {
|
||||
List<String> groupPaths = new LinkedList<>();
|
||||
for (GroupModel group : defaultGroups) {
|
||||
groupPaths.add(ModelToRepresentation.buildGroupPath(group));
|
||||
}
|
||||
rep.setDefaultGroups(groupPaths);
|
||||
}
|
||||
|
||||
List<RequiredCredentialModel> requiredCredentialModels = realm.getRequiredCredentials();
|
||||
if (requiredCredentialModels.size() > 0) {
|
||||
|
||||
@@ -315,6 +315,13 @@ public class RepresentationToModel {
|
||||
|
||||
if (rep.getGroups() != null) {
|
||||
importGroups(newRealm, rep);
|
||||
if (rep.getDefaultGroups() != null) {
|
||||
for (String path : rep.getDefaultGroups()) {
|
||||
GroupModel found = KeycloakModelUtils.findGroupByPath(newRealm, path);
|
||||
if (found == null) throw new RuntimeException("default group in realm rep doesn't exist: " + path);
|
||||
newRealm.addDefaultGroup(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user