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 f509a87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 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
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<inceptionYear>2022</inceptionYear>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<keycloak.version>19.0.1</keycloak.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<keycloak.version>23.0.0</keycloak.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<distribution.name>${project.artifactId}</distribution.name>
</properties>
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 f509a87

Please sign in to comment.