Skip to content

Commit

Permalink
fix: add compatbility to keycloak 23. This breaks compatibility to ol…
Browse files Browse the repository at this point in the history
…der versions.
  • Loading branch information
desaintmartin committed May 2, 2024
1 parent 2c2fd67 commit c82ac16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM maven:3.9.5-eclipse-temurin-17 AS build
FROM maven:3.9.6-eclipse-temurin-17 AS build

WORKDIR /home/app/src

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ public List<ProviderConfigProperty> getConfigProperties() {

@Override
public void importNewUser(KeycloakSession keycloakSession, RealmModel realmModel, UserModel userModel, IdentityProviderMapperModel identityProviderMapperModel, BrokeredIdentityContext brokeredIdentityContext) {
updateUserGroups(realmModel, userModel, identityProviderMapperModel);
updateUserGroups(keycloakSession, realmModel, userModel, identityProviderMapperModel);
}

@Override
public void updateBrokeredUser(KeycloakSession keycloakSession, RealmModel realmModel, UserModel userModel, IdentityProviderMapperModel identityProviderMapperModel, BrokeredIdentityContext brokeredIdentityContext) {
updateUserGroups(realmModel, userModel, identityProviderMapperModel);
updateUserGroups(keycloakSession, realmModel, userModel, identityProviderMapperModel);
}

private void updateUserGroups(RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel) {
GroupModel parentGroup = getParentGroup(realm, mapperModel);
private void updateUserGroups(KeycloakSession keycloakSession, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel) {
GroupModel parentGroup = getParentGroup(keycloakSession, realm, mapperModel);

List<String> userGroupNames = googleClient.getUsergroupNames(user.getEmail());

Expand Down Expand Up @@ -144,12 +144,12 @@ public String getHelpText() {
return "Adds the user to all groups that the user is a member of in Google";
}

public GroupModel getParentGroup(RealmModel realm, IdentityProviderMapperModel mapperModel) {
public GroupModel getParentGroup(KeycloakSession keycloakSession, RealmModel realm, IdentityProviderMapperModel mapperModel) {
String groupPath = mapperModel.getConfig().get(MAPPER_MODEL_KEY_PARENT_GROUP);
if(groupPath == null) {
throw new RuntimeException("No parent group configured.");
}
return KeycloakModelUtils.findGroupByPath(realm, groupPath);
return KeycloakModelUtils.findGroupByPath(keycloakSession, realm, groupPath);
}

}

0 comments on commit c82ac16

Please sign in to comment.